From 2241e6c363da15403a45640382ffd4c6033f246b Mon Sep 17 00:00:00 2001 From: Rob Ruana Date: Tue, 25 Jun 2013 01:29:56 -0400 Subject: 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. --- doc/sphinxext/numpydoc/docscrape.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'doc/sphinxext/numpydoc/docscrape.py') diff --git a/doc/sphinxext/numpydoc/docscrape.py b/doc/sphinxext/numpydoc/docscrape.py index a36171855..4ee0f2e40 100644 --- a/doc/sphinxext/numpydoc/docscrape.py +++ b/doc/sphinxext/numpydoc/docscrape.py @@ -334,7 +334,10 @@ class NumpyDocString(object): if self[name]: out += self._str_header(name) for param,param_type,desc in self[name]: - out += ['%s : %s' % (param, param_type)] + if param_type: + out += ['%s : %s' % (param, param_type)] + else: + out += [param] out += self._str_indent(desc) out += [''] return out -- cgit v1.2.1