Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Prevent autosummary from using non-Python signature syntax in its tables #364

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
Jan 11, 2022
Merged
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
12 changes: 11 additions & 1 deletion spec/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@
add_module_names = False
napoleon_custom_sections = [('Returns', 'params_style')]

# Make autosummary show the signatures of functions in the tables using actual
# Python syntax. There's currently no supported way to do this, so we have to
# just patch out the function that processes the signatures. See
# https://github.com/sphinx-doc/sphinx/issues/10053.
import sphinx.ext.autosummary as autosummary_mod
if hasattr(autosummary_mod, '_module'):
# It's a sphinx deprecated module wrapper object
autosummary_mod = autosummary_mod._module
autosummary_mod.mangle_signature = lambda sig, max_chars=30: sig

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

Expand Down Expand Up @@ -162,4 +172,4 @@ def process_signature(app, what, name, obj, options, signature, return_annotatio
return signature, return_annotation

def setup(app):
app.connect("autodoc-process-signature", process_signature)
app.connect("autodoc-process-signature", process_signature)