Skip to content

Commit dec7fef

Browse files
authored
Prevent autosummary from using non-Python signature syntax in its tables (#364)
As suggested here #348 (comment).
1 parent 0e423b0 commit dec7fef

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

spec/conf.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@
4747
add_module_names = False
4848
napoleon_custom_sections = [('Returns', 'params_style')]
4949

50+
# Make autosummary show the signatures of functions in the tables using actual
51+
# Python syntax. There's currently no supported way to do this, so we have to
52+
# just patch out the function that processes the signatures. See
53+
# https://github.com/sphinx-doc/sphinx/issues/10053.
54+
import sphinx.ext.autosummary as autosummary_mod
55+
if hasattr(autosummary_mod, '_module'):
56+
# It's a sphinx deprecated module wrapper object
57+
autosummary_mod = autosummary_mod._module
58+
autosummary_mod.mangle_signature = lambda sig, max_chars=30: sig
59+
5060
# Add any paths that contain templates here, relative to this directory.
5161
templates_path = ['_templates']
5262

@@ -162,4 +172,4 @@ def process_signature(app, what, name, obj, options, signature, return_annotatio
162172
return signature, return_annotation
163173

164174
def setup(app):
165-
app.connect("autodoc-process-signature", process_signature)
175+
app.connect("autodoc-process-signature", process_signature)

0 commit comments

Comments
 (0)