mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Close #5560: napoleon_use_param also affect "other parameters" section
This commit is contained in:
parent
3ed7590ed4
commit
73db152cf6
2
CHANGES
2
CHANGES
@ -16,6 +16,8 @@ Incompatible changes
|
||||
MathJax configuration may have to set the old MathJax path or update their
|
||||
configuration for version 3. See :mod:`sphinx.ext.mathjax`.
|
||||
* #7784: i18n: The msgid for alt text of image is changed
|
||||
* #5560: napoleon: :confval:`napoleon_use_param` also affect "other parameters"
|
||||
section
|
||||
* #7996: manpage: Make a section directory on build manpage by default (see
|
||||
:confval:`man_make_section_directory`)
|
||||
* #8380: html search: search results are wrapped with ``<p>`` instead of
|
||||
|
@ -682,7 +682,13 @@ class GoogleDocstring:
|
||||
return self._parse_generic_section(_('Notes'), use_admonition)
|
||||
|
||||
def _parse_other_parameters_section(self, section: str) -> List[str]:
|
||||
return self._format_fields(_('Other Parameters'), self._consume_fields())
|
||||
if self._config.napoleon_use_param:
|
||||
# Allow to declare multiple parameters at once (ex: x, y: int)
|
||||
fields = self._consume_fields(multiple=True)
|
||||
return self._format_docutils_params(fields)
|
||||
else:
|
||||
fields = self._consume_fields()
|
||||
return self._format_fields(_('Other Parameters'), fields)
|
||||
|
||||
def _parse_parameters_section(self, section: str) -> List[str]:
|
||||
if self._config.napoleon_use_param:
|
||||
|
@ -1441,12 +1441,18 @@ Parameters
|
||||
----------
|
||||
param1 : :class:`MyClass <name.space.MyClass>` instance
|
||||
|
||||
Other Parameters
|
||||
----------------
|
||||
param2 : :class:`MyClass <name.space.MyClass>` instance
|
||||
|
||||
"""
|
||||
|
||||
config = Config(napoleon_use_param=False)
|
||||
actual = str(NumpyDocstring(docstring, config))
|
||||
expected = """\
|
||||
:Parameters: **param1** (:class:`MyClass <name.space.MyClass>` instance)
|
||||
|
||||
:Other Parameters: **param2** (:class:`MyClass <name.space.MyClass>` instance)
|
||||
"""
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
@ -1455,6 +1461,9 @@ param1 : :class:`MyClass <name.space.MyClass>` instance
|
||||
expected = """\
|
||||
:param param1:
|
||||
:type param1: :class:`MyClass <name.space.MyClass>` instance
|
||||
|
||||
:param param2:
|
||||
:type param2: :class:`MyClass <name.space.MyClass>` instance
|
||||
"""
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user