Skip to content

FIX Handle case where description is empty in returns #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions numpydoc/docscrape_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ def _str_returns(self, name='Returns'):
param_type)])
else:
out += self._str_indent([untyped_fmt % param.strip()])
if desc:
if self.use_blockquotes:
out += ['']
out += self._str_indent(desc, 8)
if desc and self.use_blockquotes:
out += ['']
elif not desc:
desc = ['..']
out += self._str_indent(desc, 8)
out += ['']
return out

Expand Down
12 changes: 11 additions & 1 deletion numpydoc/tests/test_docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
list of str
This is not a real return value. It exists to test
anonymous return values.
no_description

Other Parameters
----------------
Expand Down Expand Up @@ -184,7 +185,7 @@ def test_other_parameters():


def test_returns():
assert_equal(len(doc['Returns']), 2)
assert_equal(len(doc['Returns']), 3)
arg, arg_type, desc = doc['Returns'][0]
assert_equal(arg, 'out')
assert_equal(arg_type, 'ndarray')
Expand All @@ -197,6 +198,11 @@ def test_returns():
assert desc[0].startswith('This is not a real')
assert desc[-1].endswith('anonymous return values.')

arg, arg_type, desc = doc['Returns'][2]
assert_equal(arg, 'no_description')
assert_equal(arg_type, '')
assert not ''.join(desc).strip()


def test_yields():
section = doc_yields['Yields']
Expand Down Expand Up @@ -373,6 +379,7 @@ def test_str():
list of str
This is not a real return value. It exists to test
anonymous return values.
no_description

Other Parameters
----------------
Expand Down Expand Up @@ -506,6 +513,9 @@ def test_sphinx_str():
This is not a real return value. It exists to test
anonymous return values.

no_description
..

:Other Parameters:

spam : parrot
Expand Down