From ed037cfa22db503ba856bfd7fadad304bfb893cb Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Wed, 17 Jul 2024 11:51:42 -0700 Subject: [PATCH 1/2] Dedent section starting with `.. deprecation::` Closes https://github.com/numpy/numpydoc/issues/573 --- numpydoc/docscrape.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpydoc/docscrape.py b/numpydoc/docscrape.py index aa13217e..5f4dcdd7 100644 --- a/numpydoc/docscrape.py +++ b/numpydoc/docscrape.py @@ -206,7 +206,7 @@ def _read_to_next_section(self): section += self._doc.read_to_next_empty_line() - return section + return dedent_lines(section) def _read_sections(self): while not self._doc.eof(): From 9ea070bd588811adea418e18d3ac6f1ff12ae494 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Fri, 22 May 2026 16:45:41 -0700 Subject: [PATCH 2/2] Only wrap if there's something to wrap --- numpydoc/docscrape.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/numpydoc/docscrape.py b/numpydoc/docscrape.py index 194cc80d..c41b98fe 100644 --- a/numpydoc/docscrape.py +++ b/numpydoc/docscrape.py @@ -570,6 +570,8 @@ def __str__(self, func_role=""): def dedent_lines(lines): """Deindent a list of lines maximally""" + if not lines: + return lines return textwrap.dedent("\n".join(lines)).split("\n")