Skip to content

Commit ebfc07f

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 2ce9cd9 commit ebfc07f

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
@@ -484,15 +484,10 @@ def _str_see_also(self, func_role):
484484
last_had_desc = True
485485
else:
486486
last_had_desc = False
487-
out += ['']
487+
out += self._str_indent(['\u200B'])
488488
if last_had_desc:
489489
out += ['']
490490
out += ['']
491-
# if 1:
492-
# print()
493-
# for l in out:
494-
# print(repr(l))
495-
# # print(out)
496491
return out
497492

498493
def _str_index(self):

numpydoc/tests/test_docscrape.py

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

333333

334334
def line_by_line_compare(a, b):
335-
a = textwrap.dedent(a)
335+
a = textwrap.dedent(a).replace(u'\u200B', '')
336336
b = textwrap.dedent(b)
337337
a = [l.rstrip() for l in _strip_blank_lines(a).split('\n')]
338338
b = [l.rstrip() for l in _strip_blank_lines(b).split('\n')]
@@ -702,9 +702,8 @@ def test_see_also():
702702
foobar
703703
""")
704704

705-
assert len(doc6['See Also']) == 10, str([len(doc6['See Also'])])
705+
assert len(doc6['See Also']) == 10
706706
for funcs, desc in doc6['See Also']:
707-
print(funcs, desc)
708707
for func, role in funcs:
709708
if func in ('func_a', 'func_b', 'func_c', 'func_f',
710709
'func_g', 'func_h', 'func_j', 'func_k', 'baz.obj_q',
@@ -733,13 +732,9 @@ def test_see_also():
733732
assert desc == ['some other func over', 'multiple lines']
734733
elif func == 'class_j':
735734
assert desc == ['fubar', 'foobar']
736-
elif func == 'func_j2':
735+
elif func in ['func_f2', 'func_g2', 'func_h2', 'func_j2']:
737736
assert desc == ['description of multiple'], str([desc, ['description of multiple']])
738737

739-
# s = str(doc6)
740-
# print(repr(s))
741-
# assert 1 == 0
742-
743738

744739
def test_see_also_parse_error():
745740
text = (

0 commit comments

Comments
 (0)