Skip to content

Commit

Permalink
Merge branch 'master' into 295-184-reparenting-rework
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlatr authored Oct 15, 2023
2 parents a70b8b2 + 922f81e commit f00cda1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
6 changes: 4 additions & 2 deletions pydoctor/napoleon/docstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
_numpy_section_regex = re.compile(r'^[=\-`:\'"~^_*+#<>]{2,}\s*$')
_single_colon_regex = re.compile(r"(?<!:):(?!:)")
_xref_or_code_regex = re.compile(
r"((?::(?:[a-zA-Z0-9]+[\-_+:.])*[a-zA-Z0-9]+:`.+?`)|" r"(?:``.+?``))"
)
r'((?::(?:[a-zA-Z0-9]+[\-_+:.])*[a-zA-Z0-9]+:`.+?`)|'
r'(?:``.+?``)|'
# r'(?::meta .+:.*)|' # 'meta' is not a supported field by pydoctor at the moment.
r'(?:`.+?\s*(?<!\x00)<.*?>`))')
_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(
Expand Down
13 changes: 9 additions & 4 deletions pydoctor/test/test_napoleon_docstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<Ellipsis>)", "",
r"(`|\\|:mod:|:func:|:class:|:obj:|:py:mod:|:py:func:|:py:class:|:py:obj:|\s<Ellipsis>)", "",
str(type_(docstring)).replace( #type: ignore[misc]
":kwtype", ":type").replace(":vartype", ":type").replace(" -- ", " - ").replace(':rtype:', ':returntype:').rstrip())

Expand Down Expand Up @@ -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 <https://foo.bar>`_, '
'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 <https://foo.bar>`_, an host:port and HH:MM strings.
:type: `b`""")
self.assertEqual(expected.rstrip(), actual)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ test =
hypothesis
cython-test-exception-raiser
bs4
Sphinx<7.0.0
Sphinx
pytest-subtests

[options.entry_points]
Expand Down

0 comments on commit f00cda1

Please sign in to comment.