From c7881f991d3bd58ce82f2b2a9e56d802d2ea8d3b Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Mon, 10 Jan 2022 14:51:42 -0700 Subject: [PATCH] Prevent autosummary from using non-Python signature syntax in its tables As suggested here https://github.com/data-apis/array-api/pull/348#issuecomment-1004380206. --- spec/conf.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/spec/conf.py b/spec/conf.py index 5370da268..5493713b3 100644 --- a/spec/conf.py +++ b/spec/conf.py @@ -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'] @@ -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) \ No newline at end of file + app.connect("autodoc-process-signature", process_signature)