Skip to content

Commit

Permalink
Merge pull request #6460 from tk0miya/6436_napoleon_unknown_target_name
Browse files Browse the repository at this point in the history
Fix #6436: napoleon: "Unknown target name" error
  • Loading branch information
tk0miya committed Jun 9, 2019
2 parents 783de00 + bc61713 commit 0b95f3f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Bugs fixed
* #6448: autodoc: crashed when autodocumenting classes with ``__slots__ = None``
* #6452: autosummary: crashed when generating document of properties
* #6455: napoleon: docstrings for properties are not processed
* #6436: napoleon: "Unknown target name" error if variable name ends with
underscore

Testing
--------
Expand Down
3 changes: 3 additions & 0 deletions sphinx/ext/napoleon/docstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ def _dedent(self, lines, full=False):

def _escape_args_and_kwargs(self, name):
# type: (str) -> str
if name.endswith('_'):
name = name[:-1] + r'\_'

if name[:2] == '**':
return r'\*\*' + name[2:]
elif name[:1] == '*':
Expand Down
4 changes: 2 additions & 2 deletions tests/test_ext_napoleon_docstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -1351,8 +1351,8 @@ def test_underscore_in_attribute(self):
"""

expected = """
:ivar arg_: some description
:vartype arg_: type
:ivar arg\\_: some description
:vartype arg\\_: type
"""

config = Config(napoleon_use_ivar=True)
Expand Down

0 comments on commit 0b95f3f

Please sign in to comment.