-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid removing newlines between docstring headers and rST blocks (#11609
) Given: ```python def func(): """ Example: .. code-block:: python import foo """ ``` Removing the newline after the `Example:` header breaks Sphinx rendering. See: #11577
- Loading branch information
1 parent
b0a7510
commit 3aa7e35
Showing
4 changed files
with
254 additions
and
26 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
crates/ruff_linter/resources/test/fixtures/pydocstyle/sphinx.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
def func(): | ||
""" | ||
Example: | ||
.. code-block:: python | ||
import foo | ||
""" | ||
|
||
|
||
def func(): | ||
""" | ||
Example: | ||
.. code-block:: python | ||
import foo | ||
""" | ||
|
||
|
||
def func(): | ||
""" | ||
Example: | ||
.. code-block:: python | ||
import foo | ||
""" | ||
|
||
|
||
def func(): | ||
""" | ||
Example | ||
------- | ||
.. code-block:: python | ||
import foo | ||
""" | ||
|
||
|
||
def func(): | ||
""" | ||
Example | ||
------- | ||
.. code-block:: python | ||
import foo | ||
""" | ||
|
||
|
||
def func(): | ||
""" | ||
Example | ||
------- | ||
.. code-block:: python | ||
import foo | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
...src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sphinx.py.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pydocstyle/mod.rs | ||
--- | ||
sphinx.py:13:5: D412 [*] No blank lines allowed between a section header and its content ("Example") | ||
| | ||
11 | def func(): | ||
12 | """ | ||
13 | Example: | ||
| ^^^^^^^ D412 | ||
| | ||
= help: Remove blank line(s) | ||
|
||
ℹ Safe fix | ||
12 12 | """ | ||
13 13 | Example: | ||
14 14 | | ||
15 |- | ||
16 15 | .. code-block:: python | ||
17 16 | | ||
18 17 | import foo | ||
|
||
sphinx.py:24:5: D412 [*] No blank lines allowed between a section header and its content ("Example") | ||
| | ||
22 | def func(): | ||
23 | """ | ||
24 | Example: | ||
| ^^^^^^^ D412 | ||
| | ||
= help: Remove blank line(s) | ||
|
||
ℹ Safe fix | ||
23 23 | """ | ||
24 24 | Example: | ||
25 25 | | ||
26 |- | ||
27 |- | ||
28 26 | .. code-block:: python | ||
29 27 | | ||
30 28 | import foo | ||
|
||
sphinx.py:47:5: D412 [*] No blank lines allowed between a section header and its content ("Example") | ||
| | ||
45 | def func(): | ||
46 | """ | ||
47 | Example | ||
| ^^^^^^^ D412 | ||
48 | ------- | ||
| | ||
= help: Remove blank line(s) | ||
|
||
ℹ Safe fix | ||
47 47 | Example | ||
48 48 | ------- | ||
49 49 | | ||
50 |- | ||
51 50 | .. code-block:: python | ||
52 51 | | ||
53 52 | import foo | ||
|
||
sphinx.py:59:5: D412 [*] No blank lines allowed between a section header and its content ("Example") | ||
| | ||
57 | def func(): | ||
58 | """ | ||
59 | Example | ||
| ^^^^^^^ D412 | ||
60 | ------- | ||
| | ||
= help: Remove blank line(s) | ||
|
||
ℹ Safe fix | ||
59 59 | Example | ||
60 60 | ------- | ||
61 61 | | ||
62 |- | ||
63 |- | ||
64 62 | .. code-block:: python | ||
65 63 | | ||
66 64 | import foo |