diff --git a/CHANGES b/CHANGES index c72929a19..cd0e55aff 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 a06a79cea..81f2496cb 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 9547a9d2b..2ce754eff 100644 --- a/tests/test_ext_napoleon_docstring.py +++ b/tests/test_ext_napoleon_docstring.py @@ -479,6 +479,8 @@ Raises: 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 @@ Example Function :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. """), ################################ ("""