|
76 | 76 |
|
77 | 77 | html_favicon = "_static/img/executorch-chip-logo.svg" |
78 | 78 |
|
79 | | -# Get ET_VERSION_DOCS during the build. |
80 | | -et_version_docs = os.environ.get("ET_VERSION_DOCS", None) |
81 | | -print(f"et_version_docs: {et_version_docs}") |
82 | | - |
83 | | -# The code below will cut version displayed in the dropdown like this: |
84 | | -# By default, set to "main". |
85 | | -# If it's a tag like refs/tags/v1.2.3-rc4 or refs/tags/v1.2.3, then |
86 | | -# cut to 1.2 |
87 | | -# the version varible is used in layout.html: https://github.com/pytorch/executorch/blob/main/docs/source/_templates/layout.html#L29 |
88 | | -version = release = "main" |
89 | | -if et_version_docs: |
90 | | - if et_version_docs.startswith("refs/tags/v"): |
91 | | - version = ".".join( |
92 | | - et_version_docs.split("/")[-1].split("-")[0].lstrip("v").split(".")[:2] |
93 | | - ) |
94 | | - elif et_version_docs.startswith("refs/heads/release/"): |
95 | | - version = et_version_docs.split("/")[-1] |
96 | | -print(f"Version: {version}") |
97 | | -html_title = " ".join((project, version, "documentation")) |
| 79 | +# Import executorch version |
| 80 | +# Adopted from PyTorch docs pattern |
| 81 | +from executorch import version as et_version # type: ignore[attr-defined] |
| 82 | + |
| 83 | +executorch_version = str(et_version.__version__) |
| 84 | + |
| 85 | +# Check if this is a release build from environment variable |
| 86 | +# The workflow sets RELEASE=true for tagged releases, RELEASE=false otherwise |
| 87 | +# We need to properly parse the string as a boolean (any non-empty string is truthy in Python) |
| 88 | +RELEASE = os.environ.get("RELEASE", "false").lower() == "true" |
| 89 | + |
| 90 | +# The version info for the project you're documenting, acts as replacement for |
| 91 | +# |version| and |release|, also used in various other places throughout the |
| 92 | +# built documents. |
| 93 | +# |
| 94 | +# The short X.Y version. |
| 95 | +version = "main" |
| 96 | +# The full version, including alpha/beta/rc tags. |
| 97 | +release = "main" |
| 98 | + |
| 99 | +# Customized html_title here. |
| 100 | +# Default is " ".join(project, release, "documentation") if not set |
| 101 | +if RELEASE: |
| 102 | + # Turn 0.8.0a0+a90e907 into 0.8 |
| 103 | + # Note: the release candidates should no longer have the aHASH suffix, but in any |
| 104 | + # case we wish to leave only major.minor, even for rc builds. |
| 105 | + version = ".".join(executorch_version.split("+")[0].split(".")[:2]) |
| 106 | + html_title = " ".join((project, version, "documentation")) |
| 107 | + release = version |
| 108 | + |
| 109 | +switcher_version = "main" if not RELEASE else version |
| 110 | + |
| 111 | +print(f"executorch_version: {executorch_version}") |
| 112 | +print(f"Version: {version}, RELEASE: {RELEASE}") |
98 | 113 |
|
99 | 114 | html_baseurl = "https://docs.pytorch.org/executorch/" # needed for sphinx-sitemap |
100 | 115 | sitemap_locales = [None] |
|
176 | 191 | # documentation. |
177 | 192 | # |
178 | 193 |
|
179 | | -switcher_version = version |
180 | | - |
181 | 194 | html_theme_options = { |
182 | 195 | "logo": { |
183 | 196 | "image_light": "_static/img/et-logo.png", |
|
242 | 255 | "display_version": True, |
243 | 256 | } |
244 | 257 |
|
| 258 | + |
245 | 259 | # Add any paths that contain custom static files (such as style sheets) here, |
246 | 260 | # relative to this directory. They are copied after the builtin static files, |
247 | 261 | # so a file named "default.css" will overwrite the builtin "default.css". |
|
0 commit comments