Skip to content

Commit

Permalink
FIX Handle case where description is empty in returns (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnothman committed Nov 20, 2017
1 parent 8c1e85c commit e6f4bf9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
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

0 comments on commit e6f4bf9

Please sign in to comment.