summaryrefslogtreecommitdiff
path: root/doc/sphinxext/numpydoc/tests/test_docscrape.py
diff options
context:
space:
mode:
authorRob Ruana <rob@relentlessidiot.com>2013-06-25 01:29:56 -0400
committerRob Ruana <rob@relentlessidiot.com>2013-06-25 01:29:56 -0400
commit2241e6c363da15403a45640382ffd4c6033f246b (patch)
tree481f0aa707443bf94410bcd38c43aed78315fa98 /doc/sphinxext/numpydoc/tests/test_docscrape.py
parent596795bf697b6be29e21c23d7680e2d476c23436 (diff)
downloadnumpy-2241e6c363da15403a45640382ffd4c6033f246b.tar.gz
ENH: Allow unnamed return values in Returns section of doc string
Developers usually only need the type of a return value followed by a brief description. However, in some cases providing a name for a return value can make the documentation clearer. This enhancement changes the format of the Returns section such that the type is required, and the name is optional: Returns ------- int Description of anonymous integer return value. x : str Description of string return value named `x`. With this change, if a colon is not present, then the entire line is interpreted as the return type. In all other cases, the Returns section is interpreted according to the current rules. Consistent with the current format, if a colon is present, then the text to the left of the colon is interpreted as the name; and the text to the right of the colon is interpreted as the type. This makes the proposed change backwards compatible with existing documentation.
Diffstat (limited to 'doc/sphinxext/numpydoc/tests/test_docscrape.py')
-rw-r--r--doc/sphinxext/numpydoc/tests/test_docscrape.py33
1 files changed, 25 insertions, 8 deletions
diff --git a/doc/sphinxext/numpydoc/tests/test_docscrape.py b/doc/sphinxext/numpydoc/tests/test_docscrape.py
index 7b7375a5a..b682504e1 100644
--- a/doc/sphinxext/numpydoc/tests/test_docscrape.py
+++ b/doc/sphinxext/numpydoc/tests/test_docscrape.py
@@ -47,6 +47,9 @@ doc_txt = '''\
In other words, each entry ``out[i,j,...,:]`` is an N-dimensional
value drawn from the distribution.
+ list of str
+ This is not a real return value. It exists to test
+ anonymous return values.
Other Parameters
----------------
@@ -148,13 +151,19 @@ def test_other_parameters():
assert desc[0].startswith('A parrot off its mortal coil')
def test_returns():
- assert_equal(len(doc['Returns']), 1)
+ assert_equal(len(doc['Returns']), 2)
arg, arg_type, desc = doc['Returns'][0]
assert_equal(arg, 'out')
assert_equal(arg_type, 'ndarray')
assert desc[0].startswith('The drawn samples')
assert desc[-1].endswith('distribution.')
+ arg, arg_type, desc = doc['Returns'][1]
+ assert_equal(arg, 'list of str')
+ assert_equal(arg_type, '')
+ assert desc[0].startswith('This is not a real')
+ assert desc[-1].endswith('anonymous return values.')
+
def test_notes():
assert doc['Notes'][0].startswith('Instead')
assert doc['Notes'][-1].endswith('definite.')
@@ -218,6 +227,9 @@ out : ndarray
In other words, each entry ``out[i,j,...,:]`` is an N-dimensional
value drawn from the distribution.
+list of str
+ This is not a real return value. It exists to test
+ anonymous return values.
Other Parameters
----------------
@@ -226,12 +238,12 @@ spam : parrot
Raises
------
-RuntimeError :
+RuntimeError
Some error
Warns
-----
-RuntimeWarning :
+RuntimeWarning
Some warning
Warnings
@@ -334,6 +346,11 @@ of the one-dimensional normal distribution to higher dimensions.
In other words, each entry ``out[i,j,...,:]`` is an N-dimensional
value drawn from the distribution.
+ list of str
+
+ This is not a real return value. It exists to test
+ anonymous return values.
+
:Other Parameters:
**spam** : parrot
@@ -342,13 +359,13 @@ of the one-dimensional normal distribution to higher dimensions.
:Raises:
- **RuntimeError** :
+ **RuntimeError**
Some error
:Warns:
- **RuntimeWarning** :
+ **RuntimeWarning**
Some warning
@@ -698,11 +715,11 @@ def test_class_members_doc():
Methods
-------
- a :
+ a
- b :
+ b
- c :
+ c
.. index::