mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #7734: napoleon: overescaped trailing underscore on attribute
This commit is contained in:
parent
d0779390d9
commit
a28c9ad842
1
CHANGES
1
CHANGES
@ -75,6 +75,7 @@ Features added
|
|||||||
:rst:dir:`py:exception:` and :rst:dir:`py:method:` directives
|
:rst:dir:`py:exception:` and :rst:dir:`py:method:` directives
|
||||||
* #7596: py domain: Change a type annotation for variables to a hyperlink
|
* #7596: py domain: Change a type annotation for variables to a hyperlink
|
||||||
* #7582: napoleon: a type for attribute are represented like type annotation
|
* #7582: napoleon: a type for attribute are represented like type annotation
|
||||||
|
* #7734: napoleon: overescaped trailing underscore on attribute
|
||||||
* #7683: Add ``allowed_exceptions`` parameter to ``Sphinx.emit()`` to allow
|
* #7683: Add ``allowed_exceptions`` parameter to ``Sphinx.emit()`` to allow
|
||||||
handlers to raise specified exceptions
|
handlers to raise specified exceptions
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ class GoogleDocstring:
|
|||||||
return [line[min_indent:] for line in lines]
|
return [line[min_indent:] for line in lines]
|
||||||
|
|
||||||
def _escape_args_and_kwargs(self, name: str) -> str:
|
def _escape_args_and_kwargs(self, name: str) -> str:
|
||||||
if name.endswith('_'):
|
if name.endswith('_') and getattr(self._config, 'strip_signature_backslash', False):
|
||||||
name = name[:-1] + r'\_'
|
name = name[:-1] + r'\_'
|
||||||
|
|
||||||
if name[:2] == '**':
|
if name[:2] == '**':
|
||||||
|
@ -1394,6 +1394,26 @@ Summary
|
|||||||
Attributes
|
Attributes
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
arg_ : type
|
||||||
|
some description
|
||||||
|
"""
|
||||||
|
|
||||||
|
expected = """
|
||||||
|
:ivar arg_: some description
|
||||||
|
:vartype arg_: type
|
||||||
|
"""
|
||||||
|
|
||||||
|
config = Config(napoleon_use_ivar=True)
|
||||||
|
app = mock.Mock()
|
||||||
|
actual = str(NumpyDocstring(docstring, config, app, "class"))
|
||||||
|
|
||||||
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
|
def test_underscore_in_attribute_strip_signature_backslash(self):
|
||||||
|
docstring = """
|
||||||
|
Attributes
|
||||||
|
----------
|
||||||
|
|
||||||
arg_ : type
|
arg_ : type
|
||||||
some description
|
some description
|
||||||
"""
|
"""
|
||||||
@ -1404,6 +1424,7 @@ arg_ : type
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
config = Config(napoleon_use_ivar=True)
|
config = Config(napoleon_use_ivar=True)
|
||||||
|
config.strip_signature_backslash = True
|
||||||
app = mock.Mock()
|
app = mock.Mock()
|
||||||
actual = str(NumpyDocstring(docstring, config, app, "class"))
|
actual = str(NumpyDocstring(docstring, config, app, "class"))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user