mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
move the return types and yield types tests to above the raises test
This commit is contained in:
parent
fa760c326a
commit
278a057104
@ -1443,6 +1443,51 @@ arg_ : type
|
|||||||
|
|
||||||
self.assertEqual(expected, actual)
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
|
def test_return_types(self):
|
||||||
|
docstring = dedent("""
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
DataFrame
|
||||||
|
a dataframe
|
||||||
|
""")
|
||||||
|
expected = dedent("""
|
||||||
|
:returns: a dataframe
|
||||||
|
:rtype: :class:`~pandas.DataFrame`
|
||||||
|
""")
|
||||||
|
translations = {
|
||||||
|
"DataFrame": "~pandas.DataFrame",
|
||||||
|
}
|
||||||
|
config = Config(
|
||||||
|
napoleon_use_param=True,
|
||||||
|
napoleon_use_rtype=True,
|
||||||
|
napoleon_type_aliases=translations,
|
||||||
|
)
|
||||||
|
actual = str(NumpyDocstring(docstring, config))
|
||||||
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
|
def test_yield_types(self):
|
||||||
|
docstring = dedent("""
|
||||||
|
Example Function
|
||||||
|
|
||||||
|
Yields
|
||||||
|
------
|
||||||
|
scalar or array-like
|
||||||
|
The result of the computation
|
||||||
|
""")
|
||||||
|
expected = dedent("""
|
||||||
|
Example Function
|
||||||
|
|
||||||
|
:Yields: :term:`scalar` or :class:`array-like <numpy.ndarray>` -- The result of the computation
|
||||||
|
""")
|
||||||
|
translations = {
|
||||||
|
"scalar": ":term:`scalar`",
|
||||||
|
"array-like": ":class:`array-like <numpy.ndarray>`",
|
||||||
|
}
|
||||||
|
config = Config(napoleon_type_aliases=translations)
|
||||||
|
app = mock.Mock()
|
||||||
|
actual = str(NumpyDocstring(docstring, config, app, "method"))
|
||||||
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
def test_raises_types(self):
|
def test_raises_types(self):
|
||||||
docstrings = [("""
|
docstrings = [("""
|
||||||
Example Function
|
Example Function
|
||||||
@ -1660,42 +1705,6 @@ Example Function
|
|||||||
actual = str(NumpyDocstring(docstring, config, app, "method"))
|
actual = str(NumpyDocstring(docstring, config, app, "method"))
|
||||||
self.assertEqual(expected, actual)
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
docstring = """
|
|
||||||
Example Function
|
|
||||||
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
ndarray
|
|
||||||
A :math:`n \\times 2` array containing
|
|
||||||
a bunch of math items
|
|
||||||
"""
|
|
||||||
config = Config(napoleon_type_aliases={"ndarray": ":class:`numpy.ndarray`"})
|
|
||||||
actual = str(NumpyDocstring(docstring, config, app, "method"))
|
|
||||||
self.assertEqual(expected, actual)
|
|
||||||
|
|
||||||
def test_yield_types(self):
|
|
||||||
docstring = dedent("""
|
|
||||||
Example Function
|
|
||||||
|
|
||||||
Yields
|
|
||||||
------
|
|
||||||
scalar or array-like
|
|
||||||
The result of the computation
|
|
||||||
""")
|
|
||||||
expected = dedent("""
|
|
||||||
Example Function
|
|
||||||
|
|
||||||
:Yields: :term:`scalar` or :class:`array-like <numpy.ndarray>` -- The result of the computation
|
|
||||||
""")
|
|
||||||
translations = {
|
|
||||||
"scalar": ":term:`scalar`",
|
|
||||||
"array-like": ":class:`array-like <numpy.ndarray>`",
|
|
||||||
}
|
|
||||||
config = Config(napoleon_type_aliases=translations)
|
|
||||||
app = mock.Mock()
|
|
||||||
actual = str(NumpyDocstring(docstring, config, app, "method"))
|
|
||||||
self.assertEqual(expected, actual)
|
|
||||||
|
|
||||||
def test_section_header_underline_length(self):
|
def test_section_header_underline_length(self):
|
||||||
docstrings = [("""
|
docstrings = [("""
|
||||||
Summary line
|
Summary line
|
||||||
|
Loading…
Reference in New Issue
Block a user