summaryrefslogtreecommitdiff
path: root/tests/test_ext_napoleon_docstring.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-08-06 02:07:11 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-08-07 23:46:55 +0900
commita4996f905471c37303748f543ded7e047b9fa7a4 (patch)
treec027ed98364fb5d58fcc719b2282208c249771e5 /tests/test_ext_napoleon_docstring.py
parent99e65a59be8627b0e06786e082fae3d53b2340d0 (diff)
downloadsphinx-git-a4996f905471c37303748f543ded7e047b9fa7a4.tar.gz
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.
Diffstat (limited to 'tests/test_ext_napoleon_docstring.py')
-rw-r--r--tests/test_ext_napoleon_docstring.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test_ext_napoleon_docstring.py b/tests/test_ext_napoleon_docstring.py
index 2f1e559b3..7eb908058 100644
--- a/tests/test_ext_napoleon_docstring.py
+++ b/tests/test_ext_napoleon_docstring.py
@@ -1340,6 +1340,32 @@ 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)
+
def test_parameters_without_class_reference(self):
docstring = """\
Parameters