Skip to content

Commit bb11821

Browse files
committed
ENH: Use a zero-width space for empty definitions in See Also blocks.
Also remove the zero-width space \u200B when comparing test output.
1 parent 5ca74fe commit bb11821

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

numpydoc/docscrape.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -492,15 +492,10 @@ def _str_see_also(self, func_role):
492492
last_had_desc = True
493493
else:
494494
last_had_desc = False
495-
out += ['']
495+
out += self._str_indent(['\u200B'])
496496
if last_had_desc:
497497
out += ['']
498498
out += ['']
499-
# if 1:
500-
# print()
501-
# for l in out:
502-
# print(repr(l))
503-
# # print(out)
504499
return out
505500

506501
def _str_index(self):

numpydoc/tests/test_docscrape.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def _strip_blank_lines(s):
331331

332332

333333
def line_by_line_compare(a, b):
334-
a = textwrap.dedent(a)
334+
a = textwrap.dedent(a).replace(u'\u200B', '')
335335
b = textwrap.dedent(b)
336336
a = [l.rstrip() for l in _strip_blank_lines(a).split('\n')]
337337
b = [l.rstrip() for l in _strip_blank_lines(b).split('\n')]
@@ -717,9 +717,8 @@ def test_see_also():
717717
foobar
718718
""")
719719

720-
assert len(doc6['See Also']) == 10, str([len(doc6['See Also'])])
720+
assert len(doc6['See Also']) == 10
721721
for funcs, desc in doc6['See Also']:
722-
print(funcs, desc)
723722
for func, role in funcs:
724723
if func in ('func_a', 'func_b', 'func_c', 'func_f',
725724
'func_g', 'func_h', 'func_j', 'func_k', 'baz.obj_q',
@@ -748,13 +747,9 @@ def test_see_also():
748747
assert desc == ['some other func over', 'multiple lines']
749748
elif func == 'class_j':
750749
assert desc == ['fubar', 'foobar']
751-
elif func == 'func_j2':
750+
elif func in ['func_f2', 'func_g2', 'func_h2', 'func_j2']:
752751
assert desc == ['description of multiple'], str([desc, ['description of multiple']])
753752

754-
# s = str(doc6)
755-
# print(repr(s))
756-
# assert 1 == 0
757-
758753

759754
def test_see_also_parse_error():
760755
text = (

0 commit comments

Comments
 (0)