-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathconf.py
283 lines (243 loc) · 10.7 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
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Handle ReadTheDocs.org build -------------------------------------------
import os
# on_rtd is whether we are on readthedocs.org
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
if on_rtd:
READTHEDOCS_PROJECT = os.environ.get("READTHEDOCS_PROJECT", "monai-deploy-app-sdk")
READTHEDOCS_VERSION = os.environ.get("READTHEDOCS_VERSION", "latest")
import subprocess
subprocess.call(
"/bin/bash -c 'source /home/docs/checkouts/readthedocs.org/user_builds/"
f"{READTHEDOCS_PROJECT}/envs/{READTHEDOCS_VERSION}/bin/activate; ../../run setup read_the_docs'",
shell=True,
)
# Print LD_LIBRARY_PATH for verification
ld_library_path = os.environ.get("LD_LIBRARY_PATH", "")
print(f"LD_LIBRARY_PATH: {ld_library_path}")
subprocess.call(
"/bin/bash -c 'source /home/docs/checkouts/readthedocs.org/user_builds/"
f"{READTHEDOCS_PROJECT}/envs/{READTHEDOCS_VERSION}/bin/activate; ../../run setup_gen_docs'",
shell=True,
)
# -- 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.
#
import re
import sys
sys.path.insert(0, os.path.abspath(".."))
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
print(sys.path)
# -- Project information -----------------------------------------------------
project = "MONAI Deploy App SDK"
copyright = "2021-2024 MONAI Consortium"
author = "MONAI Contributors"
# The full version, including alpha/beta/rc tags
from monai.deploy import __version__ as MONAI_APP_SDK_VERSION # noqa: E402
short_version = MONAI_APP_SDK_VERSION.split("+")[0]
release = short_version
version = re.sub(r"(a|b|rc)\d+.*", "", short_version)
# 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"] # type: ignore
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
# source_suffix = {".rst": "restructuredtext", ".txt": "restructuredtext", ".md": "markdown"}
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinxcontrib.spelling", # https://sphinxcontrib-spelling.readthedocs.io/en/latest/index.html
"sphinx.ext.coverage",
"sphinx.ext.doctest",
"sphinx.ext.extlinks",
"sphinx.ext.ifconfig",
"sphinx.ext.napoleon",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"sphinx.ext.intersphinx",
"sphinx.ext.mathjax",
"sphinxcontrib.bibtex",
"myst_nb",
"sphinx_copybutton",
"sphinx_togglebutton",
"sphinx_panels", # https://sphinx-panels.readthedocs.io/en/latest/
"ablog",
"sphinxemoji.sphinxemoji",
# https://myst-parser.readthedocs.io/en/latest/sphinx/use.html#automatically-create-targets-for-section-headers
# "sphinx.ext.autosectionlabel", <== don't need anymore from v0.13.0
"sphinx_autodoc_typehints",
"sphinxcontrib.mermaid",
]
autoclass_content = "both"
add_module_names = True
source_encoding = "utf-8"
# Prefix document path to section labels, to use:
# `path/to/file:heading` instead of just `heading`
# (https://www.sphinx-doc.org/en/master/usage/extensions/autosectionlabel.html)
# autosectionlabel_prefix_document = True
# autosectionlabel_maxdepth = 4
napoleon_use_param = True
napoleon_include_init_with_doc = True
set_type_checking_flag = True
autodoc_default_options = {
# Make sure that any autodoc declarations show the right members
"members": True,
"inherited-members": True,
"private-members": False,
"show-inheritance": True,
}
autosummary_generate = True
numpydoc_show_class_members = False
napoleon_numpy_docstring = False # force consistency, leave only Google
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# -- 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 = "pydata_sphinx_theme"
html_theme_options = {
"logo_link": "https://monai.io",
"external_links": [
{"url": "https://github.com/Project-MONAI/monai-deploy-app-sdk/issues/new/choose", "name": "SUBMIT ISSUE"}
],
"icon_links": [
{
"name": "GitHub",
"url": "https://github.com/project-monai/monai-deploy-app-sdk",
"icon": "fab fa-github-square",
},
{
"name": "Twitter",
"url": "https://twitter.com/projectmonai",
"icon": "fab fa-twitter-square",
},
],
"collapse_navigation": False,
"navigation_depth": 3,
"show_toc_level": 2,
"footer_items": ["copyright"],
"navbar_align": "content",
# https://pydata-sphinx-theme.readthedocs.io/en/latest/user_guide/sections.html#add-your-own-html-templates-to-theme-sections # noqa
"navbar_start": ["navbar-logo"],
}
html_context = {
"github_user": "Project-MONAI",
"github_repo": "monai-deploy-app-sdk",
"github_version": "main",
"doc_path": "docs/",
"conf_py_path": "/docs/",
"VERSION": version,
}
html_scaled_image_link = False
html_show_sourcelink = True
html_favicon = "../images/favicon.ico"
html_logo = "../images/MONAI-logo-color.png"
# Quicklinks idea is from https://github.com/pydata/pydata-sphinx-theme/issues/221#issuecomment-887622420
# "sidebar-nav-bs" is still need to add to avoid console error messages in the final home page.
html_sidebars = {
"index": ["search-field", "sidebar-quicklinks", "sidebar-nav-bs"],
"**": ["search-field", "sidebar-nav-bs"],
}
pygments_style = "monokai"
# -- Options for pydata-sphinx-theme -------------------------------------------------
#
# (reference: https://pydata-sphinx-theme.readthedocs.io/en/latest/user_guide/configuring.html) # noqa
# 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_css_files = ["custom.css"]
html_title = f"{project} {version} Documentation"
# -- Options for sphinx-panels -------------------------------------------------
#
# (reference: https://sphinx-panels.readthedocs.io/en/latest/)
panels_add_bootstrap_css = False # pydata-sphinx-theme already loads bootstrap css
# -- Options for linkcheck builder -------------------------------------------------
#
# Reference
# : https://www.sphinx-doc.org/en/master/usage/configuration.html?highlight=linkcheck#options-for-the-linkcheck-builder)
linkcheck_ignore = [r"^\/", r"^\.\."]
# -- Options for sphinx.ext.todo -------------------------------------------------
# (reference: https://www.sphinx-doc.org/en/master/usage/extensions/todo.html)
todo_include_todos = True
# -- Options for sphinxemoji.sphinxemoji -------------------------------------------------
#
# (reference: https://sphinxemojicodes.readthedocs.io/en/stable/#supported-codes) # noqa
#
# https://myst-parser.readthedocs.io/en/latest/using/syntax-optional.html#markdown-figures # noqa
myst_enable_extensions = [
"amsmath",
"colon_fence",
"deflist",
"dollarmath",
"html_admonition",
"html_image",
# "linkify", # disable linkify to not confuse with the file name such as `app.py`
"replacements",
# "smartquotes",
"substitution",
"tasklist",
]
# https://myst-parser.readthedocs.io/en/latest/syntax/optional.html#syntax-header-anchors
myst_heading_anchors = 5
# -- Options for myst-nb -------------------------------------------------
#
# (reference: https://myst-nb.readthedocs.io/en/latest/)
# Prevent the following error
# MyST NB Configuration Error:
# `nb_render_priority` not set for builder: doctest
nb_render_priority = {"doctest": ()}
# Prevent creating jupyter_execute folder in dist
# https://myst-nb.readthedocs.io/en/latest/use/execute.html#executing-in-temporary-folders # noqa
execution_in_temp = True
jupyter_execute_notebooks = "off"
# -- Options for sphinxcontrib.spelling -------------------------------------------------
#
# (reference: https://sphinxcontrib-spelling.readthedocs.io/en/latest/customize.html)
spelling_word_list_filename = ["spelling_wordlist.txt"]
spelling_exclude_patterns = [] # type: ignore
# -- Setup for Sphinx --------------------------------------
# import subprocess
# def generate_apidocs(*args):
# """Generate API docs automatically by trawling the available modules"""
# module_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "monai"))
# output_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "apidocs"))
# apidoc_command_path = "sphinx-apidoc"
# if hasattr(sys, "real_prefix"): # called from a virtualenv
# apidoc_command_path = os.path.join(sys.prefix, "bin", "sphinx-apidoc")
# apidoc_command_path = os.path.abspath(apidoc_command_path)
# print(f"output_path {output_path}")
# print(f"module_path {module_path}")
# subprocess.check_call(
# [apidoc_command_path, "-e"]
# + ["--implicit-namespaces"] # /monai folder wouldn't have __init__.py so we need this option.
# + ["-o", output_path]
# + [module_path]
# + [os.path.join(module_path, p) for p in exclude_patterns]
# )
# Avoid "WARNING: more than one target found for cross-reference 'XXX': YYY, ZZZ"
# - https://github.com/sphinx-doc/sphinx/issues/4961
# - https://github.com/sphinx-doc/sphinx/issues/3866
from sphinx.domains.python import PythonDomain
class PatchedPythonDomain(PythonDomain):
def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode):
if "refspecific" in node:
del node["refspecific"]
return super(PatchedPythonDomain, self).resolve_xref(env, fromdocname, builder, typ, target, node, contnode)
def setup(app):
# Hook to allow for automatic generation of API docs
# before doc deployment begins.
# app.connect("builder-inited", generate_apidocs)
# Avoid "WARNING: more than one target found for cross-reference 'XXX': YYY, ZZZ
app.add_domain(PatchedPythonDomain, override=True)