From 9dbd723274f6ccae93fbd46300898f6adc6da99a Mon Sep 17 00:00:00 2001 From: tristanlatr Date: Fri, 29 Sep 2023 21:34:18 -0400 Subject: [PATCH] Mirror https://github.com/sphinx-doc/sphinx/issues/11246 --- pydoctor/napoleon/docstring.py | 6 ++++-- pydoctor/test/test_napoleon_docstring.py | 13 +++++++++---- setup.cfg | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/pydoctor/napoleon/docstring.py b/pydoctor/napoleon/docstring.py index 78e2c8fcb..0f4a79375 100644 --- a/pydoctor/napoleon/docstring.py +++ b/pydoctor/napoleon/docstring.py @@ -27,8 +27,10 @@ _numpy_section_regex = re.compile(r'^[=\-`:\'"~^_*+#<>]{2,}\s*$') _single_colon_regex = re.compile(r"(?`))') _xref_regex = re.compile(r"(?:(?::(?:[a-zA-Z0-9]+[\-_+:.])*[a-zA-Z0-9]+:)?`.+?`)") _bullet_list_regex = re.compile(r"^(\*|\+|\-)(\s+\S|\s*$)") _enumerated_list_regex = re.compile( diff --git a/pydoctor/test/test_napoleon_docstring.py b/pydoctor/test/test_napoleon_docstring.py index cf2d79a7f..63c900719 100644 --- a/pydoctor/test/test_napoleon_docstring.py +++ b/pydoctor/test/test_napoleon_docstring.py @@ -60,11 +60,11 @@ def assertAlmostEqualSphinxDocstring(self, expected: str, docstring: str, :param expected: The exact expected reST docstring generated by `pydoctor.napoleon` classes (trailling whitespaces ignored) """ expected_sphinx_output = re.sub( - r"(`|\\\s|\\|:mod:|:func:|:class:|:obj:)", "", expected) + r"(`|\\\s|\\|:mod:|:func:|:class:|:obj:|:py:mod:|:py:func:|:py:class:|:py:obj:)", "", expected) # mypy error: Cannot instantiate type "Type[SphinxGoogleDocstring?] sphinx_docstring_output = re.sub( - r"(`|\\|:mod:|:func:|:class:|:obj:|\s)", "", + r"(`|\\|:mod:|:func:|:class:|:obj:|:py:mod:|:py:func:|:py:class:|:py:obj:|\s)", "", str(type_(docstring)).replace( #type: ignore[misc] ":kwtype", ":type").replace(":vartype", ":type").replace(" -- ", " - ").replace(':rtype:', ':returntype:').rstrip()) @@ -351,10 +351,15 @@ def test_attribute_colon_description(self): self.assertEqual(expected.rstrip(), actual) def test_class_data_member_inline(self): - docstring = """b: data member description with :ref:`reference`""" + docstring = ("b: data member description with :ref:`reference` " + 'inline description with ' + '``a : in code``, ' + 'a :ref:`reference`, ' + 'a `link `_, ' + 'an host:port and HH:MM strings.') actual = str(GoogleDocstring(docstring, is_attribute=True)) expected = ("""\ -data member description with :ref:`reference` +data member description with :ref:`reference` inline description with ``a : in code``, a :ref:`reference`, a `link `_, an host:port and HH:MM strings. :type: `b`""") self.assertEqual(expected.rstrip(), actual) diff --git a/setup.cfg b/setup.cfg index 71ae2f469..bf7e8be33 100644 --- a/setup.cfg +++ b/setup.cfg @@ -68,7 +68,7 @@ test = hypothesis cython-test-exception-raiser bs4 - Sphinx<7.0.0 + Sphinx>=7.2.0 pytest-subtests [options.entry_points]