mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Closes #1904: [Napoleon] parses restructuredtext references in fields/params BEFORE splitting on colon
This commit is contained in:
@@ -356,6 +356,22 @@ Returns:
|
||||
:returns: an example instance
|
||||
if available, None if not available.
|
||||
:rtype: :py:class:`~.module.submodule.SomeClass`
|
||||
"""
|
||||
actual = str(GoogleDocstring(docstring))
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_xrefs_in_return_type(self):
|
||||
docstring = """Example Function
|
||||
|
||||
Returns:
|
||||
:class:`numpy.ndarray`: A :math:`n \\times 2` array containing
|
||||
a bunch of math items
|
||||
"""
|
||||
expected = """Example Function
|
||||
|
||||
:returns: A :math:`n \\times 2` array containing
|
||||
a bunch of math items
|
||||
:rtype: :class:`numpy.ndarray`
|
||||
"""
|
||||
actual = str(GoogleDocstring(docstring))
|
||||
self.assertEqual(expected, actual)
|
||||
@@ -696,3 +712,25 @@ arg_ : type
|
||||
actual = str(NumpyDocstring(docstring, config, app, "class"))
|
||||
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_xrefs_in_return_type(self):
|
||||
docstring = """
|
||||
Example Function
|
||||
|
||||
Returns
|
||||
-------
|
||||
:class:`numpy.ndarray`
|
||||
A :math:`n \\times 2` array containing
|
||||
a bunch of math items
|
||||
"""
|
||||
expected = """
|
||||
Example Function
|
||||
|
||||
:returns: A :math:`n \\times 2` array containing
|
||||
a bunch of math items
|
||||
:rtype: :class:`numpy.ndarray`
|
||||
"""
|
||||
config = Config()
|
||||
app = mock.Mock()
|
||||
actual = str(NumpyDocstring(docstring, config, app, "method"))
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
Reference in New Issue
Block a user