From 8a5376ba14225e785c9c7236dac046036dabf1f9 Mon Sep 17 00:00:00 2001 From: Peter Cock Date: Thu, 15 Aug 2019 06:44:55 +0100 Subject: [PATCH] Fix error table RST, max short code now over 69 chars (#396) * Fix error table RST, max short code now over 69 chars Should close #380. * Release note with link to pull request --- docs/release_notes.rst | 2 ++ src/pydocstyle/violations.py | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/release_notes.rst b/docs/release_notes.rst index 9cebd3f5..7a573ca4 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -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 diff --git a/src/pydocstyle/violations.py b/src/pydocstyle/violations.py index 33109e73..e2cc3473 100644 --- a/src/pydocstyle/violations.py +++ b/src/pydocstyle/violations.py @@ -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