Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Fix error table RST, max short code now over 69 chars #396

Merged
merged 3 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all 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 docs/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Bug Fixes
e.g., init and initialize / initiate (#382).
* Fix parser hanging when there's a comment directly after ``__all__``
(#391, #366).
* Fixed RST error in table which resulted in the online documentation missing
the violation code table (#396).
* Fixed IndentationError when parsing function arguments (#392).

4.0.0 - July 6th, 2019
Expand Down
9 changes: 5 additions & 4 deletions src/pydocstyle/violations.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,19 @@ def get_error_codes(cls) -> Iterable[str]:
@classmethod
def to_rst(cls) -> str:
"""Output the registry as reStructuredText, for documentation."""
sep_line = '+' + 6 * '-' + '+' + '-' * 71 + '+\n'
blank_line = '|' + 78 * ' ' + '|\n'
max_len = max(len(error.short_desc) for group in cls.groups for error in group.errors)
sep_line = '+' + 6 * '-' + '+' + '-' * (max_len + 2) + '+\n'
blank_line = '|' + (max_len + 9) * ' ' + '|\n'
table = ''
for group in cls.groups:
table += sep_line
table += blank_line
table += '|' + '**{}**'.format(group.name).center(78) + '|\n'
table += '|' + '**{}**'.format(group.name).center(max_len + 9) + '|\n'
table += blank_line
for error in group.errors:
table += sep_line
table += ('|' + error.code.center(6) + '| ' +
error.short_desc.ljust(70) + '|\n')
error.short_desc.ljust(max_len + 1) + '|\n')
table += sep_line
return table

Expand Down