[bfdf16]: / Docs / conf.py

Download this file

387 lines (307 with data), 12.1 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
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
# -- Project information -----------------------------------------------------
import os
import re
import subprocess
import sys
from datetime import datetime
from pathlib import Path
sys.path.insert(0, os.path.abspath("exts"))
sys.path.insert(0, os.path.abspath("tools"))
current_year = os.environ.get("YEAR", datetime.now().year)
project = "AMMR"
copyright = f"{current_year}, AnyBody Technology"
author = "AnyBody Technology"
# language = "fr" # For testing language translations
def tagged_commit():
"""Check if we are on a tagged commit"""
try:
subprocess.check_call(
["git", "describe", "--tags", "--exact-match", "HEAD"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
except subprocess.CalledProcessError:
return False
else:
return True
if tags.has("offline"):
# building offline version
pass
if not tagged_commit() and not tags.has("offline"):
tags.add("draft")
# `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = tags.has("draft")
master_doc = "index"
# -- 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.
extensions = [
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
"sphinx.ext.mathjax",
"sphinx.ext.githubpages",
"myst_parser",
"ammr_directives",
"sphinxext.opengraph",
"sphinx_design",
"sphinx_togglebutton",
"sphinx_copybutton",
# "sphinxcontrib.youtube",
# "sphinx_copybutton",
# "sphinx_design",
# "sphinx_examples",
# "sphinx_tabs.tabs",
# "sphinx_togglebutton",
# "sphinxcontrib.bibtex",
# "sphinxext.opengraph",
# For the kitchen sink
# "sphinx.ext.todo",
]
myst_enable_extensions = [
"colon_fence",
"deflist",
"fieldlist",
"dollarmath",
"amsmath",
"html_image",
"substitution",
"attrs_inline",
]
# Add any paths that contain templates here, relative to this directory.
# templates_path = ["_templates"]
source_suffix = [".rst", ".md"]
# 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",
"README.md",
"Thumbs.db",
".DS_Store",
"exts",
"auto_examples",
".pixi",
]
# The name of the Pygments (syntax highlighting) style to use.
highlight_language = "AnyScriptDoc"
pygments_style = "AnyScript"
ams_version = os.environ.get("AMS_VERSION", "8.1.0")
if not re.match(r"^\d\.\d\.\d", ams_version):
raise ValueError("Wrong format for AMS version, environment variable")
ams_version_short = ams_version.rpartition(".")[0]
ams_version_x = ams_version_short + ".x"
ammr_version = os.environ.get("AMMR_VERSION", None)
if ammr_version is None:
AMMR_VERSION_RE = re.compile(r'.*AMMR_VERSION\s"(?P<version>.*)"')
with open("../AMMR.version.any") as fh:
match = AMMR_VERSION_RE.search(fh.read())
if match:
ammr_version = match.groupdict()["version"]
else:
raise Exception("Could not parse AMMR version")
if not re.match(r"^\d\.\d\.\d", ammr_version):
raise ValueError("Wrong format for AMMR version, environment variable")
ammr_version_short = ammr_version.rpartition(".")[0]
rst_epilog = f"""
.. |AMS| replace:: AnyBody Modeling System™
.. |AMS_VERSION_X| replace:: {ams_version_x}
.. |AMS_VERSION| replace:: {ams_version}
.. |AMS_VERSION_SHORT| replace:: {ams_version_short}
.. |AMMR_VERSION_SHORT| replace:: {ammr_version_short}
.. |AMMR_VERSION| replace:: {ammr_version}
.. |AMMR_DEMO_INST_DIR| replace:: :literal:`~/Documents/{ams_version_x}/AMMR.v{ammr_version}-Demo`
.. |CURRENT_YEAR| replace:: {current_year}
.. |WHAT_IS_NEW| replace:: :ref:`What's new in AMMR {ammr_version} <whats-new>`
.. |DOI| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.10527958.svg
:target: https://doi.org/10.5281/zenodo.10527958
"""
myst_substitutions = {
"AMS": "AnyBody Modeling System™",
"AMS_VERSION_X": ams_version_x,
"AMS_VERSION": ams_version_x,
"AMS_VERSION_SHORT": ams_version_short,
"AMMR_VERSION_SHORT": ams_version_short,
"AMMR_VERSION": ammr_version,
"CURRENT_YEAR": current_year,
"AMMR_DEMO_INST_DIR": f"`~/Documents/{ams_version_x}/AMMR.v{ammr_version}-Demo`",
"DOI": "[![DOI image](https://zenodo.org/badge/DOI/10.5281/zenodo.10527958.svg)](https://doi.org/10.5281/zenodo.10527958)",
"WHAT_IS_NEW": f"{{ref}}`What's new in AMMR {ammr_version} <whats-new>`",
"WHAT_IS_NEW2": f"{{material-outlined}}`update;1em` New in AMMR {ammr_version}",
}
no_index = """
.. meta::
:robots: noindex
"""
myst_html_meta = {}
if tags.has("draft"):
rst_epilog = rst_epilog + no_index
myst_html_meta["robots"] = "noindex"
github_doc_root = "https://github.com/AnyBody/ammr/tree/master/Docs"
version = f"{ammr_version_short}"
# The full version, including alpha/beta/rc tags.
release = f"{ammr_version}"
if tags.has("draft") and not release.endswith("beta"):
release = release + "-beta"
# suppress_warnings = ["myst.domains", "ref.ref"]
numfig = True
# -- 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_book_theme"
# html_logo = "_static/logo-wide.svg"
html_title = f"{project} v{release} Documentation"
html_copy_source = False
# html_favicon = "_static/logo-square.svg"
html_last_updated_fmt = ""
# html_sidebars = {
# "reference/blog/*": [
# "navbar-logo.html",
# "search-field.html",
# "ablog/postcard.html",
# "ablog/recentposts.html",
# "ablog/tagcloud.html",
# "ablog/categories.html",
# "ablog/archives.html",
# "sbt-sidebar-nav.html",
# ]
# }
# 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", "body/_static"]
html_css_files = ["_static/custom.css"]
html_logo = "_static/AMMR.svg"
html_favicon = "_static/favicon.ico"
html_theme_options = {
"path_to_docs": "Docs",
"repository_url": "https://github.com/anybody/ammr",
"repository_branch": "master",
"use_edit_page_button": True,
"use_source_button": True,
"use_issues_button": False,
"use_repository_button": True,
"use_download_button": False,
"home_page_in_toc": False,
"show_toc_level": 1,
"pygment_light_style": "AnyScript",
"pygment_dark_style": "stata-dark",
# "use_sidenotes": True,
# "announcement": (
# "⚠️The latest release refactored our HTML, "
# "so double-check your custom CSS rules!⚠️"
# ),
"logo": {
"image_dark": "_static/AMMR.svg",
# "text": html_title, # Uncomment to try text with logo
},
"icon_links": [
# {
# "name": "AnyBody Technology",
# "url": "https://anybodytech.com/",
# # "icon": "_static/ebp-logo.png",
# "type": "local",
# },
# {
# "name": "GitHub",
# "url": "https://github.com/anybody/ammr",
# "icon": "fa-brands fa-github",
# },
],
# For testing
# "use_fullscreen_button": False,
# "home_page_in_toc": True,
# "extra_footer": "<a href='https://google.com'>Test</a>", # DEPRECATED KEY
# "show_navbar_depth": 2,
# Testing layout areas
# "navbar_start": ["test.html"],
# "navbar_center": ["test.html"],
# "navbar_end": ["test.html"],
# "navbar_persistent": ["test.html"],
# "footer_start": ["test.html"],
# "footer_end": ["test.html"]
}
bibtex_bibfiles = ["references.bib"]
# To test that style looks good with common bibtex config
bibtex_reference_style = "author_year"
bibtex_default_style = "plain"
numpydoc_show_class_members = False # for automodule:: urllib.parse stub file issue
linkcheck_ignore = [
"http://someurl/release", # This is a fake link
"https://doi.org", # These don't resolve properly and cause SSL issues
]
intersphinx_mapping = {}
if tags.has("offline"):
# Todo. Find a way to link to offline html versions.
intersphinx_mapping["tutorials"] = ("https://anyscript.org/tutorials/", None)
else:
if tags.has("draft"):
intersphinx_mapping["tutorials"] = (
"https://anyscript.org/tutorials/beta/",
None,
)
else:
intersphinx_mapping["tutorials"] = ("https://anyscript.org/tutorials/", None)
# sphinxext.opengraph
# ogp_social_cards = {
# "image": "_static/logo-square.png",
# }
ogp_site_url = "https://anyscript.org/"
ogp_site_name = "AMMR Documentation"
ogp_image = "https://anyscript.org/ammr/_static/AMMR_Logo.png"
ogp_use_first_image = True # if not found defaults to 'ogp_image'
# Generate gallery files
import frontmatter
import jinja2
gallery = {}
galleryfolders = [x for x in Path("Applications").iterdir() if x.is_dir()]
for folder in galleryfolders:
gallery[folder] = []
for file in sorted(folder.glob("*.md"), key=lambda x: x.name.upper()):
post = frontmatter.load(file)
if "gallery_title" in post:
gallery[folder].append(
{
"doc": file.with_suffix("").as_posix(),
"title": post["gallery_title"],
"image": post["gallery_image"],
}
)
with open("Applications/gallery.txt.jinja2") as fh:
gallery_template = jinja2.Template(fh.read())
for folder, section in gallery.items():
gallery_txt = folder / "gallery.txt"
content = gallery_template.render(examples=section)
with open(gallery_txt, encoding="utf8") as fh:
previous_content = fh.read()
if content != previous_content:
with open(gallery_txt, "w", encoding="utf8") as fh:
fh.write(content)
# Run the python file "tools/generate_class_template_docs.py"
# to generate the class template documentation
import generate_class_template_docs
generate_class_template_docs.run_all()
user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
linkcheck_ignore = [
r".*linkcheck_ignore",
"https://doi.org/10.1115/1.4037100", # asme.org prevents the linkcheck
"https://doi.org/10.1115/1.4052115", # asme.org prevents the linkcheck
"https://dx.doi.org/10.1115/1.4001678", # asme.org prevents the linkcheck
"https://dx.doi.org/10.1115/1.4029258", # asme.org prevents the linkcheck
"https://doi.org/10.1080/10255842.2020.1851367", # tandfonline.com prevents the linkcheck
"https://dx.doi.org/10.1002/jor.20255", # wiley.com prevents the linkcheck
"https://doi.org/10.1016/j.clinbiomech.2006.10.003", # clinbiomech.com prevents the linkcheck
"https://doi.org/10.1002/jor.25267", # wiley.com prevents the linkcheck
"https://web.archive.org*", # web.archive.org is currently down due to hacking atacks
"https://doi.org/10.5281/zenodo.15094590", # version not released yet
]
linkcheck_allowed_redirects = {
"https://doi.org.*": ".*",
"https://dx.doi.org.*": ".*",
"https://www.anybodytech.com/download/anybodysetup.*": ".*",
}
def setup(app):
...