Skip to content

Commit b0b2684

Browse files
authored
doc: Remove autodoc-process-signature hook (#3029)
By now, this is redundant with the ast-postprocessing of the swig-wrapper. Related to #2399.
1 parent 2732898 commit b0b2684

File tree

1 file changed

+0
-54
lines changed

1 file changed

+0
-54
lines changed

doc/conf.py

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -441,59 +441,6 @@ def process_docstring(app, what, name, obj, options, lines):
441441
)
442442

443443

444-
def fix_typehints(sig: str) -> str:
445-
# cleanup types
446-
if not isinstance(sig, str):
447-
return sig
448-
449-
for old, new in typemaps.items():
450-
sig = sig.replace(old, new)
451-
sig = sig.replace("void", "None")
452-
sig = sig.replace("amici::realtype", "float")
453-
sig = sig.replace("std::string", "str")
454-
sig = sig.replace("double", "float")
455-
sig = sig.replace("long", "int")
456-
sig = sig.replace("char const *", "str")
457-
sig = sig.replace("amici::", "")
458-
sig = sig.replace("sunindextype", "int")
459-
sig = sig.replace("H5::H5File", "object")
460-
461-
# remove const / const&
462-
sig = sig.replace(" const&? ", r" ")
463-
sig = re.sub(r" const&?$", r"", sig)
464-
465-
# remove pass by reference
466-
sig = re.sub(r" &(,|\))", r"\1", sig)
467-
sig = re.sub(r" &$", r"", sig)
468-
469-
# turn gsl_spans and pointers into Iterables
470-
sig = re.sub(r"([\w.]+) \*", r"Iterable[\1]", sig)
471-
sig = re.sub(r"gsl::span< ([\w.]+) >", r"Iterable[\1]", sig)
472-
473-
# fix garbled output
474-
sig = sig.replace(" >", "")
475-
return sig
476-
477-
478-
def process_signature(
479-
app, what: str, name: str, obj, options, signature, return_annotation
480-
):
481-
if signature is None:
482-
return
483-
484-
# only apply in the amici.amici module
485-
split_name = name.split(".")
486-
if len(split_name) < 2 or split_name[1] != "amici":
487-
return
488-
489-
signature = fix_typehints(signature)
490-
if hasattr(obj, "__annotations__"):
491-
for ann in obj.__annotations__:
492-
obj.__annotations__[ann] = fix_typehints(obj.__annotations__[ann])
493-
494-
return signature, return_annotation
495-
496-
497444
# this code fixes references in symlinked md files in documentation folder
498445
# link replacements must be in env.domains['std'].labels
499446
doclinks = {
@@ -600,7 +547,6 @@ def skip_member(app, what, name, obj, skip, options):
600547

601548
def setup(app: "sphinx.application.Sphinx"):
602549
app.connect("autodoc-process-docstring", process_docstring, priority=0)
603-
app.connect("autodoc-process-signature", process_signature, priority=0)
604550
app.connect("missing-reference", process_missing_ref, priority=0)
605551
app.connect("autodoc-skip-member", skip_member, priority=0)
606552
app.config.intersphinx_mapping = intersphinx_mapping

0 commit comments

Comments
 (0)