diff options
author | Rob Ruana <rob@relentlessidiot.com> | 2014-06-13 14:06:39 -0600 |
---|---|---|
committer | Rob Ruana <rob@relentlessidiot.com> | 2014-06-13 14:06:39 -0600 |
commit | 7229a9361cc9493c4047743e7c30c261a7639c1f (patch) | |
tree | 6c3e418d8627bccce9856b0ad08d0d2b2407e42d | |
parent | f8fdce88db304862e1c33f04ad9e8cf61b0981ef (diff) | |
download | sphinx-7229a9361cc9493c4047743e7c30c261a7639c1f.tar.gz |
Closes #1489: Removes use of ":annotation:" for attribute types in napoleon, as inline markup is not allowed
-rw-r--r-- | doc/ext/napoleon.rst | 3 | ||||
-rw-r--r-- | sphinx/ext/napoleon/__init__.py | 3 | ||||
-rw-r--r-- | sphinx/ext/napoleon/docstring.py | 6 | ||||
-rw-r--r-- | tests/test_napoleon_docstring.py | 31 |
4 files changed, 40 insertions, 3 deletions
diff --git a/doc/ext/napoleon.rst b/doc/ext/napoleon.rst index 7248e491..26d494db 100644 --- a/doc/ext/napoleon.rst +++ b/doc/ext/napoleon.rst @@ -324,7 +324,8 @@ enabled in `conf.py`:: **If False**:: .. attribute:: attr1 - :annotation: int + + *int* Description of `attr1` diff --git a/sphinx/ext/napoleon/__init__.py b/sphinx/ext/napoleon/__init__.py index b67ea79c..655a07a0 100644 --- a/sphinx/ext/napoleon/__init__.py +++ b/sphinx/ext/napoleon/__init__.py @@ -151,7 +151,8 @@ class Config(object): **If False**:: .. attribute:: attr1 - :annotation: int + + *int* Description of `attr1` diff --git a/sphinx/ext/napoleon/docstring.py b/sphinx/ext/napoleon/docstring.py index 1a8d88c6..19f5f395 100644 --- a/sphinx/ext/napoleon/docstring.py +++ b/sphinx/ext/napoleon/docstring.py @@ -428,7 +428,11 @@ class GoogleDocstring(UnicodeMixin): else: lines.append('.. attribute:: ' + _name) if _type: - lines.append(' :annotation: ' + _type) + lines.append('') + if '`' in _type: + lines.append(' %s' % _type) + else: + lines.append(' *%s*' % _type) if _desc: lines.extend([''] + self._indent(_desc, 3)) lines.append('') diff --git a/tests/test_napoleon_docstring.py b/tests/test_napoleon_docstring.py index 34ba4e41..b731072a 100644 --- a/tests/test_napoleon_docstring.py +++ b/tests/test_napoleon_docstring.py @@ -205,6 +205,37 @@ This class should only be used by runtimes. """ 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): docstrings = [( |