Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sphinx 2.0: napoleon extension fails to parse exception with tilde #6220

Closed
RazerM opened this issue Mar 29, 2019 · 5 comments
Closed

Sphinx 2.0: napoleon extension fails to parse exception with tilde #6220

RazerM opened this issue Mar 29, 2019 · 5 comments

Comments

@RazerM
Copy link
Contributor

RazerM commented Mar 29, 2019

Describe the bug
Using the napoleon extension with napoleon_numpy_docstring = False, an exception with a tilde in front fails to parse.

I have a docstring

"""
    Raises:
        ValueError: description.
        ~mymodule.MyError: description.
"""

This regex fails:

_name_rgx = re.compile(r"^\s*(:(?P<role>\w+):`(?P<name>[a-zA-Z0-9_.-]+)`|"
r" (?P<name2>[a-zA-Z0-9_.-]+))\s*", re.X)

at this line:

m = self._name_rgx.match(_type).groupdict()

To Reproduce

from sphinx.ext.napoleon.docstring import GoogleDocstring
assert GoogleDocstring._name_rgx.match('~mymodule.MyError') is None

Expected behavior
Sphinx renders it as if I used :raises ~mymodule.MyError: description.

Environment info

  • Sphinx version: 2.0.0
  • Sphinx extensions: sphinx.ext.napoleon

Additional context
Bug introduced by #4046

@gmc444-b
Copy link

I found a similar error when parsing a section where the exception was enclosed in backquotes, ie:

    Raises:
        `SomeError`

@RobRuana
Copy link
Contributor

@tk0miya I must apologize. I no longer have the time to maintain Napoleon. I probably should have said something sooner.

@tk0miya
Copy link
Member

tk0miya commented Mar 31, 2019

@RobRuana Don't mind. I'll try to maintain it. Thank you for letting me know

@tk0miya
Copy link
Member

tk0miya commented Mar 31, 2019

I just posted #6237 to resolve this :-)

tk0miya added a commit to tk0miya/sphinx that referenced this issue Mar 31, 2019
…sed for raised section having references
tk0miya added a commit that referenced this issue Apr 4, 2019
Fix #6220, #6225: napoleon: AttributeError is raised for raised section having references
@tk0miya
Copy link
Member

tk0miya commented Apr 4, 2019

Fixed by #6237.
Thank you for reporting!

@tk0miya tk0miya closed this as completed Apr 4, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants