Skip to content

Commit 2f075a6

Browse files
authored
Merge pull request #111 from jnothman/tilde
Allow see also object ref to incorporate ~ prefix
2 parents 3a6aa40 + 7238c06 commit 2f075a6

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
@@ -219,7 +219,8 @@ def _parse_param_list(self, content):
219219

220220
return params
221221

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

225226
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
@@ -687,21 +687,23 @@ def test_see_also():
687687
func_f, func_g, :meth:`func_h`, func_j,
688688
func_k
689689
:obj:`baz.obj_q`
690+
:obj:`~baz.obj_r`
690691
:class:`class_j`: fubar
691692
foobar
692693
""")
693694

694-
assert len(doc6['See Also']) == 12
695+
assert len(doc6['See Also']) == 13
695696
for func, desc, role in doc6['See Also']:
696697
if func in ('func_a', 'func_b', 'func_c', 'func_f',
697-
'func_g', 'func_h', 'func_j', 'func_k', 'baz.obj_q'):
698+
'func_g', 'func_h', 'func_j', 'func_k', 'baz.obj_q',
699+
'~baz.obj_r'):
698700
assert(not desc)
699701
else:
700702
assert(desc)
701703

702704
if func == 'func_h':
703705
assert role == 'meth'
704-
elif func == 'baz.obj_q':
706+
elif func == 'baz.obj_q' or func == '~baz.obj_r':
705707
assert role == 'obj'
706708
elif func == 'class_j':
707709
assert role == 'class'

0 commit comments

Comments
 (0)