mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #7583 from eric-wieser/fix-napoleon
ext.napoleon: Emit type annotations at the start of `.. attribute::`
This commit is contained in:
@@ -168,11 +168,10 @@ class Config:
|
|||||||
**If False**::
|
**If False**::
|
||||||
|
|
||||||
.. attribute:: attr1
|
.. attribute:: attr1
|
||||||
|
:type: int
|
||||||
|
|
||||||
Description of `attr1`
|
Description of `attr1`
|
||||||
|
|
||||||
:type: int
|
|
||||||
|
|
||||||
napoleon_use_param : :obj:`bool` (Defaults to True)
|
napoleon_use_param : :obj:`bool` (Defaults to True)
|
||||||
True to use a ``:param:`` role for each function parameter. False to
|
True to use a ``:param:`` role for each function parameter. False to
|
||||||
use a single ``:parameters:`` role for all the parameters.
|
use a single ``:parameters:`` role for all the parameters.
|
||||||
|
|||||||
@@ -588,13 +588,12 @@ class GoogleDocstring:
|
|||||||
lines.append('.. attribute:: ' + _name)
|
lines.append('.. attribute:: ' + _name)
|
||||||
if self._opt and 'noindex' in self._opt:
|
if self._opt and 'noindex' in self._opt:
|
||||||
lines.append(' :noindex:')
|
lines.append(' :noindex:')
|
||||||
|
if _type:
|
||||||
|
lines.extend(self._indent([':type: %s' % _type], 3))
|
||||||
lines.append('')
|
lines.append('')
|
||||||
|
|
||||||
fields = self._format_field('', '', _desc)
|
fields = self._format_field('', '', _desc)
|
||||||
lines.extend(self._indent(fields, 3))
|
lines.extend(self._indent(fields, 3))
|
||||||
if _type:
|
|
||||||
lines.append('')
|
|
||||||
lines.extend(self._indent([':type: %s' % _type], 3))
|
|
||||||
lines.append('')
|
lines.append('')
|
||||||
if self._config.napoleon_use_ivar:
|
if self._config.napoleon_use_ivar:
|
||||||
lines.append('')
|
lines.append('')
|
||||||
|
|||||||
@@ -53,22 +53,19 @@ class NamedtupleSubclassTest(BaseDocstringTest):
|
|||||||
Sample namedtuple subclass
|
Sample namedtuple subclass
|
||||||
|
|
||||||
.. attribute:: attr1
|
.. attribute:: attr1
|
||||||
|
:type: Arbitrary type
|
||||||
|
|
||||||
Quick description of attr1
|
Quick description of attr1
|
||||||
|
|
||||||
:type: Arbitrary type
|
|
||||||
|
|
||||||
.. attribute:: attr2
|
.. attribute:: attr2
|
||||||
|
:type: Another arbitrary type
|
||||||
|
|
||||||
Quick description of attr2
|
Quick description of attr2
|
||||||
|
|
||||||
:type: Another arbitrary type
|
|
||||||
|
|
||||||
.. attribute:: attr3
|
.. attribute:: attr3
|
||||||
|
:type: Type
|
||||||
|
|
||||||
Adds a newline after the type
|
Adds a newline after the type
|
||||||
|
|
||||||
:type: Type
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.assertEqual(expected, actual)
|
self.assertEqual(expected, actual)
|
||||||
@@ -412,10 +409,9 @@ Attributes:
|
|||||||
actual = str(GoogleDocstring(docstring))
|
actual = str(GoogleDocstring(docstring))
|
||||||
expected = """\
|
expected = """\
|
||||||
.. attribute:: in_attr
|
.. attribute:: in_attr
|
||||||
|
:type: :class:`numpy.ndarray`
|
||||||
|
|
||||||
super-dooper attribute
|
super-dooper attribute
|
||||||
|
|
||||||
:type: :class:`numpy.ndarray`
|
|
||||||
"""
|
"""
|
||||||
self.assertEqual(expected, actual)
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
@@ -427,10 +423,9 @@ Attributes:
|
|||||||
actual = str(GoogleDocstring(docstring))
|
actual = str(GoogleDocstring(docstring))
|
||||||
expected = """\
|
expected = """\
|
||||||
.. attribute:: in_attr
|
.. attribute:: in_attr
|
||||||
|
:type: numpy.ndarray
|
||||||
|
|
||||||
super-dooper attribute
|
super-dooper attribute
|
||||||
|
|
||||||
:type: numpy.ndarray
|
|
||||||
"""
|
"""
|
||||||
self.assertEqual(expected, actual)
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user