Close #5560: napoleon_use_param also affect "other parameters" section

This commit is contained in:
Takeshi KOMIYA 2021-01-20 23:21:11 +09:00
parent 3ed7590ed4
commit 73db152cf6
3 changed files with 18 additions and 1 deletions

View File

@ -16,6 +16,8 @@ Incompatible changes
MathJax configuration may have to set the old MathJax path or update their MathJax configuration may have to set the old MathJax path or update their
configuration for version 3. See :mod:`sphinx.ext.mathjax`. configuration for version 3. See :mod:`sphinx.ext.mathjax`.
* #7784: i18n: The msgid for alt text of image is changed * #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 * #7996: manpage: Make a section directory on build manpage by default (see
:confval:`man_make_section_directory`) :confval:`man_make_section_directory`)
* #8380: html search: search results are wrapped with ``<p>`` instead of * #8380: html search: search results are wrapped with ``<p>`` instead of

View File

@ -682,7 +682,13 @@ class GoogleDocstring:
return self._parse_generic_section(_('Notes'), use_admonition) return self._parse_generic_section(_('Notes'), use_admonition)
def _parse_other_parameters_section(self, section: str) -> List[str]: 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]: def _parse_parameters_section(self, section: str) -> List[str]:
if self._config.napoleon_use_param: if self._config.napoleon_use_param:

View File

@ -1441,12 +1441,18 @@ Parameters
---------- ----------
param1 : :class:`MyClass <name.space.MyClass>` instance param1 : :class:`MyClass <name.space.MyClass>` instance
Other Parameters
----------------
param2 : :class:`MyClass <name.space.MyClass>` instance
""" """
config = Config(napoleon_use_param=False) config = Config(napoleon_use_param=False)
actual = str(NumpyDocstring(docstring, config)) actual = str(NumpyDocstring(docstring, config))
expected = """\ expected = """\
:Parameters: **param1** (:class:`MyClass <name.space.MyClass>` instance) :Parameters: **param1** (:class:`MyClass <name.space.MyClass>` instance)
:Other Parameters: **param2** (:class:`MyClass <name.space.MyClass>` instance)
""" """
self.assertEqual(expected, actual) self.assertEqual(expected, actual)
@ -1455,6 +1461,9 @@ param1 : :class:`MyClass <name.space.MyClass>` instance
expected = """\ expected = """\
:param param1: :param param1:
:type param1: :class:`MyClass <name.space.MyClass>` instance :type param1: :class:`MyClass <name.space.MyClass>` instance
:param param2:
:type param2: :class:`MyClass <name.space.MyClass>` instance
""" """
self.assertEqual(expected, actual) self.assertEqual(expected, actual)