Skip to content

Commit f884309

Browse files
authored
Disable escaping "*" on signature (#256)
On handling autodoc-process-signature event, it's not needed to escape "*" characters. The escaping is mainly allowed for highlighting feature of editors. So it's not necessary for generating contents by autodoc. In addition, since Sphinx-3.0, the escaping is not recommended by default (see strip_signature_backslash) refs: sphinx-doc/sphinx#7439
1 parent 0e8ce2e commit f884309

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

numpydoc/docscrape.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ def __init__(self, func, role='func', doc=None, config={}):
564564
if func is None:
565565
raise ValueError("No function or docstring given")
566566
doc = inspect.getdoc(func) or ''
567-
NumpyDocString.__init__(self, doc)
567+
NumpyDocString.__init__(self, doc, config)
568568

569569
if not self['Signature'] and func is not None:
570570
func, func_name = self.get_func()
@@ -578,7 +578,7 @@ def __init__(self, func, role='func', doc=None, config={}):
578578
else:
579579
argspec = inspect.getargspec(func)
580580
signature = inspect.formatargspec(*argspec)
581-
signature = '%s%s' % (func_name, signature.replace('*', r'\*'))
581+
signature = '%s%s' % (func_name, signature)
582582
except TypeError:
583583
signature = '%s()' % func_name
584584
self['Signature'] = signature

numpydoc/tests/test_docscrape.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ def my_func(a, b, **kwargs):
720720
pass
721721

722722
fdoc = FunctionDoc(func=my_func)
723-
assert fdoc['Signature'] == r'my_func(a, b, \*\*kwargs)'
723+
assert fdoc['Signature'] == 'my_func(a, b, **kwargs)'
724724

725725

726726
doc4 = NumpyDocString(

numpydoc/tests/test_full.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_MyClass(sphinx_app):
4747
html = fid.read()
4848
# escaped * chars should no longer be preceded by \'s,
4949
# if we see a \* in the output we know it's incorrect:
50-
assert r'\*' in html # XXX should be "not in", bug!
50+
assert r'\*' not in html
5151
# "self" should not be in the parameter list for the class:
5252
assert 'self,' in html # XXX should be "not in", bug!
5353
# check xref was embedded properly (dict should link using xref):

0 commit comments

Comments
 (0)