Closes #1489: Removes use of ":annotation:" for attribute types in napoleon, as inline markup is not allowed

This commit is contained in:
Rob Ruana 2014-06-13 14:06:39 -06:00
parent fb2c15eaa7
commit 71b8fe8854
4 changed files with 40 additions and 3 deletions

View File

@ -324,7 +324,8 @@ enabled in `conf.py`::
**If False**:: **If False**::
.. attribute:: attr1 .. attribute:: attr1
:annotation: int
*int*
Description of `attr1` Description of `attr1`

View File

@ -151,7 +151,8 @@ class Config(object):
**If False**:: **If False**::
.. attribute:: attr1 .. attribute:: attr1
:annotation: int
*int*
Description of `attr1` Description of `attr1`

View File

@ -428,7 +428,11 @@ class GoogleDocstring(UnicodeMixin):
else: else:
lines.append('.. attribute:: ' + _name) lines.append('.. attribute:: ' + _name)
if _type: if _type:
lines.append(' :annotation: ' + _type) lines.append('')
if '`' in _type:
lines.append(' %s' % _type)
else:
lines.append(' *%s*' % _type)
if _desc: if _desc:
lines.extend([''] + self._indent(_desc, 3)) lines.extend([''] + self._indent(_desc, 3))
lines.append('') lines.append('')

View File

@ -205,6 +205,37 @@ This class should only be used by runtimes.
""" """
self.assertEqual(expected, actual) self.assertEqual(expected, actual)
def test_attributes_with_class_reference(self):
docstring = """\
Attributes:
in_attr(:class:`numpy.ndarray`): super-dooper attribute
"""
actual = str(GoogleDocstring(docstring))
expected = """\
.. attribute:: in_attr
:class:`numpy.ndarray`
super-dooper attribute
"""
self.assertEqual(expected, actual)
docstring = """\
Attributes:
in_attr(numpy.ndarray): super-dooper attribute
"""
actual = str(GoogleDocstring(docstring))
expected = """\
.. attribute:: in_attr
*numpy.ndarray*
super-dooper attribute
"""
self.assertEqual(expected, actual)
class NumpyDocstringTest(BaseDocstringTest): class NumpyDocstringTest(BaseDocstringTest):
docstrings = [( docstrings = [(