Skip to content

Disable escaping "*" on signature #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions numpydoc/docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ def __init__(self, func, role='func', doc=None, config={}):
if func is None:
raise ValueError("No function or docstring given")
doc = inspect.getdoc(func) or ''
NumpyDocString.__init__(self, doc)
NumpyDocString.__init__(self, doc, config)

if not self['Signature'] and func is not None:
func, func_name = self.get_func()
Expand All @@ -578,7 +578,7 @@ def __init__(self, func, role='func', doc=None, config={}):
else:
argspec = inspect.getargspec(func)
signature = inspect.formatargspec(*argspec)
signature = '%s%s' % (func_name, signature.replace('*', r'\*'))
signature = '%s%s' % (func_name, signature)
except TypeError:
signature = '%s()' % func_name
self['Signature'] = signature
Expand Down
2 changes: 1 addition & 1 deletion numpydoc/tests/test_docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ def my_func(a, b, **kwargs):
pass

fdoc = FunctionDoc(func=my_func)
assert fdoc['Signature'] == r'my_func(a, b, \*\*kwargs)'
assert fdoc['Signature'] == 'my_func(a, b, **kwargs)'


doc4 = NumpyDocString(
Expand Down
2 changes: 1 addition & 1 deletion numpydoc/tests/test_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_MyClass(sphinx_app):
html = fid.read()
# escaped * chars should no longer be preceded by \'s,
# if we see a \* in the output we know it's incorrect:
assert r'\*' in html # XXX should be "not in", bug!
assert r'\*' not in html
# "self" should not be in the parameter list for the class:
assert 'self,' in html # XXX should be "not in", bug!
# check xref was embedded properly (dict should link using xref):
Expand Down