-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathconf.py
More file actions
292 lines (261 loc) · 11 KB
/
conf.py
File metadata and controls
292 lines (261 loc) · 11 KB
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
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
"""Sphinx configuration for the movement documentation."""
import os
import sys
import setuptools_scm
# Used when building API docs, put the dependencies
# of any class you are documenting here
autodoc_mock_imports = []
# Add the module path to sys.path here.
# If the directory is relative to the documentation root,
# use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath("../.."))
project = "movement"
copyright = "2023, University College London"
author = "Niko Sirmpilatze"
try:
release = setuptools_scm.get_version(root="../..", relative_to=__file__)
release = release.split("+")[0] # remove git hash
except LookupError:
# if git is not initialised, still allow local build
# with a dummy version
release = "0.0.0"
is_dev = "dev" in release
doc_version = "dev" if is_dev else f"v{release}"
binder_branch = "main" if is_dev else f"v{release}"
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = [
"sphinx.ext.napoleon",
"sphinx.ext.autodoc",
"sphinx.ext.githubpages",
"sphinx_autodoc_typehints",
"sphinx.ext.autosummary",
"sphinx.ext.viewcode",
"sphinx.ext.intersphinx",
"myst_parser",
"nbsphinx",
"notfound.extension",
"sphinx_design",
"sphinx_gallery.gen_gallery",
"sphinx_sitemap",
"sphinx.ext.autosectionlabel",
"ablog",
]
# Configure the myst parser to enable cool markdown features
# See https://sphinx-design.readthedocs.io
myst_enable_extensions = [
"amsmath",
"colon_fence",
"deflist",
"dollarmath",
"fieldlist",
"html_admonition",
"html_image",
"linkify",
"replacements",
"smartquotes",
"strikethrough",
"substitution",
"tasklist",
]
# Automatically add anchors to markdown headings
myst_heading_anchors = 4
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# Automatically generate stub pages for API
autosummary_generate = True
autosummary_generate_overwrite = False
autodoc_default_flags = ["members", "inherited-members"]
# Prefix section labels with the document name
autosectionlabel_prefix_document = True
# 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 = [
"**.ipynb_checkpoints",
# to ensure that include files (partial pages) aren't built, exclude them
# https://github.com/sphinx-doc/sphinx/issues/1965#issuecomment-124732907
"**/includes/**",
# exclude .py and .ipynb files in examples generated by sphinx-gallery
# this is to prevent sphinx from complaining about duplicate source files
"examples/*.ipynb",
"examples/*.py",
"examples/**/*.ipynb",
"examples/**/*.py",
]
# Configure Sphinx gallery
sphinx_gallery_conf = {
"examples_dirs": ["../../examples"],
"filename_pattern": "/*.py", # which files to execute before inclusion
"gallery_dirs": ["examples"], # output directory
"run_stale_examples": True, # re-run examples on each build
# Integration with Binder, see https://sphinx-gallery.github.io/stable/configuration.html#generate-binder-links-for-gallery-notebooks-experimental
"binder": {
"org": "neuroinformatics-unit",
"repo": "movement",
"branch": binder_branch, # Can be any branch, tag, or commit hash
"binderhub_url": "https://mybinder.org",
"dependencies": ["../../.binder/requirements.txt"],
},
"reference_url": {"movement": None},
"default_thumb_file": "source/_static/data_icon.png",
# default thumbnail image
# Do not render config comments with the pattern
# sphinx_gallery_config [= value]
"remove_config_comments": True,
# Mini-galleries config, see https://sphinx-gallery.github.io/stable/configuration.html#add-mini-galleries-for-api-documentation
"backreferences_dir": "api/backreferences",
# directory where function/class granular galleries are stored
}
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = "pydata_sphinx_theme"
html_title = "movement"
html_logo = "_static/movement_favicon.svg"
html_favicon = "_static/movement_favicon.svg"
# Customize the theme
html_theme_options = {
"icon_links": [
{
# Label for this link
"name": "GitHub",
# URL where the link will redirect
"url": "https://github.com/neuroinformatics-unit/movement",
# Icon class (if "type": "fontawesome"),
# or path to local image (if "type": "local")
"icon": "fa-brands fa-github",
# The type of image to be used (see below for details)
"type": "fontawesome",
},
{
"name": "Zulip (chat)",
"url": "https://neuroinformatics.zulipchat.com/#narrow/stream/406001-Movement",
"icon": "fa-solid fa-comments",
"type": "fontawesome",
},
],
"switcher": {
"json_url": "https://movement.neuroinformatics.dev/latest/_static/switcher.json",
"version_match": doc_version,
},
"logo": {
"text": f"{project} v{release}",
},
"navbar_end": ["version-switcher", "theme-switcher", "navbar-icon-links"],
"footer_start": ["footer_start"],
"footer_end": ["footer_end"],
"external_links": [],
}
# Redirect the webpage to another URL
# Sphinx will create the appropriate CNAME file in the build directory
# The default is the URL of the GitHub pages
# https://www.sphinx-doc.org/en/master/usage/extensions/githubpages.html
github_user = "neuroinformatics-unit"
html_baseurl = "https://movement.neuroinformatics.dev"
sitemap_url_scheme = "{link}"
# 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 = [
("css/custom.css", {"priority": 100}),
]
html_js_files = [
"js/contributors.js", # javascript for contributors table
]
html_favicon = "_static/light-logo-niu.png"
# Linkcheck configuration
linkcheck_timeout = 60 # defaut is 30
linkcheck_retries = 3 # default is 1
# The linkcheck builder will skip verifying that anchors exist when checking
# these URLs (because they are generated dynamically)
linkcheck_anchors_ignore_for_url = [
"https://gin.g-node.org/G-Node/Info/wiki/",
"https://neuroinformatics.zulipchat.com/",
"https://github.com/talmolab/sleap/blob/v1.3.3/sleap/info/write_tracking_h5.py",
]
# A list of regular expressions that match URIs that should not be checked
linkcheck_ignore = [
"https://pubs.acs.org/doi/*", # Checking dois is forbidden here
"https://opensource.org/license/bsd-3-clause/", # 403 error
"https://www.sainsburywellcome.org/", # ConnectTimeoutError
"https://www.robots.ox.ac.uk/", # 404 error
"https://silvalab.codeberg.page/BraiAn/", # SSLError despite working link
"https://www.g-node.org/", # frequent timeouts
"https://www.contributor-covenant.org/*", # frequent timeouts
"https://docutils.sourceforge.io/*", # 403 error
"https://www.iso.org/", # 403 error
# Checking zenodo redirects (from concept doi to record) takes a long time
"https://zenodo.org/doi/*",
"https://zenodo.org/records/*",
"https://doi.org/10.5281/zenodo.*",
"https://abide.ics.ulisboa.pt/*" # flaky
]
# Add request headers for specific domains (e.g. to avoid rate-limiting)
linkcheck_request_headers = {
"https://github.com": {
"Authorization": f"Bearer {os.environ.get('GITHUB_TOKEN', '')}",
},
}
myst_url_schemes = {
"http": None,
"https": None,
"ftp": None,
"mailto": None,
"movement-github": "https://github.com/neuroinformatics-unit/movement/{{path}}",
"movement-zulip": "https://neuroinformatics.zulipchat.com/#narrow/stream/406001-Movement",
"movement-community-calls": "https://neuroinformatics.zulipchat.com/#narrow/channel/406001-Movement/topic/Community.20Calls",
"conda": "https://docs.conda.io/projects/conda/en/latest/{{path}}#{{fragment}}",
"dlc": "https://www.mackenziemathislab.org/deeplabcut/",
"gin": "https://gin.g-node.org/{{path}}#{{fragment}}",
"github-docs": "https://docs.github.com/en/{{path}}#{{fragment}}",
"myst-parser": "https://myst-parser.readthedocs.io/en/latest/{{path}}#{{fragment}}",
"napari": "https://napari.org/stable/{{path}}",
"setuptools-scm": "https://setuptools-scm.readthedocs.io/en/latest/{{path}}#{{fragment}}",
"sleap": "https://sleap.ai/{{path}}#{{fragment}}",
"sleap-docs": "https://docs.sleap.ai/latest/{{path}}#{{fragment}}",
"sphinx-doc": "https://www.sphinx-doc.org/en/master/usage/{{path}}#{{fragment}}",
"sphinx-gallery": "https://sphinx-gallery.github.io/stable/{{path}}#{{fragment}}",
"xarray": "https://docs.xarray.dev/en/stable/{{path}}#{{fragment}}",
"lp": "https://lightning-pose.readthedocs.io/en/stable/{{path}}#{{fragment}}",
"via": "https://www.robots.ox.ac.uk/~vgg/software/via/{{path}}#{{fragment}}",
"anipose": "https://anipose.readthedocs.io/en/latest/",
"TRex": "https://trex.run/docs/",
"uv": "https://docs.astral.sh/uv/{{path}}#{{fragment}}",
"attrs": "https://www.attrs.org/en/stable/{{path}}#{{fragment}}",
"pytest-benchmark": "https://pytest-benchmark.readthedocs.io/en/latest/{{path}}#{{fragment}}",
}
intersphinx_mapping = {
"xarray": ("https://docs.xarray.dev/en/stable/", None),
"scipy": ("https://docs.scipy.org/doc/scipy/", None),
"pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None),
"python": ("https://docs.python.org/3", None),
"loguru": ("https://loguru.readthedocs.io/en/stable/", None),
"pynwb": ("https://pynwb.readthedocs.io/en/stable/", None),
"matplotlib": ("https://matplotlib.org/stable/", None),
"numpy": ("https://numpy.org/doc/stable/", None),
"attrs": ("https://www.attrs.org/en/stable/", None),
"shapely": ("https://shapely.readthedocs.io/en/stable/", None),
}
# What to show on the 404 page
notfound_context = {
"title": "Page Not Found",
"body": """
<h1>Page Not Found</h1>
<p>Sorry, we couldn't find that page.</p>
<p>
We occasionally restructure the movement website,
and some links may have broken.
</p>
<p>Try using the search box or go to the homepage.</p>
""",
}
# Static files live in /<version>/_static/, but GH pages expects a single
# 404.html at root, so use latest version for all static asset URLs in 404 page
notfound_urls_prefix = "/latest/"