mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #7780: napoleon: multiple params declaration was wrongly recognized
So far, napoleon converts multiple paramaters declrarations to single paramaeter fields (`:param:` and `:type:`) unexpectedly. As a result, the output seems broken. This converts it to multiple parameter fields (a pair of field for each parameter declration) to build parameter successfully. Note: The conversion rule is available only when napoleon_use_params=True.
This commit is contained in:
@@ -1337,6 +1337,32 @@ param1 : :class:`MyClass <name.space.MyClass>` instance
|
||||
expected = """\
|
||||
:param param1:
|
||||
:type param1: :class:`MyClass <name.space.MyClass>` instance
|
||||
"""
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_multiple_parameters(self):
|
||||
docstring = """\
|
||||
Parameters
|
||||
----------
|
||||
x1, x2 : array_like
|
||||
Input arrays, description of ``x1``, ``x2``.
|
||||
|
||||
"""
|
||||
|
||||
config = Config(napoleon_use_param=False)
|
||||
actual = str(NumpyDocstring(docstring, config))
|
||||
expected = """\
|
||||
:Parameters: **x1, x2** (:class:`array_like`) -- Input arrays, description of ``x1``, ``x2``.
|
||||
"""
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
config = Config(napoleon_use_param=True)
|
||||
actual = str(NumpyDocstring(dedent(docstring), config))
|
||||
expected = """\
|
||||
:param x1: Input arrays, description of ``x1``, ``x2``.
|
||||
:type x1: :class:`array_like`
|
||||
:param x2: Input arrays, description of ``x1``, ``x2``.
|
||||
:type x2: :class:`array_like`
|
||||
"""
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user