mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #8552 from tk0miya/8236_napoleon_receives_section
Close #8236: napoleon: Support numpydoc's "Receives" section
This commit is contained in:
commit
6e8ea8572f
1
CHANGES
1
CHANGES
@ -44,6 +44,7 @@ Features added
|
|||||||
* #8460: autodoc: Support custom types defined by typing.NewType
|
* #8460: autodoc: Support custom types defined by typing.NewType
|
||||||
* #8285: napoleon: Add :confval:`napoleon_attr_annotations` to merge type hints
|
* #8285: napoleon: Add :confval:`napoleon_attr_annotations` to merge type hints
|
||||||
on source code automatically if any type is specified in docstring
|
on source code automatically if any type is specified in docstring
|
||||||
|
* #8236: napoleon: Support numpydoc's "Receives" section
|
||||||
* #6914: Add a new event :event:`warn-missing-reference` to custom warning
|
* #6914: Add a new event :event:`warn-missing-reference` to custom warning
|
||||||
messages when failed to resolve a cross-reference
|
messages when failed to resolve a cross-reference
|
||||||
* #6914: Emit a detailed warning when failed to resolve a ``:ref:`` reference
|
* #6914: Emit a detailed warning when failed to resolve a ``:ref:`` reference
|
||||||
|
@ -179,6 +179,8 @@ class GoogleDocstring:
|
|||||||
'notes': self._parse_notes_section,
|
'notes': self._parse_notes_section,
|
||||||
'other parameters': self._parse_other_parameters_section,
|
'other parameters': self._parse_other_parameters_section,
|
||||||
'parameters': self._parse_parameters_section,
|
'parameters': self._parse_parameters_section,
|
||||||
|
'receive': self._parse_receives_section,
|
||||||
|
'receives': self._parse_receives_section,
|
||||||
'return': self._parse_returns_section,
|
'return': self._parse_returns_section,
|
||||||
'returns': self._parse_returns_section,
|
'returns': self._parse_returns_section,
|
||||||
'raise': self._parse_raises_section,
|
'raise': self._parse_raises_section,
|
||||||
@ -714,6 +716,15 @@ class GoogleDocstring:
|
|||||||
lines.append('')
|
lines.append('')
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
|
def _parse_receives_section(self, section: str) -> List[str]:
|
||||||
|
if self._config.napoleon_use_param:
|
||||||
|
# Allow to declare multiple parameters at once (ex: x, y: int)
|
||||||
|
fields = self._consume_fields(multiple=True)
|
||||||
|
return self._format_docutils_params(fields)
|
||||||
|
else:
|
||||||
|
fields = self._consume_fields()
|
||||||
|
return self._format_fields(_('Receives'), fields)
|
||||||
|
|
||||||
def _parse_references_section(self, section: str) -> List[str]:
|
def _parse_references_section(self, section: str) -> List[str]:
|
||||||
use_admonition = self._config.napoleon_use_admonition_for_references
|
use_admonition = self._config.napoleon_use_admonition_for_references
|
||||||
return self._parse_generic_section(_('References'), use_admonition)
|
return self._parse_generic_section(_('References'), use_admonition)
|
||||||
|
@ -303,6 +303,34 @@ class GoogleDocstringTest(BaseDocstringTest):
|
|||||||
"""
|
"""
|
||||||
Single line summary
|
Single line summary
|
||||||
|
|
||||||
|
Receive:
|
||||||
|
arg1 (list(int)): Description
|
||||||
|
arg2 (list[int]): Description
|
||||||
|
""",
|
||||||
|
"""
|
||||||
|
Single line summary
|
||||||
|
|
||||||
|
:Receives: * **arg1** (*list(int)*) -- Description
|
||||||
|
* **arg2** (*list[int]*) -- Description
|
||||||
|
"""
|
||||||
|
), (
|
||||||
|
"""
|
||||||
|
Single line summary
|
||||||
|
|
||||||
|
Receives:
|
||||||
|
arg1 (list(int)): Description
|
||||||
|
arg2 (list[int]): Description
|
||||||
|
""",
|
||||||
|
"""
|
||||||
|
Single line summary
|
||||||
|
|
||||||
|
:Receives: * **arg1** (*list(int)*) -- Description
|
||||||
|
* **arg2** (*list[int]*) -- Description
|
||||||
|
"""
|
||||||
|
), (
|
||||||
|
"""
|
||||||
|
Single line summary
|
||||||
|
|
||||||
Yield:
|
Yield:
|
||||||
str:Extended
|
str:Extended
|
||||||
description of yielded value
|
description of yielded value
|
||||||
@ -1263,6 +1291,48 @@ class NumpyDocstringTest(BaseDocstringTest):
|
|||||||
"""
|
"""
|
||||||
Single line summary
|
Single line summary
|
||||||
|
|
||||||
|
Receive
|
||||||
|
-------
|
||||||
|
arg1:str
|
||||||
|
Extended
|
||||||
|
description of arg1
|
||||||
|
arg2 : int
|
||||||
|
Extended
|
||||||
|
description of arg2
|
||||||
|
""",
|
||||||
|
"""
|
||||||
|
Single line summary
|
||||||
|
|
||||||
|
:Receives: * **arg1** (:class:`str`) -- Extended
|
||||||
|
description of arg1
|
||||||
|
* **arg2** (:class:`int`) -- Extended
|
||||||
|
description of arg2
|
||||||
|
"""
|
||||||
|
), (
|
||||||
|
"""
|
||||||
|
Single line summary
|
||||||
|
|
||||||
|
Receives
|
||||||
|
--------
|
||||||
|
arg1:str
|
||||||
|
Extended
|
||||||
|
description of arg1
|
||||||
|
arg2 : int
|
||||||
|
Extended
|
||||||
|
description of arg2
|
||||||
|
""",
|
||||||
|
"""
|
||||||
|
Single line summary
|
||||||
|
|
||||||
|
:Receives: * **arg1** (:class:`str`) -- Extended
|
||||||
|
description of arg1
|
||||||
|
* **arg2** (:class:`int`) -- Extended
|
||||||
|
description of arg2
|
||||||
|
"""
|
||||||
|
), (
|
||||||
|
"""
|
||||||
|
Single line summary
|
||||||
|
|
||||||
Yield
|
Yield
|
||||||
-----
|
-----
|
||||||
str
|
str
|
||||||
|
Loading…
Reference in New Issue
Block a user