-
Notifications
You must be signed in to change notification settings - Fork 20
Adding Markdown printer #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
0156125
298c279
7671497
c5105ee
e3862aa
940a31b
62ee8b3
4059d62
32efe47
6fb7404
d321905
6f94034
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ | |
| from docstr_coverage.config_file import set_config_defaults | ||
| from docstr_coverage.coverage import analyze | ||
| from docstr_coverage.ignore_config import IgnoreConfig | ||
| from docstr_coverage.printers import LegacyPrinter | ||
| from docstr_coverage.printers import LegacyPrinter, MarkdownPrinter | ||
|
|
||
|
|
||
| def do_include_filepath(filepath: str, exclude_re: Optional["re.Pattern"]) -> bool: | ||
|
|
@@ -261,6 +261,24 @@ def _assert_valid_key_value(k, v): | |
| default=".docstr_coverage", | ||
| help="Deprecated. Use json config (--config / -C) instead", | ||
| ) | ||
| @click.option( | ||
| "-o", | ||
| "--output", | ||
| type=click.Choice(["stdout", "file"]), | ||
| default="stdout", | ||
| help="Format of output", | ||
|
||
| show_default=True, | ||
| metavar="FORMAT", | ||
| ) | ||
| @click.option( | ||
| "-r", | ||
| "--format", | ||
| type=click.Choice(["text", "markdown"]), | ||
| default="text", | ||
| help="Format of output", | ||
| show_default=True, | ||
| metavar="FORMAT", | ||
| ) | ||
| def execute(paths, **kwargs): | ||
| """Measure docstring coverage for `PATHS`""" | ||
|
|
||
|
|
@@ -328,7 +346,21 @@ def execute(paths, **kwargs): | |
| show_progress = not kwargs["percentage_only"] | ||
| results = analyze(all_paths, ignore_config=ignore_config, show_progress=show_progress) | ||
|
|
||
| LegacyPrinter(verbosity=kwargs["verbose"], ignore_config=ignore_config).print(results) | ||
| report_format: str = kwargs["format"] | ||
| if report_format == "markdown": | ||
| printer = MarkdownPrinter(results, verbosity=kwargs["verbose"], ignore_config=ignore_config) | ||
| elif report_format == "text": | ||
| printer = LegacyPrinter(results, verbosity=kwargs["verbose"], ignore_config=ignore_config) | ||
| else: | ||
| raise SystemError("Unknown report format: {0}".format(report_format)) | ||
|
|
||
| output_type: str = kwargs["output"] | ||
| if output_type == "file": | ||
| printer.save_to_file() | ||
HunterMcGushion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| elif output_type == "stdout": | ||
| printer.print_to_stdout() | ||
| else: | ||
| raise SystemError("Unknown output type: {0}".format(output_type)) | ||
|
|
||
| file_results, total_results = results.to_legacy() | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.