From f3f1194e9e676465c50a7c31024996f5726837ab Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Tue, 14 Jul 2020 21:25:07 -0700 Subject: [PATCH] BUG: Properly parse See Also when summary on first line. 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 --- numpydoc/docscrape.py | 2 ++ numpydoc/tests/test_docscrape.py | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/numpydoc/docscrape.py b/numpydoc/docscrape.py index 77de401b..d79992cb 100644 --- a/numpydoc/docscrape.py +++ b/numpydoc/docscrape.py @@ -284,6 +284,8 @@ def _parse_see_also(self, content): """ + content = dedent_lines(content) + items = [] def parse_item_name(text): diff --git a/numpydoc/tests/test_docscrape.py b/numpydoc/tests/test_docscrape.py index 8b297044..d55b211b 100644 --- a/numpydoc/tests/test_docscrape.py +++ b/numpydoc/tests/test_docscrape.py @@ -17,6 +17,7 @@ ) from numpydoc.docscrape_sphinx import (SphinxDocString, SphinxClassDoc, SphinxFunctionDoc, get_doc_object) +import pytest from pytest import raises as assert_raises from pytest import warns as assert_warns @@ -766,11 +767,10 @@ def test_warns(): assert param.type == 'SomeWarning' assert param.desc == ['If needed'] - -def test_see_also(): +@pytest.mark.parametrize('prefix', ['', '\n ']) +def test_see_also(prefix): doc6 = NumpyDocString( - """ - z(x,theta) + prefix + """z(x,theta) See Also --------