Skip to content

Commit a82926f

Browse files
Carreaularsoner
authored andcommitted
BUG: fix role regex.
Spyder sometime uses the full :py:meth: role, this make sure it is properly handled.
1 parent 4e7c5ad commit a82926f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

numpydoc/docscrape.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def _parse_param_list(self, content, single_element_is_type=False):
251251
# Examples: func_f1 :meth:`func_h1` :obj:`~baz.obj_r` :class:`class_j`
252252
# <DESC> is a string describing the function.
253253

254-
_role = r":(?P<role>\w+):"
254+
_role = r":(?P<role>(py:)?\w+):"
255255
_funcbacktick = r"`(?P<name>(?:~\w+\.)?[a-zA-Z0-9_\.-]+)`"
256256
_funcplain = r"(?P<name2>[a-zA-Z0-9_\.-]+)"
257257
_funcname = r"(" + _role + _funcbacktick + r"|" + _funcplain + r")"

numpydoc/tests/test_docscrape.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
--------
111111
some, other, funcs
112112
otherfunc : relationship
113+
:py:meth:`spyder.widgets.mixins.GetHelpMixin.show_object_info`
113114
114115
Examples
115116
--------
@@ -435,6 +436,8 @@ def test_str():
435436
..
436437
`otherfunc`_
437438
relationship
439+
:py:meth:`spyder.widgets.mixins.GetHelpMixin.show_object_info`
440+
..
438441
439442
Notes
440443
-----
@@ -602,6 +605,8 @@ def test_sphinx_str():
602605
..
603606
:obj:`otherfunc`
604607
relationship
608+
:py:meth:`spyder.widgets.mixins.GetHelpMixin.show_object_info`
609+
..
605610
606611
.. rubric:: Notes
607612

0 commit comments

Comments
 (0)