Skip to content

Commit 545cce2

Browse files
committed
sphinx.ext.napoleon: Don't indent empty lines
Signed-off-by: Stephen Finucane <[email protected]>
1 parent 34403ad commit 545cce2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

sphinx/ext/napoleon/docstring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ def _get_min_indent(self, lines: list[str]) -> int:
534534
return min_indent or 0
535535

536536
def _indent(self, lines: list[str], n: int = 4) -> list[str]:
537-
return [(' ' * n) + line for line in lines]
537+
return [(' ' * n) + line if line else line for line in lines]
538538

539539
def _is_indented(self, line: str, indent: int = 1) -> bool:
540540
for i, s in enumerate(line): # noqa: SIM110

tests/test_ext_napoleon_docstring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ def test_noindex(self):
11541154
.. method:: func(i, j)
11551155
:no-index:
11561156
1157-
1157+
11581158
description
11591159
""" # noqa: W293
11601160
config = Config()

0 commit comments

Comments
 (0)