diff --git a/numpydoc/docscrape.py b/numpydoc/docscrape.py index bfc2840e..7c8360ae 100644 --- a/numpydoc/docscrape.py +++ b/numpydoc/docscrape.py @@ -257,14 +257,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") @@ -300,12 +302,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 f10adc45..86a99a4e 100644 --- a/numpydoc/tests/test_docscrape.py +++ b/numpydoc/tests/test_docscrape.py @@ -110,6 +110,7 @@ some, other, funcs otherfunc : relationship :py:meth:`spyder.widgets.mixins.GetHelpMixin.show_object_info` + :py:meth:`int.bit_length ` Examples -------- @@ -451,6 +452,8 @@ def test_str(doc): relationship :py:meth:`spyder.widgets.mixins.GetHelpMixin.show_object_info` .. +:py:meth:`int.bit_length ` + .. Notes ----- @@ -642,6 +645,8 @@ def test_sphinx_str(): relationship :py:meth:`spyder.widgets.mixins.GetHelpMixin.show_object_info` .. + :py:meth:`int.bit_length ` + .. .. rubric:: Notes