|
11 | 11 | # documentation root, use os.path.abspath to make it absolute, like shown here. |
12 | 12 | import os |
13 | 13 | import sys |
| 14 | +import shutil |
| 15 | +from sphinx_polyversion import load |
| 16 | +from sphinx_polyversion.git import GitRef |
14 | 17 |
|
15 | 18 | sys.path.insert(0, os.path.abspath("../..")) |
16 | 19 |
|
|
87 | 90 | # Add any paths that contain custom _static files (such as style sheets) here, |
88 | 91 | # relative to this directory. They are copied after the builtin _static files, |
89 | 92 | # so a file named "default.css" will overwrite the builtin "default.css". |
90 | | -# html_static_path = ["css/custom.css"] |
| 93 | +html_static_path = ["_static"] |
| 94 | +html_css_files = ["custom.css"] |
91 | 95 | html_show_sourcelink = False |
92 | 96 | html_theme_options = { |
93 | 97 | "repository_url": "https://github.com/bayesflow-org/bayesflow", |
|
102 | 106 | html_favicon = "_static/bayesflow_hex.ico" |
103 | 107 | html_baseurl = "https://www.bayesflow.org/" |
104 | 108 | html_js_files = ["https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"] |
| 109 | +html_sidebars = { |
| 110 | + "**": [ |
| 111 | + "navbar-logo.html", |
| 112 | + "icon-links.html", |
| 113 | + "search-button-field.html", |
| 114 | + "sbt-sidebar-nav.html", |
| 115 | + "versioning.html", |
| 116 | + ], |
| 117 | +} |
105 | 118 |
|
106 | 119 | todo_include_todos = True |
107 | 120 |
|
|
120 | 133 | remove_from_toctrees = ["_autosummary/*"] |
121 | 134 |
|
122 | 135 | autosummmary_generate = True |
| 136 | + |
| 137 | +# sphinx-multiversion: select tags, branches and remotes |
| 138 | +smv_tag_whitelist = r"^(v1.1.6)$" |
| 139 | +# smv_branch_whitelist = r"^(|doc-autosummary|master|dev)$" |
| 140 | +smv_branch_whitelist = r"^(master)$" |
| 141 | +smv_remote_whitelist = None |
| 142 | + |
| 143 | + |
| 144 | +# move files around if necessary |
| 145 | +def copy_files_handler(app, config): |
| 146 | + print("TODO") |
| 147 | + return |
| 148 | + current_version = config["smv_current_version"] |
| 149 | + current_metadata = config["smv_metadata"][current_version] |
| 150 | + basedir = current_metadata["basedir"] |
| 151 | + sourcedir = current_metadata["sourcedir"] |
| 152 | + |
| 153 | + print("Current version:", current_version) |
| 154 | + print("Basedir:", basedir) |
| 155 | + print("Metadata:", current_metadata) |
| 156 | + |
| 157 | + examples_src = os.path.join(basedir, "examples") |
| 158 | + examples_dst = os.path.join(sourcedir, "_examples") |
| 159 | + if os.path.exists(examples_src): |
| 160 | + shutil.copytree(examples_src, examples_dst, dirs_exist_ok=True) |
| 161 | + examples_in_progress = os.path.join(examples_dst, "in_progress") |
| 162 | + if os.path.exists(examples_in_progress): |
| 163 | + shutil.rmtree(examples_in_progress) |
| 164 | + contributing_src = os.path.join(basedir, "CONTRIBUTING.md") |
| 165 | + contributing_dst = os.path.join(sourcedir, "contributing.md") |
| 166 | + if os.path.exists(contributing_src): |
| 167 | + shutil.copy2(contributing_src, contributing_dst) |
| 168 | + installation_src = os.path.join(basedir, "INSTALL.rst") |
| 169 | + installation_dst = os.path.join(sourcedir, "installation.rst") |
| 170 | + if os.path.exists(installation_src): |
| 171 | + shutil.copy2(installation_src, installation_dst) |
| 172 | + |
| 173 | + |
| 174 | +def cleanup_handler(app, exception): |
| 175 | + print("Done, what now?") |
| 176 | + |
| 177 | + |
| 178 | +def setup(app): |
| 179 | + app.connect("config-inited", copy_files_handler) |
| 180 | + app.connect("build-finished", cleanup_handler) |
| 181 | + |
| 182 | + |
| 183 | +data = load(globals()) |
| 184 | +current: GitRef = data["current"] |
0 commit comments