Skip to content

Commit 080aa87

Browse files
authored
Don't print fully documented file stats (HunterMcGushion#85)
* Don't print fully documented file stats * Print empty files after all? * 'continue' statement * -v 4 as discussed with @killthekitten * also print present docstrings in -v 4 * fix test
1 parent 0d8653f commit 080aa87

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ docstr-coverage some_project/src
8787
- 1 - Print overall statistics
8888
- 2 - Also print individual statistics for each file
8989
- 3 - Also print missing docstrings (function names, class names, etc.)
90+
- 4 - Also print information about present docstrings
9091
- _--fail-under=<int|float>, -F <int|float>_ - Fail if under a certain percentage of coverage (default: 100.0)
9192
- _--docstr-ignore-file=\<filepath\>, -d \<filepath\>_ - Filepath containing list of patterns to ignore. Patterns are (file-pattern, name-pattern) pairs
9293
- File content example:

docstr_coverage/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def _assert_valid_key_value(k, v):
156156
@click.option(
157157
"-v",
158158
"--verbose",
159-
type=click.Choice(["0", "1", "2", "3"]),
159+
type=click.Choice(["0", "1", "2", "3", "4"]),
160160
default="3",
161161
help="Verbosity level",
162162
show_default=True,

docstr_coverage/printers.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,29 @@ def _print_file_statistics(self, results):
6363
results: ResultCollection
6464
The information about docstr presence to be printed to stdout."""
6565
for file_path, file in results.files():
66+
if self.verbosity < 4 and file.count_aggregate().missing == 0:
67+
# Don't print fully documented files
68+
continue
69+
6670
# File Header
6771
print_line('\nFile: "{}"'.format(file_path))
6872

6973
# List of missing docstrings
7074
if self.verbosity >= 3:
71-
if file.status == FileStatus.EMPTY:
75+
if file.status == FileStatus.EMPTY and self.verbosity > 3:
7276
print_line(" - File is empty")
7377
for expected_docstr in file._expected_docstrings:
74-
if not expected_docstr.has_docstring and not expected_docstr.ignore_reason:
78+
if expected_docstr.has_docstring and self.verbosity > 3:
79+
print_line(
80+
" - Found docstring for `{0}`".format(expected_docstr.node_identifier)
81+
)
82+
elif expected_docstr.ignore_reason and self.verbosity > 3:
83+
print_line(
84+
" - Ignored `{0}`: reason: `{1}`".format(
85+
expected_docstr.node_identifier, expected_docstr.ignore_reason
86+
)
87+
)
88+
elif not expected_docstr.has_docstring and not expected_docstr.ignore_reason:
7589
if expected_docstr.node_identifier == "module docstring":
7690
print_line(" - No module docstring")
7791
else:

tests/test_coverage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def test_should_report_when_no_docs_in_a_file():
160160
def test_logging_empty_file(caplog, expected):
161161
with caplog.at_level(logging.DEBUG):
162162
result = analyze([EMPTY_FILE_PATH])
163-
LegacyPrinter(verbosity=3).print(result)
163+
LegacyPrinter(verbosity=4).print(result)
164164
_file_results, _total_results = result.to_legacy()
165165

166166
if platform.system() == "Windows":

0 commit comments

Comments
 (0)