mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #7827 from tk0miya/7808_napoleon_nitpicky_warning
Revert "ext.napoleon: Emit type annotations at the start of `.. attribute::`"
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -7,6 +7,8 @@ Dependencies
|
||||
Incompatible changes
|
||||
--------------------
|
||||
|
||||
* #7808: napoleon: a type for attribute are represented as typed field
|
||||
|
||||
Deprecated
|
||||
----------
|
||||
|
||||
@@ -21,6 +23,7 @@ Bugs fixed
|
||||
* #7821: autodoc: TypeError is raised for overloaded C-ext function
|
||||
* #7812: autosummary: generates broken stub files if the target code contains
|
||||
an attribute and module that are same name
|
||||
* #7808: napoleon: Warnings raised on variable and attribute type annotations
|
||||
* #7811: sphinx.util.inspect causes circular import problem
|
||||
|
||||
Testing
|
||||
|
||||
@@ -168,10 +168,11 @@ class Config:
|
||||
**If False**::
|
||||
|
||||
.. attribute:: attr1
|
||||
:type: int
|
||||
|
||||
Description of `attr1`
|
||||
|
||||
:type: int
|
||||
|
||||
napoleon_use_param : :obj:`bool` (Defaults to True)
|
||||
True to use a ``:param:`` role for each function parameter. False to
|
||||
use a single ``:parameters:`` role for all the parameters.
|
||||
|
||||
@@ -588,12 +588,13 @@ class GoogleDocstring:
|
||||
lines.append('.. attribute:: ' + _name)
|
||||
if self._opt and 'noindex' in self._opt:
|
||||
lines.append(' :noindex:')
|
||||
if _type:
|
||||
lines.extend(self._indent([':type: %s' % _type], 3))
|
||||
lines.append('')
|
||||
|
||||
fields = self._format_field('', '', _desc)
|
||||
lines.extend(self._indent(fields, 3))
|
||||
if _type:
|
||||
lines.append('')
|
||||
lines.extend(self._indent([':type: %s' % _type], 3))
|
||||
lines.append('')
|
||||
if self._config.napoleon_use_ivar:
|
||||
lines.append('')
|
||||
|
||||
@@ -53,19 +53,22 @@ class NamedtupleSubclassTest(BaseDocstringTest):
|
||||
Sample namedtuple subclass
|
||||
|
||||
.. attribute:: attr1
|
||||
:type: Arbitrary type
|
||||
|
||||
Quick description of attr1
|
||||
|
||||
:type: Arbitrary type
|
||||
|
||||
.. attribute:: attr2
|
||||
:type: Another arbitrary type
|
||||
|
||||
Quick description of attr2
|
||||
|
||||
:type: Another arbitrary type
|
||||
|
||||
.. attribute:: attr3
|
||||
:type: Type
|
||||
|
||||
Adds a newline after the type
|
||||
|
||||
:type: Type
|
||||
"""
|
||||
|
||||
self.assertEqual(expected, actual)
|
||||
@@ -409,9 +412,10 @@ Attributes:
|
||||
actual = str(GoogleDocstring(docstring))
|
||||
expected = """\
|
||||
.. attribute:: in_attr
|
||||
:type: :class:`numpy.ndarray`
|
||||
|
||||
super-dooper attribute
|
||||
|
||||
:type: :class:`numpy.ndarray`
|
||||
"""
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
@@ -423,9 +427,10 @@ Attributes:
|
||||
actual = str(GoogleDocstring(docstring))
|
||||
expected = """\
|
||||
.. attribute:: in_attr
|
||||
:type: numpy.ndarray
|
||||
|
||||
super-dooper attribute
|
||||
|
||||
:type: numpy.ndarray
|
||||
"""
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user