diff --git a/numpydoc/docscrape.py b/numpydoc/docscrape.py index 26a08259..81a0b0c2 100644 --- a/numpydoc/docscrape.py +++ b/numpydoc/docscrape.py @@ -256,14 +256,16 @@ def _parse_param_list(self, content, single_element_is_type=False): # is one of # # COLON COLON BACKTICK BACKTICK + # COLON COLON BACKTICK RIGHT_ANGLE_BRACKET LEFT_ANGLE_BRACKET BACKTICK # where + # is a legal sphinx target for cross-linking # is a legal function name, and # is any nonempty sequence of word characters. - # Examples: func_f1 :meth:`func_h1` :obj:`~baz.obj_r` :class:`class_j` + # Examples: func_f1 :meth:`func_h1` :obj:`~baz.obj_r` :class:`class_j` :class:`class_j ` # is a string describing the function. _role = r":(?P(py:)?\w+):" - _funcbacktick = r"`(?P(?:~\w+\.)?[a-zA-Z0-9_\.-]+)`" + _funcbacktick = r"`(?P(?:~\w+\.)?[a-zA-Z0-9_\.-]+)\s?(?P(?:\s?\<\w)[a-zA-Z0-9_\.-]+(?:\>))?`" _funcplain = r"(?P[a-zA-Z0-9_\.-]+)" _funcname = r"(" + _role + _funcbacktick + r"|" + _funcplain + r")" _funcnamenext = _funcname.replace("role", "rolenext") @@ -299,12 +301,16 @@ def _parse_see_also(self, content): items = [] def parse_item_name(text): - """Match ':role:`name`' or 'name'.""" + """Match ':role:`name`', ':role:`name `' or 'name'.""" m = self._func_rgx.match(text) if not m: self._error_location(f"Error parsing See Also entry {line!r}") role = m.group("role") name = m.group("name") if role else m.group("name2") + + target_name = m.group("target_name") + if target_name is not None: + name += f" {target_name}" return name, role, m.end() rest = [] diff --git a/numpydoc/tests/test_docscrape.py b/numpydoc/tests/test_docscrape.py index acf5194c..8a8e5e19 100644 --- a/numpydoc/tests/test_docscrape.py +++ b/numpydoc/tests/test_docscrape.py @@ -109,6 +109,7 @@ some, other, funcs otherfunc : relationship :py:meth:`spyder.widgets.mixins.GetHelpMixin.show_object_info` + :py:meth:`int.bit_length ` Examples -------- @@ -456,6 +457,8 @@ def test_str(doc): relationship :py:meth:`spyder.widgets.mixins.GetHelpMixin.show_object_info` .. +:py:meth:`int.bit_length ` + .. Notes ----- @@ -647,6 +650,8 @@ def test_sphinx_str(): relationship :py:meth:`spyder.widgets.mixins.GetHelpMixin.show_object_info` .. + :py:meth:`int.bit_length ` + .. .. rubric:: Notes