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

Commit

Permalink
Fix error table RST, max short code now over 69 chars (#396)
Browse files Browse the repository at this point in the history
* Fix error table RST, max short code now over 69 chars

Should close #380.

* Release note with link to pull request
  • Loading branch information
peterjc authored and Nurdok committed Aug 15, 2019
1 parent 0e9d708 commit 8a5376b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
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

0 comments on commit 8a5376b

Please sign in to comment.