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