|
5 | 5 |
|
6 | 6 | # -- Project information ----------------------------------------------------- |
7 | 7 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information |
8 | | - |
9 | 8 | import os |
10 | 9 | import sys |
| 10 | +from importlib.metadata import version |
11 | 11 | from pathlib import Path |
12 | 12 |
|
| 13 | +from docs.source.docs_utils.tutorials import generate_tutorial_links_for_notebook_creation |
| 14 | + |
13 | 15 | conf_dir = os.path.dirname(os.path.abspath(__file__)) # noqa: PTH100, PTH120 |
14 | 16 |
|
15 | 17 | sys.path.insert(0, conf_dir) |
16 | 18 |
|
17 | 19 | from docs_utils.skip_members import skip_member # noqa: E402 |
18 | | -from docs_utils.tutorials import generate_tutorial_links_for_notebook_creation # noqa: E402 |
| 20 | +from docs_utils.versions_generator import generate_versions_json # noqa: E402 |
19 | 21 |
|
20 | 22 | project = "AutoIntent" |
21 | 23 | copyright = "2024, DeepPavlov" |
|
44 | 46 | "sphinx_copybutton", |
45 | 47 | "nbsphinx", |
46 | 48 | "sphinx.ext.intersphinx", |
| 49 | + "sphinx_multiversion", |
47 | 50 | ] |
48 | 51 |
|
49 | 52 | templates_path = ["_templates"] |
|
81 | 84 |
|
82 | 85 | html_theme = "pydata_sphinx_theme" |
83 | 86 | html_static_path = ["../_static"] |
| 87 | +version = version("autointent").replace("dev", "") # may differ |
| 88 | + |
| 89 | +BASE_URL = "https://deeppavlov.github.io/AutoIntent/versions" |
| 90 | +BASE_STATIC_URL = f"{BASE_URL}/dev/_static" |
84 | 91 |
|
85 | 92 | html_theme_options = { |
86 | 93 | "logo": { |
87 | 94 | "text": "AutoIntent", |
88 | | - "image_light": "../_static/logo-light.svg", |
89 | | - "image_dark": "../_static/logo-dark.svg", |
| 95 | + "image_light": f"{BASE_STATIC_URL}/logo-light.svg", |
| 96 | + "image_dark": f"{BASE_STATIC_URL}/logo-dark.svg", |
90 | 97 | }, |
91 | 98 | "icon_links": [ |
92 | 99 | { |
|
98 | 105 | { |
99 | 106 | "name": "HuggingFace", |
100 | 107 | "url": "https://huggingface.co/AutoIntent", |
101 | | - "icon": "../_static/hf-logo.svg", |
| 108 | + "icon": f"{BASE_STATIC_URL}/hf-logo.svg", |
102 | 109 | "type": "local", |
103 | 110 | }, |
104 | 111 | ], |
| 112 | + "switcher": { |
| 113 | + "json_url": f"{BASE_STATIC_URL}/versions.json", |
| 114 | + "version_match": version, |
| 115 | + }, |
| 116 | + "navbar_start": ["navbar-logo", "version-switcher"], |
105 | 117 | "show_toc_level": 3, |
106 | 118 | } |
107 | 119 |
|
108 | | -html_favicon = "../_static/logo-white.svg" |
| 120 | +html_favicon = f"{BASE_STATIC_URL}/logo-white.svg" |
109 | 121 | html_show_sourcelink = False |
110 | 122 |
|
111 | 123 | toc_object_entries_show_parents = "hide" |
|
133 | 145 |
|
134 | 146 | mathjax_path = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" |
135 | 147 |
|
| 148 | +# sphinx_multiversion |
| 149 | +# Whitelist for tags matching v1.0.0, v2.1.0 format |
| 150 | +# smv_tag_whitelist = r'^v\d+\.\d+\.\d+$' |
| 151 | +smv_tag_whitelist = r"^.*$" |
| 152 | + |
| 153 | +# Whitelist for the dev branch |
| 154 | +smv_branch_whitelist = r"^dev$" |
| 155 | + |
| 156 | +# Output format (keeping your current format) |
| 157 | +smv_outputdir_format = "versions/{ref.name}" |
| 158 | + |
| 159 | +# Include both tags and dev branch as released |
| 160 | +smv_released_pattern = r"^(refs/tags/.*|refs/heads/dev)$" |
| 161 | + |
| 162 | +smv_remote_whitelist = r"^(origin|upstream)$" # Use branches from origin and upstream |
| 163 | + |
| 164 | +repo_root = Path(__file__).resolve().parents[2] # if conf.py is in docs/ |
| 165 | + |
136 | 166 |
|
137 | 167 | def setup(app) -> None: # noqa: ANN001 |
| 168 | + generate_versions_json(repo_root, BASE_URL) |
| 169 | + |
138 | 170 | generate_tutorial_links_for_notebook_creation( |
139 | 171 | include=[ |
140 | 172 | ( |
|
0 commit comments