From 0e6f6898bd1f0dbe264a1311cd8406ae81c36090 Mon Sep 17 00:00:00 2001 From: Joel Nothman Date: Wed, 15 Nov 2017 20:36:09 +1100 Subject: [PATCH] FIX Handle case where description is empty in returns --- numpydoc/docscrape_sphinx.py | 9 +++++---- numpydoc/tests/test_docscrape.py | 12 +++++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/numpydoc/docscrape_sphinx.py b/numpydoc/docscrape_sphinx.py index 640efa7b..087ddafb 100644 --- a/numpydoc/docscrape_sphinx.py +++ b/numpydoc/docscrape_sphinx.py @@ -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 diff --git a/numpydoc/tests/test_docscrape.py b/numpydoc/tests/test_docscrape.py index fa3f700f..21bbe28b 100644 --- a/numpydoc/tests/test_docscrape.py +++ b/numpydoc/tests/test_docscrape.py @@ -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 ---------------- @@ -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') @@ -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'] @@ -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 ---------------- @@ -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