Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Bugs fixed
Patch by Bénédikt Tran.
* #11697: HTML Search: add 'noindex' meta robots tag.
Patch by James Addison.
* #11678: Fix ``ZeroDivisionError`` in ``sphinx.ext.coverage``.
Patch by Lonami.

Testing
-------
Expand Down
14 changes: 9 additions & 5 deletions sphinx/ext/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,15 @@ def _write_py_statistics(self, op: TextIO) -> None:
value = 100.0

table.append([module, '%.2f%%' % value, '%d' % len(self.py_undocumented[module])])
table.append([
'TOTAL',
f'{100 * len(all_documented_objects) / len(all_objects):.2f}%',
f'{len(all_objects) - len(all_documented_objects)}',
])

if all_objects:
table.append([
'TOTAL',
f'{100 * len(all_documented_objects) / len(all_objects):.2f}%',
f'{len(all_objects) - len(all_documented_objects)}',
])
else:
table.append(['TOTAL', '100', '0'])

for line in _write_table(table):
op.write(f'{line}\n')
Expand Down