Skip to content

Commit 652f396

Browse files
committed
Fix error table RST, max short code now over 69 chars
Should close PyCQA#380.
1 parent 49183a3 commit 652f396

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/pydocstyle/violations.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,19 @@ def get_error_codes(cls) -> Iterable[str]:
152152
@classmethod
153153
def to_rst(cls) -> str:
154154
"""Output the registry as reStructuredText, for documentation."""
155-
sep_line = '+' + 6 * '-' + '+' + '-' * 71 + '+\n'
156-
blank_line = '|' + 78 * ' ' + '|\n'
155+
max_len = max(len(error.short_desc) for group in cls.groups for error in group.errors)
156+
sep_line = '+' + 6 * '-' + '+' + '-' * (max_len + 2) + '+\n'
157+
blank_line = '|' + (max_len + 9) * ' ' + '|\n'
157158
table = ''
158159
for group in cls.groups:
159160
table += sep_line
160161
table += blank_line
161-
table += '|' + '**{}**'.format(group.name).center(78) + '|\n'
162+
table += '|' + '**{}**'.format(group.name).center(max_len + 9) + '|\n'
162163
table += blank_line
163164
for error in group.errors:
164165
table += sep_line
165166
table += ('|' + error.code.center(6) + '| ' +
166-
error.short_desc.ljust(70) + '|\n')
167+
error.short_desc.ljust(max_len + 1) + '|\n')
167168
table += sep_line
168169
return table
169170

0 commit comments

Comments
 (0)