From b14439ca48713e92da29630ee067ea8c4331eb28 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 9 Jan 2020 00:15:27 +0900 Subject: [PATCH] Fix #6999: napoleon: fails to parse tilde in :exc: role --- CHANGES | 1 + sphinx/ext/napoleon/docstring.py | 4 ++-- tests/test_ext_napoleon_docstring.py | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index c72929a19c3..cd0e55aff62 100644 --- a/CHANGES +++ b/CHANGES @@ -45,6 +45,7 @@ Bugs fixed * #6961: latex: warning for babel shown twice * #6559: Wrong node-ids are generated in glossary directive * #6986: apidoc: misdetects module name for .so file inside module +* #6999: napoleon: fails to parse tilde in :exc: role Testing -------- diff --git a/sphinx/ext/napoleon/docstring.py b/sphinx/ext/napoleon/docstring.py index a06a79cea11..81f2496cb0c 100644 --- a/sphinx/ext/napoleon/docstring.py +++ b/sphinx/ext/napoleon/docstring.py @@ -101,8 +101,8 @@ class GoogleDocstring: """ - _name_rgx = re.compile(r"^\s*((?::(?P\S+):)?`(?P[a-zA-Z0-9_.-]+)`|" - r" (?P[a-zA-Z0-9_.-]+))\s*", re.X) + _name_rgx = re.compile(r"^\s*((?::(?P\S+):)?`(?P~?[a-zA-Z0-9_.-]+)`|" + r" (?P~?[a-zA-Z0-9_.-]+))\s*", re.X) def __init__(self, docstring: Union[str, List[str]], config: SphinxConfig = None, app: Sphinx = None, what: str = '', name: str = '', diff --git a/tests/test_ext_napoleon_docstring.py b/tests/test_ext_napoleon_docstring.py index 9547a9d2b06..2ce754eff8f 100644 --- a/tests/test_ext_napoleon_docstring.py +++ b/tests/test_ext_napoleon_docstring.py @@ -479,6 +479,8 @@ def test_raises_types(self): If the dimensions couldn't be parsed. `InvalidArgumentsError` If the arguments are invalid. + :exc:`~ValueError` + If the arguments are wrong. """, """ Example Function @@ -488,6 +490,7 @@ def test_raises_types(self): :raises AttributeError: errors for missing attributes. :raises ~InvalidDimensionsError: If the dimensions couldn't be parsed. :raises InvalidArgumentsError: If the arguments are invalid. +:raises ~ValueError: If the arguments are wrong. """), ################################ ("""