mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #6240: napoleon: Attributes and Methods sections ignore :noindex: option
This commit is contained in:
parent
c75470f9b7
commit
89dd4bf438
1
CHANGES
1
CHANGES
@ -141,6 +141,7 @@ Bugs fixed
|
|||||||
* #2377: C, parse function pointers even in complex types.
|
* #2377: C, parse function pointers even in complex types.
|
||||||
* #7345: sphinx-build: Sphinx crashes if output directory exists as a file
|
* #7345: sphinx-build: Sphinx crashes if output directory exists as a file
|
||||||
* #7290: sphinx-build: Ignore bdb.BdbQuit when handling exceptions
|
* #7290: sphinx-build: Ignore bdb.BdbQuit when handling exceptions
|
||||||
|
* #6240: napoleon: Attributes and Methods sections ignore :noindex: option
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -583,7 +583,11 @@ class GoogleDocstring:
|
|||||||
if _type:
|
if _type:
|
||||||
lines.append(':vartype %s: %s' % (_name, _type))
|
lines.append(':vartype %s: %s' % (_name, _type))
|
||||||
else:
|
else:
|
||||||
lines.extend(['.. attribute:: ' + _name, ''])
|
lines.append('.. attribute:: ' + _name)
|
||||||
|
if self._opt and 'noindex' in self._opt:
|
||||||
|
lines.append(' :noindex:')
|
||||||
|
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:
|
if _type:
|
||||||
@ -641,6 +645,8 @@ class GoogleDocstring:
|
|||||||
lines = [] # type: List[str]
|
lines = [] # type: List[str]
|
||||||
for _name, _type, _desc in self._consume_fields(parse_type=False):
|
for _name, _type, _desc in self._consume_fields(parse_type=False):
|
||||||
lines.append('.. method:: %s' % _name)
|
lines.append('.. method:: %s' % _name)
|
||||||
|
if self._opt and 'noindex' in self._opt:
|
||||||
|
lines.append(' :noindex:')
|
||||||
if _desc:
|
if _desc:
|
||||||
lines.extend([''] + self._indent(_desc, 3))
|
lines.extend([''] + self._indent(_desc, 3))
|
||||||
lines.append('')
|
lines.append('')
|
||||||
|
@ -1020,6 +1020,34 @@ Sooper Warning:
|
|||||||
actual = str(GoogleDocstring(docstring, testConfig))
|
actual = str(GoogleDocstring(docstring, testConfig))
|
||||||
self.assertEqual(expected, actual)
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
|
def test_noindex(self):
|
||||||
|
docstring = """
|
||||||
|
Attributes:
|
||||||
|
arg
|
||||||
|
description
|
||||||
|
|
||||||
|
Methods:
|
||||||
|
func(i, j)
|
||||||
|
description
|
||||||
|
"""
|
||||||
|
|
||||||
|
expected = """
|
||||||
|
.. attribute:: arg
|
||||||
|
:noindex:
|
||||||
|
|
||||||
|
description
|
||||||
|
|
||||||
|
.. method:: func(i, j)
|
||||||
|
:noindex:
|
||||||
|
|
||||||
|
|
||||||
|
description
|
||||||
|
"""
|
||||||
|
config = Config()
|
||||||
|
actual = str(GoogleDocstring(docstring, config=config, app=None, what='module',
|
||||||
|
options={'noindex': True}))
|
||||||
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
|
|
||||||
class NumpyDocstringTest(BaseDocstringTest):
|
class NumpyDocstringTest(BaseDocstringTest):
|
||||||
docstrings = [(
|
docstrings = [(
|
||||||
|
Loading…
Reference in New Issue
Block a user