Open
Description
numpydoc 1.9.0rc0.dev0 git tip (2025-05-16)
CPython 3.12
A round-trip through FunctionDoc improperly removes empty lines after elements of Parameters
.
This in turn breaks doctest.
In [1]: def f():
...: """
...: Hello world
...:
...: Parameters
...: ----------
...: foo : int
...: foo desc
...:
...: >>> x = [1, 2]
...:
...: bar: int
...: bar desc
...: """
In [2]: import doctest
In [3]: doctest.testmod()
Out[3]: TestResults(failed=0, attempted=1)
In [4]: from numpydoc.docscrape import FunctionDoc
In [5]: print(FunctionDoc(f))
.. function:: f
Hello world
Parameters
----------
foo : int
foo desc
>>> x = [1, 2]
bar: int
bar desc
In [6]: f.__doc__ = str(FunctionDoc(f))
In [7]: doctest.testmod()
ValueError: line 13 of the docstring for __main__.f has inconsistent leading whitespace: 'bar: int'
Metadata
Metadata
Assignees
Labels
No labels