forked from AMICI-dev/AMICI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconf.py
711 lines (595 loc) · 22.4 KB
/
conf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/stable/config
import os
import re
import subprocess
import sys
from enum import EnumType
import exhale.deploy
from unittest import mock
import sphinx
from exhale import configs as exhale_configs
from sphinx.transforms.post_transforms import ReferencesResolver
try:
import exhale_multiproject_monkeypatch # noqa: F401
except ModuleNotFoundError:
# for unclear reasons, the import of exhale_multiproject_monkeypatch
# fails on some systems, because the the location of the editable install
# is not automatically added to sys.path ¯\_(ツ)_/¯
from importlib.metadata import Distribution
import json
from urllib.parse import unquote_plus, urlparse
dist = Distribution.from_name("sphinx-contrib-exhale-multiproject")
url = json.loads(dist.read_text("direct_url.json"))["url"]
package_dir = unquote_plus(urlparse(url).path)
sys.path.append(package_dir)
import exhale_multiproject_monkeypatch # noqa: F401
# need to import before setting typing.TYPE_CHECKING=True, fails otherwise
import amici
import pandas as pd # noqa: F401
import sympy as sp # noqa: F401
# BEGIN Monkeypatch exhale
from exhale.deploy import _generate_doxygen as exhale_generate_doxygen
def my_exhale_generate_doxygen(doxygen_input):
"""Monkey-patch exhale for post-processing doxygen output"""
# run mtocpp_post
doxy_xml_dir = exhale_configs._doxygen_xml_output_directory
if "matlab" in doxy_xml_dir:
print("Running mtocpp_post on ", doxy_xml_dir)
mtocpp_post = os.path.join(
amici_dir, "ThirdParty", "mtocpp-master", "build", "mtocpp_post"
)
subprocess.run([mtocpp_post, doxy_xml_dir])
# let exhale do its job
exhale_generate_doxygen(doxygen_input)
exhale.deploy._generate_doxygen = my_exhale_generate_doxygen
# END Monkeypatch exhale
# BEGIN Monkeypatch breathe
from breathe.renderer.sphinxrenderer import (
DomainDirectiveFactory as breathe_DomainDirectiveFactory,
)
old_breathe_DomainDirectiveFactory_create = (
breathe_DomainDirectiveFactory.create
)
def my_breathe_DomainDirectiveFactory_create(domain: str, args):
if domain != "mat":
return old_breathe_DomainDirectiveFactory_create(domain, args)
from sphinxcontrib.matlab import MatClassmember, MATLABDomain
matlab_classes = {k: (v, k) for k, v in MATLABDomain.directives.items()}
matlab_classes["variable"] = (MatClassmember, "attribute")
cls, name = matlab_classes[args[0]]
return cls(domain + ":" + name, *args[1:])
breathe_DomainDirectiveFactory.create = (
my_breathe_DomainDirectiveFactory_create
)
# END Monkeypatch breathe
def install_mtocpp():
"""Install mtocpp (Matlab doxygen filter)"""
cmd = os.path.join(amici_dir, "scripts", "downloadAndBuildMtocpp.sh")
ret = subprocess.run(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
)
if ret.returncode != 0:
print(ret.stdout.decode("utf-8"))
raise RuntimeError("downloadAndBuildMtocpp.sh failed")
def install_doxygen():
"""Get a more recent doxygen"""
version = "1.11.0"
release = f"Release_{version.replace('.', '_')}"
filename = f"doxygen-{version}.linux.bin.tar.gz"
doxygen_exe = os.path.join(
amici_dir, "ThirdParty", f"doxygen-{version}", "bin", "doxygen"
)
# to create a symlink to doxygen in a location that is already on PATH
some_dir_on_path = os.environ["PATH"].split(os.pathsep)[0]
cmd = (
f"cd '{os.path.join(amici_dir, 'ThirdParty')}' "
f"&& wget 'https://github.com/doxygen/doxygen/releases/download/"
f"{release}/{filename}' "
f"&& tar -xzf '{filename}' "
f"&& ln -sf '{doxygen_exe}' '{some_dir_on_path}'"
)
subprocess.run(cmd, shell=True, check=True)
assert os.path.islink(os.path.join(some_dir_on_path, "doxygen"))
# verify it's available
res = subprocess.run(
["doxygen", "--version"], check=False, capture_output=True
)
print(res.stdout.decode(), res.stderr.decode())
assert version in res.stdout.decode()
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
amici_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# -- RTD custom build --------------------------------------------------------
# only execute those commands when running from RTD
if "READTHEDOCS" in os.environ and os.environ["READTHEDOCS"]:
install_doxygen()
# Required for matlab doxygen processing
install_mtocpp()
# -- Project information -----------------------------------------------------
# The short X.Y version
version = amici.__version__
# The full version, including alpha/beta/rc tags
release = version
project = "AMICI"
copyright = "2020, The AMICI developers"
author = "The AMICI developers"
title = "AMICI Documentation"
# -- Mock out some problematic modules-------------------------------------
# Note that for sub-modules, all parent modules must be listed explicitly.
autodoc_mock_imports = ["_amici", "amici._amici"]
for mod_name in autodoc_mock_imports:
sys.modules[mod_name] = mock.MagicMock()
# -- General configuration ---------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"readthedocs_ext.readthedocs",
# Required, e.g. for PEtab-derived classes where the base class has non-rst
# docstrings
"sphinx.ext.napoleon",
"sphinx.ext.autodoc",
"sphinx.ext.doctest",
"sphinx.ext.coverage",
"sphinx.ext.intersphinx",
"sphinx.ext.autosummary",
"sphinx.ext.viewcode",
"sphinx.ext.mathjax",
"sphinxcontrib.matlab",
"nbsphinx",
"IPython.sphinxext.ipython_console_highlighting",
"recommonmark",
"sphinx_autodoc_typehints",
"hoverxref.extension",
"breathe",
"exhale",
]
intersphinx_mapping = {
"pysb": ("https://pysb.readthedocs.io/en/stable/", None),
"petab": (
"https://petab.readthedocs.io/projects/libpetab-python/en/latest/",
None,
),
"pandas": ("https://pandas.pydata.org/docs/", None),
"numpy": ("https://numpy.org/devdocs/", None),
"sympy": ("https://docs.sympy.org/latest/", None),
"python": ("https://docs.python.org/3", None),
"jax": ["https://jax.readthedocs.io/en/latest/", None],
}
# Add notebooks prolog with binder links
# get current git reference
ret = subprocess.run("git rev-parse HEAD".split(" "), capture_output=True)
ref = ret.stdout.rstrip().decode()
nbsphinx_prolog = (
f"{{% set {ref=} %}}"
r"""
{% set docname = "documentation/" + env.doc2path(env.docname, base=False)|string %}
.. raw:: html
<div class="note">
<a href="https://mybinder.org/v2/gh/AMICI-dev/AMICI/{{ ref|e }}?labpath={{ docname|e }}" target="_blank">
<img src="https://mybinder.org/badge_logo.svg" alt="Open in binder"/></a>
</div>
"""
)
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = [".rst", ".md"]
# The master toctree document.
master_doc = "index"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = "en"
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = [
"_build",
"Thumbs.db",
".DS_Store",
"**.ipynb_checkpoints",
"numpy.py",
"INSTALL.md",
"MATLAB_.md",
"CPP_.md",
"gfx",
]
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
# autodoc
autodoc_default_options = {
"special-members": "__init__",
"inherited-members": True,
"undoc-members": True,
}
# sphinx-autodoc-typehints
typehints_fully_qualified = True
typehints_document_rtype = True
set_type_checking_flag = True
# hoverxref
hoverxref_auto_ref = True
hoverxref_roles = ["term"]
hoverxref_domains = ["py"]
hoverxref_role_types = {
"hoverxref": "tooltip",
"ref": "tooltip",
"term": "tooltip",
"obj": "tooltip",
"func": "tooltip",
"mod": "tooltip",
"meth": "tooltip",
"class": "tooltip",
}
# breathe settings
breathe_projects = {
"AMICI_Matlab": "./_doxyoutput_amici_matlab/xml",
"AMICI_CPP": "./_doxyoutput_amici_cpp/xml",
}
breathe_default_project = "AMICI_CPP"
breathe_domain_by_extension = {
"m": "mat",
"h": "cpp",
"cpp": "cpp",
}
# exhale settings
exhale_args = {
"rootFileName": "library_root.rst",
"doxygenStripFromPath": "..",
"createTreeView": True,
# TIP: if using the sphinx-bootstrap-theme, you need
# "treeViewIsBootstrap": True,
"exhaleExecutesDoxygen": True,
"verboseBuild": True,
}
mtocpp_filter = os.path.join(
amici_dir, "matlab", "mtoc", "config", "mtocpp_filter.sh"
)
exhale_projects_args = {
"AMICI_CPP": {
"exhaleDoxygenStdin": "\n".join(
[
"INPUT = ../include/amici",
"BUILTIN_STL_SUPPORT = YES",
"PREDEFINED += EXHALE_DOXYGEN_SHOULD_SKIP_THIS",
"EXCLUDE += ../include/amici/interface_matlab.h",
"EXCLUDE += ../include/amici/returndata_matlab.h",
"EXCLUDE += ../include/amici/spline.h",
# amici::log collides with amici::${some_enum}::log
# potentially fixed in
# https://github.com/svenevs/exhale/commit/c924df2e139a09fbacd07587779c55fd0ee4e00b
# and can be un-excluded after the next exhale release
"EXCLUDE += ../include/amici/symbolic_functions.h",
]
),
"containmentFolder": "_exhale_cpp_api",
"rootFileTitle": "AMICI C++ API",
"afterTitleDescription": "AMICI C++ library functions",
},
# Third Party Project Includes
"AMICI_Matlab": {
"exhaleDoxygenStdin": "\n".join(
[
"INPUT = ../matlab",
"EXTENSION_MAPPING = .m=C++",
"FILTER_PATTERNS = " f"*.m={mtocpp_filter}",
"EXCLUDE += ../matlab/examples",
"EXCLUDE += ../matlab/mtoc",
"EXCLUDE += ../matlab/SBMLimporter",
"EXCLUDE += ../matlab/auxiliary",
"EXCLUDE += ../matlab/tests",
"PREDEFINED += EXHALE_DOXYGEN_SHOULD_SKIP_THIS",
]
),
"containmentFolder": "_exhale_matlab_api",
"rootFileTitle": "AMICI Matlab API",
"afterTitleDescription": "AMICI Matlab library functions",
"lexerMapping": {r".*\.m$": "matlab"},
},
}
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
# html_static_path = ['_static']
html_favicon = "gfx/logo.png"
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = "AMICIdoc"
# -- Options for LaTeX output ------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, "AMICI.tex", title, author, "manual"),
]
# -- Options for manual page output ------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "amici", title, [author], 1)]
# -- Options for Texinfo output ----------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(
master_doc,
"AMICI",
title,
author,
"AMICI",
"Advanced Multilanguage Interface for CVODES and IDAS.",
"Miscellaneous",
),
]
# Custom processing routines for docstrings and signatures
typemaps = {
"std::vector< amici::realtype,std::allocator< amici::realtype > >": "DoubleVector",
"std::vector< double,std::allocator< double > >": "DoubleVector",
"std::vector< int,std::allocator< int > >": "IntVector",
"std::vector< amici::ParameterScaling,std::allocator< "
"amici::ParameterScaling >": "ParameterScalingVector",
"std::vector< std::string,std::allocator< std::string > >": "StringVector",
"std::vector< bool,std::allocator< bool > >": "BoolVector",
"std::map< std::string,amici::realtype,std::less< std::string >,"
"std::allocator< std::pair< std::string const,amici::realtype > > >": "StringDoubleMap",
"std::vector< amici::ExpData *,std::allocator< amici::ExpData * > >": "ExpDataPtrVector",
"std::vector< std::unique_ptr< amici::ReturnData >,std::allocator< "
"std::unique_ptr< amici::ReturnData > > >": "Iterable[ReturnData]",
"std::unique_ptr< amici::ExpData >": "ExpData",
"std::unique_ptr< amici::ReturnData >": "ReturnData",
"std::unique_ptr< amici::Solver >": "Solver",
"amici::realtype": "float",
}
vector_types = {
"IntVector": ":class:`int`",
"BoolVector": ":class:`bool`",
"DoubleVector": ":class:`float`",
"StringVector": ":class:`str`",
"ExpDataPtrVector": ":class:`amici.amici.ExpData`",
}
def process_docstring(app, what, name, obj, options, lines):
# only apply in the amici.amici module
if len(name.split(".")) < 2 or name.split(".")[1] != "amici":
return
# add custom doc to swig generated classes
if len(name.split(".")) == 3 and name.split(".")[2] in [
"IntVector",
"BoolVector",
"DoubleVector",
"StringVector",
"ExpDataPtrVector",
]:
cname = name.split(".")[2]
lines.append(
f"Swig-Generated class templating common python "
f"types including :class:`Iterable` "
f"[{vector_types[cname]}] "
f"and "
f":class:`numpy.array` [{vector_types[cname]}] to facilitate"
" interfacing with C++ bindings."
)
return
if len(name.split(".")) == 3 and name.split(".")[2] in [
"ExpDataPtr",
"ReturnDataPtr",
"ModelPtr",
"SolverPtr",
]:
cname = name.split(".")[2]
lines.append(
f"Swig-Generated class that implements smart pointers to "
f'{cname.replace("Ptr", "")} as objects.'
)
return
# add linebreaks before argument/return definitions
lines_clean = []
while len(lines):
line = lines.pop(0)
if (
re.match(r":(type|rtype|param|return)", line)
and len(lines_clean)
and lines_clean[-1] != ""
):
lines_clean.append("")
lines_clean.append(line)
lines.extend(lines_clean)
for i in range(len(lines)):
# fix types
for old, new in typemaps.items():
lines[i] = lines[i].replace(old, new)
lines[i] = re.sub(
r"amici::(Model|Solver|ExpData) ",
r":class:`amici\.amici\.\1\`",
lines[i],
)
lines[i] = re.sub(
r"amici::(runAmiciSimulation[s]?)",
r":func:`amici\.amici\.\1`",
lines[i],
)
def fix_typehints(sig: str) -> str:
# cleanup types
if not isinstance(sig, str):
return sig
for old, new in typemaps.items():
sig = sig.replace(old, new)
sig = sig.replace("void", "None")
sig = sig.replace("amici::realtype", "float")
sig = sig.replace("std::string", "str")
sig = sig.replace("double", "float")
sig = sig.replace("long", "int")
sig = sig.replace("char const *", "str")
sig = sig.replace("amici::", "")
sig = sig.replace("sunindextype", "int")
sig = sig.replace("H5::H5File", "object")
# remove const / const&
sig = sig.replace(" const&? ", r" ")
sig = re.sub(r" const&?$", r"", sig)
# remove pass by reference
sig = re.sub(r" &(,|\))", r"\1", sig)
sig = re.sub(r" &$", r"", sig)
# turn gsl_spans and pointers into Iterables
sig = re.sub(r"([\w.]+) \*", r"Iterable[\1]", sig)
sig = re.sub(r"gsl::span< ([\w.]+) >", r"Iterable[\1]", sig)
# fix garbled output
sig = sig.replace(" >", "")
return sig
def process_signature(
app, what: str, name: str, obj, options, signature, return_annotation
):
if signature is None:
return
# only apply in the amici.amici module
split_name = name.split(".")
if len(split_name) < 2 or split_name[1] != "amici":
return
signature = fix_typehints(signature)
if hasattr(obj, "__annotations__"):
for ann in obj.__annotations__:
obj.__annotations__[ann] = fix_typehints(obj.__annotations__[ann])
return signature, return_annotation
# this code fixes references in symlinked md files in documentation folder
# link replacements must be in env.domains['std'].labels
doclinks = {
"documentation/development": "/development.md",
"documentation/CI": "/ci.md",
"documentation/code_review_guide": "/code_review_guide.md",
}
def process_missing_ref(app, env, node, contnode):
if not any(link in node["reftarget"] for link in doclinks):
return # speedup futile processing
for old, new in doclinks.items():
node["reftarget"] = node["reftarget"].replace(old, new)
cnode = node[0]
if "refuri" in cnode:
for old, new in doclinks.items():
cnode["refuri"] = cnode["refuri"].replace(old, new)
refdoc = node.get("refdoc", env.docname)
resolver = ReferencesResolver(env.get_doctree(refdoc))
result = resolver.resolve_anyref(refdoc, node, cnode)
return result
def skip_member(app, what, name, obj, skip, options):
ignored_names = {
"AbstractModel",
"CVodeSolver",
"IDASolver",
"Model_ODE",
"Model_DAE",
"ConditionContext",
"checkSigmaPositivity",
"createGroup",
"equals",
"printErrMsgIdAndTxt",
"wrapErrHandlerFn",
"printWarnMsgIdAndTxt",
"AmiciApplication",
"writeReturnData",
"writeReturnDataDiagnosis",
"attributeExists",
"locationExists",
"createAndWriteDouble1DDataset",
"createAndWriteDouble2DDataset",
"createAndWriteDouble3DDataset",
"createAndWriteInt1DDataset",
"createAndWriteInt2DDataset",
"createAndWriteInt3DDataset",
"getDoubleDataset1D",
"getDoubleDataset2D",
"getDoubleDataset3D",
"getIntDataset1D",
"getIntScalarAttribute",
"getDoubleScalarAttribute",
"stdVec2ndarray",
"SwigPyIterator",
"thisown",
}
if name in ignored_names:
return True
if name.startswith("_") and name != "__init__":
return True
obj_str = str(obj)
# ignore various functions for std::vector<> types
if re.match(r"^<function [\w]+Vector\.", obj_str):
return True
# ignore various functions for smart pointer types
if re.match(r"^<function [\w]+Ptr\.", obj_str):
return True
# ignore various functions for StringDoubleMap
if obj_str.startswith("<function StringDoubleMap"):
return True
# Skip inherited members from builtins
# (skips, for example, all the int/str-derived methods of enums
if (
objclass := getattr(obj, "__objclass__", None)
) and objclass.__module__ == "builtins":
return True
# Avoid the following issue for all enum types:
# > python/sdist/amici/amici.py:docstring of amici.amici.FixedParameterContext.from_bytes:9:
# WARNING: Inline interpreted text or phrase reference start-string without end-string.
if (
(qualname := getattr(obj, "__qualname__", ""))
and qualname == "int.to_bytes"
) or (
isinstance(getattr(obj, "__self__", None), EnumType)
and name == "from_bytes"
):
return True
return None
def setup(app: "sphinx.application.Sphinx"):
app.connect("autodoc-process-docstring", process_docstring, priority=0)
app.connect("autodoc-process-signature", process_signature, priority=0)
app.connect("missing-reference", process_missing_ref, priority=0)
app.connect("autodoc-skip-member", skip_member, priority=0)
app.config.intersphinx_mapping = intersphinx_mapping
app.config.autosummary_generate = True
app.config.autodoc_mock_imports = autodoc_mock_imports