Skip to content

Commit 1670bbb

Browse files
committed
BUG: Replace Unicode zero-width-space with ".."
1 parent 30ec43d commit 1670bbb

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

numpydoc/docscrape.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,7 @@ def _parse_param_list(self, content):
258258
r"`(?P<name>(?:~\w+\.)?[a-zA-Z0-9_.-]+)`|"
259259
r" (?P<name2>[a-zA-Z0-9_.-]+))\s*", re.X)
260260

261-
if sys.version_info[0] >= 3:
262-
zerowidthspace = '\u200B'
263-
else:
264-
zerowidthspace = '\xE2\x80\x8B'
261+
empty_description = '..'
265262

266263
def _parse_see_also(self, content):
267264
"""
@@ -497,7 +494,7 @@ def _str_see_also(self, func_role):
497494
last_had_desc = True
498495
else:
499496
last_had_desc = False
500-
out += self._str_indent([self.zerowidthspace])
497+
out += self._str_indent([self.empty_description])
501498

502499
if last_had_desc:
503500
out += ['']

numpydoc/tests/test_docscrape.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -331,18 +331,15 @@ def _strip_blank_lines(s):
331331

332332

333333
def line_by_line_compare(a, b):
334-
if sys.version_info.major >= 3:
335-
zerowidthspace = '\u200B'
336-
else:
337-
zerowidthspace = '\xE2\x80\x8B'
334+
empty_description = '..'
335+
rgx = re.compile(r"^\s+" + re.escape(empty_description) + "$")
338336

339-
a = textwrap.dedent(a).replace(zerowidthspace, '')
337+
a = textwrap.dedent(a)
340338
b = textwrap.dedent(b)
341-
a = [l.rstrip() for l in _strip_blank_lines(a).split('\n')]
342-
b = [l.rstrip() for l in _strip_blank_lines(b).split('\n')]
339+
a = [rgx.sub('', l.rstrip()) for l in _strip_blank_lines(a).split('\n')]
340+
b = [rgx.sub('', l.rstrip()) for l in _strip_blank_lines(b).split('\n')]
343341
assert all(x == y for x, y in zip(a, b))
344342

345-
346343
def test_str():
347344
# doc_txt has the order of Notes and See Also sections flipped.
348345
# This should be handled automatically, and so, one thing this test does

0 commit comments

Comments
 (0)