Support report terminal output in Markdown Table format · Issue #1418 · nedbat/coveragepy (original) (raw)
The current terminal report is great, but wondered if there would be interest in adding a new output format or flag to support markdown table syntax.
This would enable nice display of coverage reports in rendered html that contains the markdown output. Some examples where this might be nice:
- Users could used Cog to automate the inclusion of coverage report information in documentation.
- GitHub actions workflow summaries could have nicely formatted tables of coverage information, example here
Current appearance:
Name Stmts Miss Cover
---------------------------------------------
my_program.py 20 4 80%
my_module.py 15 2 86%
my_other_module.py 56 6 89%
---------------------------------------------
TOTAL 91 12 87%
Sample Markdown syntax:
| Name | Stmts | Miss | Cover |
| ------------------ | ---------- | -------- | -------- |
| my_program.py | 20 | 4 | 80% |
| my_module.py | 15 | 2 | 86% |
| my_other_module.py | 56 | 6 | 89% |
| **TOTAL** | **91** | **12** | **87%** |
Sample Rendering:
Name | Stmts | Miss | Cover |
---|---|---|---|
my_program.py | 20 | 4 | 80% |
my_module.py | 15 | 2 | 86% |
my_other_module.py | 56 | 6 | 89% |
TOTAL | 91 | 12 | 87% |
Describe the solution you'd like
Ideally the a flag to the default report
subcommand could indicate to use markdown syntax like:
$ coverage report --markdown
Name | Stmts | Miss | Cover |
---|---|---|---|
my_program.py | 20 | 4 | 80% |
my_module.py | 15 | 2 | 86% |
my_other_module.py | 56 | 6 | 89% |
TOTAL | 91 | 12 | 87% |
$ |
This would allow the output to be piped to a file in the GitHub action summary, or captured by cog to inject into a markdown file.
Describe alternatives you've considered
If the report
subcommand is not suitable place to add this flag then a new subcommand specifically for markdown reporting might be a good alternative with coverage markdown
$ coverage markdown
Name | Stmts | Miss | Cover |
---|---|---|---|
my_program.py | 20 | 4 | 80% |
my_module.py | 15 | 2 | 86% |
my_other_module.py | 56 | 6 | 89% |
TOTAL | 91 | 12 | 87% |
$ |