|
18 | 18 | # add these directories to sys.path here. If the directory is relative to the |
19 | 19 | # documentation root, use os.path.abspath to make it absolute, like shown here. |
20 | 20 | # |
| 21 | + |
| 22 | + |
21 | 23 | import glob |
22 | 24 | import os |
23 | 25 | import shutil |
|
27 | 29 | import pytorch_sphinx_theme2 # type: ignore[import-not-found] |
28 | 30 |
|
29 | 31 | # To let us import ./custom_directives.py |
| 32 | + |
30 | 33 | sys.path.insert(0, os.path.abspath(".")) |
31 | 34 | # -- Project information ----------------------------------------------------- |
32 | 35 |
|
| 36 | + |
33 | 37 | project = "ExecuTorch" |
34 | 38 | copyright = "2024, ExecuTorch" |
35 | 39 | author = "ExecuTorch Contributors" |
|
41 | 45 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom |
42 | 46 | # ones. |
43 | 47 |
|
| 48 | + |
44 | 49 | import os |
45 | 50 | import sys |
46 | 51 |
|
|
78 | 83 |
|
79 | 84 | # Import executorch version |
80 | 85 | # Adopted from PyTorch docs pattern |
| 86 | + |
81 | 87 | from executorch import version as et_version # type: ignore[attr-defined] |
82 | 88 |
|
83 | 89 | executorch_version = str(et_version.__version__) |
84 | 90 |
|
85 | 91 | # Check if this is a release build from environment variable |
86 | 92 | # The workflow sets RELEASE=true for tagged releases, RELEASE=false otherwise |
87 | 93 | # We need to properly parse the string as a boolean (any non-empty string is truthy in Python) |
| 94 | + |
88 | 95 | RELEASE = os.environ.get("RELEASE", "false").lower() == "true" |
89 | 96 |
|
90 | 97 | # The version info for the project you're documenting, acts as replacement for |
91 | 98 | # |version| and |release|, also used in various other places throughout the |
92 | 99 | # built documents. |
93 | 100 | # |
94 | 101 | # The short X.Y version. |
| 102 | + |
95 | 103 | version = "main" |
96 | 104 | # The full version, including alpha/beta/rc tags. |
| 105 | + |
97 | 106 | release = "main" |
98 | 107 |
|
99 | 108 | # Customized html_title here. |
100 | 109 | # Default is " ".join(project, release, "documentation") if not set |
| 110 | + |
101 | 111 | if RELEASE: |
102 | 112 | # Turn 0.8.0a0+a90e907 into 0.8 |
103 | 113 | # Note: the release candidates should no longer have the aHASH suffix, but in any |
104 | 114 | # case we wish to leave only major.minor, even for rc builds. |
| 115 | + |
105 | 116 | version = ".".join(executorch_version.split("+")[0].split(".")[:2]) |
106 | 117 | html_title = " ".join((project, version, "documentation")) |
107 | 118 | release = version |
108 | | - |
109 | 119 | switcher_version = "main" if not RELEASE else version |
110 | 120 |
|
111 | 121 | print(f"executorch_version: {executorch_version}") |
|
153 | 163 | source_dir = sphinx_gallery_conf["examples_dirs"][i] |
154 | 164 |
|
155 | 165 | # Create gallery dirs if it doesn't exist |
| 166 | + |
156 | 167 | os.makedirs(gallery_dir, exist_ok=True) |
157 | 168 |
|
158 | 169 | # Copy .md files from source dir to gallery dir |
| 170 | + |
159 | 171 | for f in glob.glob(os.path.join(source_dir, "*.md")): |
160 | 172 |
|
161 | 173 | shutil.copyfile(f, gallery_dir) |
162 | | - |
163 | 174 | source_suffix = [".rst", ".md"] |
164 | 175 |
|
165 | 176 |
|
|
171 | 182 | # List of patterns, relative to source directory, that match files and |
172 | 183 | # directories to ignore when looking for source files. |
173 | 184 | # This pattern also affects html_static_path and html_extra_path. |
| 185 | + |
174 | 186 | exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "tutorial-template.md"] |
175 | 187 | exclude_patterns += sphinx_gallery_conf["examples_dirs"] |
176 | 188 | exclude_patterns += ["*/index.rst"] |
177 | 189 |
|
178 | 190 | # autosectionlabel throws warnings if section names are duplicated. |
179 | 191 | # The following tells autosectionlabel to not throw a warning for |
180 | 192 | # duplicated section names that are in different documents. |
| 193 | + |
181 | 194 | autosectionlabel_prefix_document = True |
182 | 195 |
|
183 | 196 | # -- Options for HTML output ------------------------------------------------- |
184 | 197 |
|
185 | 198 | # The theme to use for HTML and HTML Help pages. See the documentation for |
186 | 199 | # a list of builtin themes. |
187 | 200 | # |
| 201 | + |
| 202 | + |
188 | 203 | html_theme = "pytorch_sphinx_theme2" |
189 | 204 | html_theme_path = [pytorch_sphinx_theme2.get_html_theme_path()] |
190 | 205 |
|
|
193 | 208 | # documentation. |
194 | 209 | # |
195 | 210 |
|
| 211 | + |
196 | 212 | html_theme_options = { |
197 | 213 | "logo": { |
198 | 214 | "image_light": "_static/img/et-logo.png", |
|
262 | 278 | # Add any paths that contain custom static files (such as style sheets) here, |
263 | 279 | # relative to this directory. They are copied after the builtin static files, |
264 | 280 | # so a file named "default.css" will overwrite the builtin "default.css". |
| 281 | + |
265 | 282 | html_static_path = ["_static"] |
266 | 283 |
|
| 284 | +html_css_files = ["navbar.css"] |
| 285 | + |
267 | 286 | # Add custom 404 page for GitHub Pages |
| 287 | + |
268 | 288 | html_additional_pages = {"404": "404.html"} |
269 | 289 |
|
270 | 290 |
|
271 | 291 | # Example configuration for intersphinx: refer to the Python standard library. |
| 292 | + |
272 | 293 | intersphinx_mapping = { |
273 | 294 | "python": ("https://docs.python.org/", None), |
274 | 295 | "numpy": ("https://numpy.org/doc/stable/", None), |
275 | 296 | "torch": ("https://docs.pytorch.org/docs/stable/", None), |
276 | 297 | } |
277 | 298 |
|
278 | 299 | # Redirects for moved pages |
| 300 | + |
279 | 301 | redirects = { |
280 | 302 | "getting-started-setup": "getting-started.html", |
281 | 303 | "export-overview": "using-executorch-export.html", |
|
304 | 326 |
|
305 | 327 | # Custom directives defintions to create cards on main landing page |
306 | 328 |
|
| 329 | + |
307 | 330 | from custom_directives import ( # type: ignore[import-not-found] |
308 | 331 | CustomCardEnd, |
309 | 332 | CustomCardItem, |
|
0 commit comments