ext.napoleon: Do not consume colons within inline code

Fixes gh-7581
This commit is contained in:
Eric Wieser
2020-04-30 08:57:24 +01:00
parent 21ca43719a
commit 453fe55dc9
2 changed files with 33 additions and 9 deletions

View File

@@ -78,15 +78,17 @@ class InlineAttributeTest(BaseDocstringTest):
def test_class_data_member(self):
config = Config()
docstring = """data member description:
docstring = dedent("""\
data member description:
- a: b
"""
- a: b
""")
actual = str(GoogleDocstring(docstring, config=config, app=None,
what='attribute', name='some_data', obj=0))
expected = """data member description:
expected = dedent("""\
data member description:
- a: b"""
- a: b""")
self.assertEqual(expected, actual)
@@ -95,10 +97,30 @@ class InlineAttributeTest(BaseDocstringTest):
docstring = """b: data member description with :ref:`reference`"""
actual = str(GoogleDocstring(docstring, config=config, app=None,
what='attribute', name='some_data', obj=0))
expected = """data member description with :ref:`reference`
expected = dedent("""\
data member description with :ref:`reference`
:type: b"""
:type: b""")
self.assertEqual(expected, actual)
def test_class_data_member_inline_no_type(self):
config = Config()
docstring = """data with ``a : in code`` and :ref:`reference` and no type"""
actual = str(GoogleDocstring(docstring, config=config, app=None,
what='attribute', name='some_data', obj=0))
expected = """data with ``a : in code`` and :ref:`reference` and no type"""
self.assertEqual(expected, actual)
def test_class_data_member_inline_ref_in_type(self):
config = Config()
docstring = """:class:`int`: data member description"""
actual = str(GoogleDocstring(docstring, config=config, app=None,
what='attribute', name='some_data', obj=0))
expected = dedent("""\
data member description
:type: :class:`int`""")
self.assertEqual(expected, actual)