diff options
| author | Rob Ruana <rob@relentlessidiot.com> | 2014-03-09 01:56:56 -0500 |
|---|---|---|
| committer | Rob Ruana <rob@relentlessidiot.com> | 2014-03-09 01:56:56 -0500 |
| commit | 0deddff3813aefd50fb7d853584d0a9330bf063c (patch) | |
| tree | 3754ab9ab99a7abe59c27cabd563df3cf45752e5 /tests/test_napoleon_docstring.py | |
| parent | 151838e2749b57816cf29e8d2b9e8fcc665751c7 (diff) | |
| download | sphinx-0deddff3813aefd50fb7d853584d0a9330bf063c.tar.gz | |
Closes #1396: Param types with inline markup no longer italicized
Napoleon was attempting to render nested inline markup
( [a big no-no!](http://sphinx-doc.org/rest.html) ) for
parameter types. Now, if Napoleon sees any backquotes
in the parameter type, it is rendered without italics.
Diffstat (limited to 'tests/test_napoleon_docstring.py')
| -rw-r--r-- | tests/test_napoleon_docstring.py | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/tests/test_napoleon_docstring.py b/tests/test_napoleon_docstring.py index aa52aebe..7d5e3ad8 100644 --- a/tests/test_napoleon_docstring.py +++ b/tests/test_napoleon_docstring.py @@ -11,6 +11,7 @@ """ import textwrap +from sphinx.ext.napoleon import Config from sphinx.ext.napoleon.docstring import GoogleDocstring, NumpyDocstring from unittest import TestCase @@ -142,8 +143,9 @@ class GoogleDocstringTest(BaseDocstringTest): )] def test_docstrings(self): + config = Config(napoleon_use_param=False, napoleon_use_rtype=False) for docstring, expected in self.docstrings: - actual = str(GoogleDocstring(textwrap.dedent(docstring))) + actual = str(GoogleDocstring(textwrap.dedent(docstring), config)) expected = textwrap.dedent(expected) self.assertEqual(expected, actual) @@ -253,7 +255,54 @@ class NumpyDocstringTest(BaseDocstringTest): )] def test_docstrings(self): + config = Config(napoleon_use_param=False, napoleon_use_rtype=False) for docstring, expected in self.docstrings: - actual = str(NumpyDocstring(textwrap.dedent(docstring))) + actual = str(NumpyDocstring(textwrap.dedent(docstring), config)) expected = textwrap.dedent(expected) self.assertEqual(expected, actual) + + def test_parameters_with_class_reference(self): + docstring = """ + Parameters + ---------- + param1 : :class:`MyClass <name.space.MyClass>` instance + + """ + + config = Config(napoleon_use_param=False) + actual = str(NumpyDocstring(textwrap.dedent(docstring), config)) + expected = textwrap.dedent(""" + :Parameters: **param1** (:class:`MyClass <name.space.MyClass>` instance) + """) + self.assertEqual(expected, actual) + + config = Config(napoleon_use_param=True) + actual = str(NumpyDocstring(textwrap.dedent(docstring), config)) + expected = textwrap.dedent(""" + + :type param1: :class:`MyClass <name.space.MyClass>` instance + """) + self.assertEqual(expected, actual) + + def test_parameters_without_class_reference(self): + docstring = """ + Parameters + ---------- + param1 : MyClass instance + + """ + + config = Config(napoleon_use_param=False) + actual = str(NumpyDocstring(textwrap.dedent(docstring), config)) + expected = textwrap.dedent(""" + :Parameters: **param1** (*MyClass instance*) + """) + self.assertEqual(expected, actual) + + config = Config(napoleon_use_param=True) + actual = str(NumpyDocstring(textwrap.dedent(docstring), config)) + expected = textwrap.dedent(""" + + :type param1: MyClass instance + """) + self.assertEqual(expected, actual) |
