-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconf.py
198 lines (166 loc) · 5.31 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
# 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
import datetime
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = "TinyStan"
year = datetime.date.today().year
copyright = f"{year}, TinyStan Developers"
author = "TinyStan Developers"
import os
import tinystan
most_recent_release = "v" + tinystan.__version__
version = os.getenv("TS_DOCS_VERSION", most_recent_release)
if version == "latest":
# don't display a version number for "latest" docs
switcher_version = "latest"
release = ""
else:
release = version.strip("v")
switcher_version = version
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = [
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
"sphinx.ext.autodoc",
"sphinx.ext.githubpages",
"sphinx_copybutton",
"nbsphinx",
"sphinx.ext.mathjax",
"myst_parser",
]
myst_enable_extensions = ["substitution"]
myst_substitutions = {"most_recent_release": most_recent_release}
suppress_warnings = ["myst.xref_missing"] # Julia doc generates raw html links
templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "README.md", "languages/_*"]
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = "pydata_sphinx_theme"
html_static_path = ["_static"]
html_css_files = [
"css/Documenter.css",
"css/custom.css",
]
# html_favicon = "_static/image/favicon.ico"
html_show_sphinx = False
html_theme_options = {
"icon_links": [
{
"name": "GitHub",
"url": "https://github.com/WardBrian/tinystan",
"icon": "fab fa-github",
},
{
"name": "Forums",
"url": "https://discourse.mc-stan.org/",
"icon": "fas fa-users",
},
],
"use_edit_page_button": True,
"switcher": {
"json_url": "https://raw.githubusercontent.com/WardBrian/tinystan/main/docs/_static/switcher.json",
"version_match": switcher_version,
},
"logo": {
"text": "TinyStan " + release if release else "TinyStan",
# "image_light": "_static/image/icon.png",
# "image_dark": "_static/image/icon_w.png",
"alt_text": "TinyStan - Home",
},
"navbar_end": ["theme-switcher", "navbar-icon-links", "version-switcher"],
}
html_context = {
"github_user": "WardBrian",
"github_repo": "tinystan",
"github_version": "main",
"doc_path": "docs",
}
latex_logo = "_static/image/logo.pdf"
intersphinx_mapping = {
"python": (
"https://docs.python.org/3/",
None,
),
"numpy": ("https://numpy.org/doc/stable/", None),
"cmdstanpy": ("https://mc-stan.org/cmdstanpy/", None),
"bridgestan": ("https://roualdes.github.io/bridgestan/latest/", None),
}
breathe_projects = {"tinystan": "./_build/cppxml/"}
breathe_projects_source = {"tinystan": ("../src/", ["tinystan.h"])}
breathe_default_project = "tinystan"
# doxygen doesn't like __attribute and __declspec
# https://www.doxygen.nl/manual/preprocessing.html
breathe_doxygen_config_options = {
"ENABLE_PREPROCESSING": "YES",
"MACRO_EXPANSION": "YES",
"EXPAND_ONLY_PREDEF": "YES",
"PREDEFINED": "TINYSTAN_PUBLIC=",
}
autoclass_content = "both"
import os
import subprocess
import pathlib
RUNNING_IN_CI = os.environ.get("CI") or os.environ.get("READTHEDOCS")
BASE_DIR = pathlib.Path(__file__).parent.parent
try:
print("Building Julia doc")
subprocess.run(
["julia", "--project=.", "./make.jl"],
cwd=BASE_DIR / "clients" / "julia" / "docs",
check=True,
)
except Exception as e:
# fail loudly in Github Actions
if RUNNING_IN_CI:
raise e
else:
print("Failed to build julia docs!\n", e)
try:
print("Building R doc")
subprocess.run(
["Rscript", "convert_docs.R"],
cwd=BASE_DIR / "clients" / "R",
check=True,
)
except Exception as e:
# fail loudly in Github Actions
if RUNNING_IN_CI:
raise e
else:
print("Failed to build R docs!\n", e)
try:
print("Checking C++ doc availability")
import breathe
subprocess.run(["doxygen", "-v"], check=True, capture_output=True)
except Exception as e:
if RUNNING_IN_CI:
raise e
else:
print("Breathe/doxygen not installed, skipping C++ Doc")
exclude_patterns += ["languages/c-api.rst"]
else:
extensions.append("breathe")
try:
print("Building JS doc")
yarn = os.getenv("YARN", "yarn").split()
ret = subprocess.run(
yarn + ["--silent", "doc"],
cwd=BASE_DIR / "clients" / "typescript",
check=True,
capture_output=True,
text=True,
)
with open("./languages/js.md", "w") as f:
f.write(ret.stdout)
except Exception as e:
# fail loudly in Github Actions
if RUNNING_IN_CI:
raise e
else:
print("Failed to build JS docs!\n", e)