Skip to content

Commit 4e86e81

Browse files
authored
BUG: Properly parse See Also when summary on first line. (#283)
in a case like: """signature See Also -------- a,b,c,d """" Numpydoc would incorrectly assign `a, b, c, d` as a description with no name, or type associated items. Closes #281
1 parent fd17df0 commit 4e86e81

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

numpydoc/docscrape.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ def _parse_see_also(self, content):
284284
285285
"""
286286

287+
content = dedent_lines(content)
288+
287289
items = []
288290

289291
def parse_item_name(text):

numpydoc/tests/test_docscrape.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
)
1818
from numpydoc.docscrape_sphinx import (SphinxDocString, SphinxClassDoc,
1919
SphinxFunctionDoc, get_doc_object)
20+
import pytest
2021
from pytest import raises as assert_raises
2122
from pytest import warns as assert_warns
2223

@@ -766,11 +767,16 @@ def test_warns():
766767
assert param.type == 'SomeWarning'
767768
assert param.desc == ['If needed']
768769

769-
770-
def test_see_also():
770+
# see numpydoc/numpydoc #281
771+
# we want to correctly parse "See Also" both in docstrings both like
772+
#"""foo
773+
# and
774+
#"""
775+
#foo
776+
@pytest.mark.parametrize('prefix', ['', '\n '])
777+
def test_see_also(prefix):
771778
doc6 = NumpyDocString(
772-
"""
773-
z(x,theta)
779+
prefix + """z(x,theta)
774780
775781
See Also
776782
--------

0 commit comments

Comments
 (0)