Skip to content

Commit a5fd825

Browse files
[primer] Add blank line after <details> tag for proper markdown rendering (#10948)
GitHub markdown requires a blank line after <details> for the content inside to be rendered as markdown rather than plain text.
1 parent 5ad1249 commit a5fd825

12 files changed

Lines changed: 26 additions & 7 deletions

File tree

pylint/testutils/_primer/primer_compare_command.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ def _create_comment_for_package(
7373
)
7474
if new_non_astroid_messages:
7575
comment += (
76-
"The following messages are now emitted:\n\n<details>\n"
76+
"The following messages are now emitted:\n\n<details>\n\n"
7777
+ new_non_astroid_messages
7878
+ "</details>\n\n"
7979
)
8080

8181
# Create comment for missing messages
8282
count = 1
8383
if missing_messages["messages"]:
84-
comment += "The following messages are no longer emitted:\n\n<details>\n"
84+
comment += "The following messages are no longer emitted:\n\n<details>\n\n"
8585
print("No longer emitted:")
8686
for message in missing_messages["messages"]:
8787
comment += f"{count}) {message['symbol']}:\n*{message['message']}*\n"
@@ -122,7 +122,12 @@ def _truncate_comment(self, comment: str) -> str:
122122
- len(suffix)
123123
- len(closing_tag)
124124
)
125-
comment = comment[: max_len - 10] + "...\n"
125+
# Cut at the last space before the limit to avoid mid-word truncation.
126+
cut_point = comment.rfind(" ", 0, max_len - 10)
127+
if cut_point > 0:
128+
comment = comment[:cut_point] + "...\n"
129+
else:
130+
comment = comment[: max_len - 10] + "...\n"
126131
# Close any <details> tag left open by the truncation.
127132
if comment.count("<details>") > comment.count("</details>"):
128133
comment += closing_tag

tests/testutils/_primer/batched_cases/expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
The following messages are no longer emitted:
77

88
<details>
9+
910
1) locally-disabled:
1011
*Locally disabling redefined-builtin (W0622)*
1112
https://github.com/pylint-dev/astroid/blob/1234567890abcdef/astroid/__init__.py#L91

tests/testutils/_primer/cases/line_moved/expected.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
The following messages are now emitted:
77

88
<details>
9+
910
1) too-complex:
1011
*'my_function' is too complex. The McCabe rating is 18*
1112
https://github.com/pylint-dev/astroid/blob/123456789abcdef/astroid/node_classes.py#L103
@@ -14,6 +15,7 @@ https://github.com/pylint-dev/astroid/blob/123456789abcdef/astroid/node_classes.
1415
The following messages are no longer emitted:
1516

1617
<details>
18+
1719
1) too-complex:
1820
*'my_function' is too complex. The McCabe rating is 18*
1921
https://github.com/pylint-dev/astroid/blob/123456789abcdef/astroid/node_classes.py#L100

tests/testutils/_primer/cases/message_changed/expected.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
The following messages are now emitted:
77

88
<details>
9+
910
1) locally-disabled:
1011
*Locally disabling redefined-builtin [we added some text in the message] (W0622)*
1112
https://github.com/pylint-dev/astroid/blob/123456789abcdef/astroid/__init__.py#L91
@@ -14,6 +15,7 @@ https://github.com/pylint-dev/astroid/blob/123456789abcdef/astroid/__init__.py#L
1415
The following messages are no longer emitted:
1516

1617
<details>
18+
1719
1) locally-disabled:
1820
*Locally disabling redefined-builtin (W0622)*
1921
https://github.com/pylint-dev/astroid/blob/123456789abcdef/astroid/__init__.py#L91

tests/testutils/_primer/cases/message_changed/expected_truncated.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
The following messages are now emitted:
77

88
<details>
9+
910
1) locally-disabled:
10-
*Locally disabling redefined-builtin [we added some text in the message] (W0622)*
11-
https://github.com/pylint-dev/astroid/blob/123456789abcdef/astroid/__init__.py#L91
11+
*Locally disabling redefined-builtin [we added some text in the message]...
1212
</details>
13-
...
1413

1514
*This comment was truncated because GitHub allows only 525 characters in a comment.*
1615

tests/testutils/_primer/cases/message_changed/expected_truncated_in_details.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
The following messages are now emitted:
77

88
<details>
9+
910
1) locally-disabled:
10-
*Locally disabling redefined-builtin [we added some text in the message...
11+
*Locally disabling redefined-builtin [we added some text in the...
1112
</details>
1213

1314
*This comment was truncated because GitHub allows only 420 characters in a comment.*

tests/testutils/_primer/cases/message_changed_line/expected.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
The following messages are now emitted:
77

88
<details>
9+
910
1) too-complex:
1011
*'my_function' is too complex. The McCabe rating is 17*
1112
https://github.com/pylint-dev/astroid/blob/123456789abcdef/astroid/node_classes.py#L103
@@ -14,6 +15,7 @@ https://github.com/pylint-dev/astroid/blob/123456789abcdef/astroid/node_classes.
1415
The following messages are no longer emitted:
1516

1617
<details>
18+
1719
1) too-complex:
1820
*'my_function' is too complex. The McCabe rating is 18*
1921
https://github.com/pylint-dev/astroid/blob/123456789abcdef/astroid/node_classes.py#L100

tests/testutils/_primer/cases/mixed_changes/expected.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
The following messages are now emitted:
77

88
<details>
9+
910
1) locally-disabled:
1011
*Locally disabling redefined-builtin [we added some text in the message] (W0622)*
1112
https://github.com/pylint-dev/astroid/blob/123456789abcdef/astroid/__init__.py#L91
@@ -17,6 +18,7 @@ https://github.com/pylint-dev/astroid/blob/123456789abcdef/astroid/node_classes.
1718
The following messages are no longer emitted:
1819

1920
<details>
21+
2022
1) locally-disabled:
2123
*Locally disabling redefined-builtin (W0622)*
2224
https://github.com/pylint-dev/astroid/blob/123456789abcdef/astroid/__init__.py#L91

tests/testutils/_primer/cases/new_message/expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
The following messages are now emitted:
77

88
<details>
9+
910
1) locally-disabled:
1011
*Locally disabling redefined-builtin [we added some text in the message] (W0622)*
1112
https://github.com/pylint-dev/astroid/blob/123456789abcdef/astroid/__init__.py#L91

tests/testutils/_primer/cases/removed_message/expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
The following messages are no longer emitted:
77

88
<details>
9+
910
1) unknown-option-value:
1011
*Unknown option value for 'disable', expected a valid pylint message and got 'Ellipsis'*
1112
https://github.com/pylint-dev/astroid/blob/123456789abcdef/astroid/__init__.py#L91

0 commit comments

Comments
 (0)