From 1a865069dbc5f753684347d7fd33a2045806c4bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Gia=20Phong?= Date: Mon, 29 Jun 2020 16:15:49 +0700 Subject: [PATCH] napoleon: Add aliases Warn and Raise --- CHANGES | 1 + doc/usage/extensions/napoleon.rst | 2 ++ sphinx/ext/napoleon/docstring.py | 2 ++ 3 files changed, 5 insertions(+) diff --git a/CHANGES b/CHANGES index b0dc46b9a16..e6888146c73 100644 --- a/CHANGES +++ b/CHANGES @@ -14,6 +14,7 @@ Features added -------------- * #7853: C and C++, support parameterized GNU style attributes. +* #7888: napoleon: Add aliases Warn and Raise. Bugs fixed ---------- diff --git a/doc/usage/extensions/napoleon.rst b/doc/usage/extensions/napoleon.rst index b12dd03baf5..76c423dc0e8 100644 --- a/doc/usage/extensions/napoleon.rst +++ b/doc/usage/extensions/napoleon.rst @@ -115,6 +115,7 @@ All of the following section headers are supported: * ``Parameters`` * ``Return`` *(alias of Returns)* * ``Returns`` + * ``Raise`` *(alias of Raises)* * ``Raises`` * ``References`` * ``See Also`` @@ -122,6 +123,7 @@ All of the following section headers are supported: * ``Todo`` * ``Warning`` * ``Warnings`` *(alias of Warning)* + * ``Warn`` *(alias of Warns)* * ``Warns`` * ``Yield`` *(alias of Yields)* * ``Yields`` diff --git a/sphinx/ext/napoleon/docstring.py b/sphinx/ext/napoleon/docstring.py index 769d1ed2212..5857fcf92fb 100644 --- a/sphinx/ext/napoleon/docstring.py +++ b/sphinx/ext/napoleon/docstring.py @@ -162,6 +162,7 @@ def __init__(self, docstring: Union[str, List[str]], config: SphinxConfig = None 'parameters': self._parse_parameters_section, 'return': self._parse_returns_section, 'returns': self._parse_returns_section, + 'raise': self._parse_raises_section, 'raises': self._parse_raises_section, 'references': self._parse_references_section, 'see also': self._parse_see_also_section, @@ -169,6 +170,7 @@ def __init__(self, docstring: Union[str, List[str]], config: SphinxConfig = None 'todo': partial(self._parse_admonition, 'todo'), 'warning': partial(self._parse_admonition, 'warning'), 'warnings': partial(self._parse_admonition, 'warning'), + 'warn': self._parse_warns_section, 'warns': self._parse_warns_section, 'yield': self._parse_yields_section, 'yields': self._parse_yields_section,