Skip to content

Commit 7238c06

Browse files
committed
Allow see also object ref to incorporate ~ prefix
Fixes #3
1 parent b215bed commit 7238c06

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

numpydoc/docscrape.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ def _parse_param_list(self, content):
213213

214214
return params
215215

216-
_name_rgx = re.compile(r"^\s*(:(?P<role>\w+):`(?P<name>[a-zA-Z0-9_.-]+)`|"
216+
_name_rgx = re.compile(r"^\s*(:(?P<role>\w+):"
217+
r"`(?P<name>(?:~\w+\.)?[a-zA-Z0-9_.-]+)`|"
217218
r" (?P<name2>[a-zA-Z0-9_.-]+))\s*", re.X)
218219

219220
def _parse_see_also(self, content):

numpydoc/tests/test_docscrape.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,21 +665,23 @@ def test_see_also():
665665
func_f, func_g, :meth:`func_h`, func_j,
666666
func_k
667667
:obj:`baz.obj_q`
668+
:obj:`~baz.obj_r`
668669
:class:`class_j`: fubar
669670
foobar
670671
""")
671672

672-
assert len(doc6['See Also']) == 12
673+
assert len(doc6['See Also']) == 13
673674
for func, desc, role in doc6['See Also']:
674675
if func in ('func_a', 'func_b', 'func_c', 'func_f',
675-
'func_g', 'func_h', 'func_j', 'func_k', 'baz.obj_q'):
676+
'func_g', 'func_h', 'func_j', 'func_k', 'baz.obj_q',
677+
'~baz.obj_r'):
676678
assert(not desc)
677679
else:
678680
assert(desc)
679681

680682
if func == 'func_h':
681683
assert role == 'meth'
682-
elif func == 'baz.obj_q':
684+
elif func == 'baz.obj_q' or func == '~baz.obj_r':
683685
assert role == 'obj'
684686
elif func == 'class_j':
685687
assert role == 'class'

0 commit comments

Comments
 (0)