Skip to content

Commit 9b75042

Browse files
committed
coverage: Handle no modules
If you run coverage and there are no modules documented, we currently exit with a ZeroDivision error. Resolve this. Signed-off-by: Stephen Finucane <[email protected]>
1 parent 5e2a746 commit 9b75042

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

sphinx/ext/coverage.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,15 @@ def _write_py_statistics(self, op: TextIO) -> None:
362362
value = 100.0
363363

364364
table.append([module, '%.2f%%' % value, '%d' % len(self.py_undocumented[module])])
365-
table.append([
366-
'TOTAL',
367-
f'{100 * len(all_documented_objects) / len(all_objects):.2f}%',
368-
f'{len(all_objects) - len(all_documented_objects)}',
369-
])
365+
366+
if len(all_objects):
367+
table.append([
368+
'TOTAL',
369+
f'{100 * len(all_documented_objects) / len(all_objects):.2f}%',
370+
f'{len(all_objects) - len(all_documented_objects)}',
371+
])
372+
else:
373+
table.append(['TOTAL', '100', '0'])
370374

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

0 commit comments

Comments
 (0)