summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Schulz <quentin.schulz@theobroma-systems.com>2022-04-20 17:04:43 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-04-20 17:25:33 +0100
commitee6718fe086cdb50b2acda9eab7a3f030478bed2 (patch)
treeb6eabd91c0c0acae87132715fe0681ef82d1e8a6
parent63e717738fb658432de63666e6d0d2790eaf5c88 (diff)
downloadpoky-ee6718fe086cdb50b2acda9eab7a3f030478bed2.tar.gz
docs: sphinx-static: switchers.js.in: fix broken switcher for branches
The switcher expects URL subpath to match the "release" used by sphinx to build the documentation. Branches, however, are put in a subpath after their name (e.g. dunfell) while sphinx sets the "release" to X.Y.999. This means the switcher cannot replace correctly the path to switch between releases/versions. Let set_versions.py inject the list of release names into the switchers.js.in file so it can check whether the subpath is one of the release names in which case it needs to be stripped. Cc: Quentin Schulz <foss+yocto@0leil.net> (From yocto-docs rev: 5ef3d129b8d0d8ae98a694103930988a46285525) Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xdocumentation/set_versions.py3
-rw-r--r--documentation/sphinx-static/switchers.js.in12
2 files changed, 15 insertions, 0 deletions
diff --git a/documentation/set_versions.py b/documentation/set_versions.py
index fc179ee195..261c1eeb37 100755
--- a/documentation/set_versions.py
+++ b/documentation/set_versions.py
@@ -203,6 +203,9 @@ versions = []
203with open("sphinx-static/switchers.js.in", "r") as r, open("sphinx-static/switchers.js", "w") as w: 203with open("sphinx-static/switchers.js.in", "r") as r, open("sphinx-static/switchers.js", "w") as w:
204 lines = r.readlines() 204 lines = r.readlines()
205 for line in lines: 205 for line in lines:
206 if "ALL_RELEASES_PLACEHOLDER" in line:
207 w.write(str(list(release_series.keys())))
208 continue
206 if "VERSIONS_PLACEHOLDER" in line: 209 if "VERSIONS_PLACEHOLDER" in line:
207 w.write(" 'dev': { 'title': 'dev (%s)', 'obsolete': false,},\n" % release_series[devbranch]) 210 w.write(" 'dev': { 'title': 'dev (%s)', 'obsolete': false,},\n" % release_series[devbranch])
208 for branch in activereleases + ([ourseries] if ourseries not in activereleases else []): 211 for branch in activereleases + ([ourseries] if ourseries not in activereleases else []):
diff --git a/documentation/sphinx-static/switchers.js.in b/documentation/sphinx-static/switchers.js.in
index 7eb0c2ff34..1e523a188f 100644
--- a/documentation/sphinx-static/switchers.js.in
+++ b/documentation/sphinx-static/switchers.js.in
@@ -9,6 +9,10 @@ by https://git.yoctoproject.org/yocto-autobuilder-helper/tree/scripts/run-docs-b
9(function() { 9(function() {
10 'use strict'; 10 'use strict';
11 11
12 var all_releases =
13 ALL_RELEASES_PLACEHOLDER
14 ;
15
12 var switcher_versions = { 16 var switcher_versions = {
13 VERSIONS_PLACEHOLDER 17 VERSIONS_PLACEHOLDER
14 }; 18 };
@@ -155,6 +159,14 @@ by https://git.yoctoproject.org/yocto-autobuilder-helper/tree/scripts/run-docs-b
155 var new_url = docroot + new_versionpath + url.replace(docroot, ""); 159 var new_url = docroot + new_versionpath + url.replace(docroot, "");
156 var fallback_url = docroot + new_versionpath; 160 var fallback_url = docroot + new_versionpath;
157 } else { 161 } else {
162 // check for named releases (e.g. dunfell) in the subpath
163 $.each(all_releases, function(idx, release) {
164 if (docroot.endsWith('/' + release + '/')) {
165 current_version = release;
166 return false;
167 }
168 });
169
158 var new_url = url.replace('/' + current_version + '/', '/' + new_versionpath); 170 var new_url = url.replace('/' + current_version + '/', '/' + new_versionpath);
159 var fallback_url = new_url.replace(url.replace(docroot, ""), ""); 171 var fallback_url = new_url.replace(url.replace(docroot, ""), "");
160 } 172 }