Skip to content

Commit

Permalink
Fix sphinx-doc#6999: napoleon: fails to parse tilde in :exc: role
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Jan 8, 2020
1 parent ae8fc43 commit b14439c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -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
--------
Expand Down
4 changes: 2 additions & 2 deletions sphinx/ext/napoleon/docstring.py
Expand Up @@ -101,8 +101,8 @@ class GoogleDocstring:
"""

_name_rgx = re.compile(r"^\s*((?::(?P<role>\S+):)?`(?P<name>[a-zA-Z0-9_.-]+)`|"
r" (?P<name2>[a-zA-Z0-9_.-]+))\s*", re.X)
_name_rgx = re.compile(r"^\s*((?::(?P<role>\S+):)?`(?P<name>~?[a-zA-Z0-9_.-]+)`|"
r" (?P<name2>~?[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 = '',
Expand Down
3 changes: 3 additions & 0 deletions tests/test_ext_napoleon_docstring.py
Expand Up @@ -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
Expand All @@ -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.
"""),
################################
("""
Expand Down

0 comments on commit b14439c

Please sign in to comment.