Skip to contentSkip to conversation

Makefile: Use switchers generated from master

PATCH In review Richard Purdie 3 participants 10 messages Mar 19, 2022 – Mar 22, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Makefile: Use switchers generated from master

This allows an improved and custmomised switcher for each release showing the current doc version, the latest in that series and the latest releases for the project overall.

---
 documentation/.gitignore                 |   1 +
 documentation/Makefile                   |   9 +-
 documentation/sphinx-static/switchers.js | 233 -----------------------
 3 files changed, 9 insertions(+), 234 deletions(-)
 delete mode 100644 documentation/sphinx-static/switchers.js
documentation/.gitignore +1 -0
index c1e43630d..f7d91141a 100644
@@ -1,2 +1,3 @@
 _build/
 sphinx/__pycache__/
+sphinx-static/switchers.js
\ No newline at end of file
documentation/Makefile +8 -1
index 564a906e2..433e880c4 100644
@@ -8,9 +8,16 @@ TRANSITIONS   = $(sort $(patsubst $(SOURCEDIR)/transition/%/index.rst,%,$(wildca
 
 .PHONY: Makefile publish transition clean $(TRANSITIONS)
 
+sphinx-static/switchers.js.in:
+	git checkout master sphinx-static/switchers.js.in
+
+set_versions.py:
+	git checkout master set_versions.py
+
 transition: $(TRANSITIONS)
 
-$(TRANSITIONS):
+$(TRANSITIONS): sphinx-static/switchers.js.in set_versions.py
+	./set_versions.py $@
 	@$(SPHINXBUILD) -M html "$(SOURCEDIR)"/transition/$@/ "$(BUILDDIR)"/$@ $(SPHINXOPTS) $(O) -c "$(SOURCEDIR)"
 
 publish: transition
documentation/sphinx-static/switchers.js deleted +0 -233

233 lines not on this page · raw message

Signature · 1 line
2.32.0
#1 lore raw

PATCH 1/2 set_versions/switchers.js: Allow switchers.js version information to be autogenerated

A horrible blunt hammer approach to updating the version information in switchers.js based on the available tag information.

To merge and work correctly, this will need a change to the autobuilder-helper docs generation code to pull the swicthers.js and script from master, then to run the script. That should hopefully remove the need for other patching even on old docs branches though.

---
 documentation/.gitignore                      |  1 +
 documentation/set_versions.py                 | 20 +++++++++++++++++++
 .../{switchers.js => switchers.js.in}         |  8 +-------
 3 files changed, 22 insertions(+), 7 deletions(-)
 rename documentation/sphinx-static/{switchers.js => switchers.js.in} (97%)
documentation/.gitignore +1 -0
index e5e2c1708..096b97ec2 100644
@@ -1,6 +1,7 @@
 _build/
 Pipfile.lock
 poky.yaml
+sphinx-static/switchers.js
 .vscode/
 */svg/*.png
 */svg/*.pdf
documentation/set_versions.py +20 -0
index db94ef5c1..4cdea8f42 100755
@@ -13,6 +13,7 @@ import subprocess
 import collections
 import sys
 
+activereleases = ["honister", "hardknott", "dunfell"]
 devbranch = "kirkstone"
 #devbranch = "langdale"
 ltsseries = ["kirkstone", "dunfell"]
@@ -143,3 +144,22 @@ with open("poky.yaml.in", "r") as r, open("poky.yaml", "w") as w:
             w.write(line)
 
 print("poky.yaml generated from poky.yaml.in")
+
+with open("sphinx-static/switchers.js.in", "r") as r, open("sphinx-static/switchers.js", "w") as w:
+    lines = r.readlines()
+    for line in lines:
+        if "VERSIONS_PLACEHOLDER" in line:
+            w.write("    'dev': 'dev (%s)',\n" % release_series[devbranch])
+            for branch in activereleases:
+                if branch == devbranch:
+                    continue
+                versions = subprocess.run('git tag --list yocto-%s*' % (release_series[branch]), shell=True, capture_output=True, text=True).stdout.split()
+                versions = sorted([v.replace("yocto-" +  release_series[branch] + ".", "").replace("yocto-" +  release_series[branch], "0") for v in versions], key=int)
+                version = release_series[branch]
+                if versions[-1] != "0":
+                    version = version + "." + versions[-1]
+                w.write("    '%s': '%s',\n" % (version, version))
+        else:
+            w.write(line)
+
+print("switchers.js generated from switchers.js.in")
documentation/sphinx-static/switchers.js.in renamed from documentation/sphinx-static/switchers.js +1 -7
similarity index 97%
rename from documentation/sphinx-static/switchers.js
rename to documentation/sphinx-static/switchers.js.in
index 3ea8927d7..5d3a4d793 100644
@@ -10,13 +10,7 @@ by https://git.yoctoproject.org/yocto-autobuilder-helper/tree/scripts/run-docs-b
   'use strict';
 
   var all_versions = {
-    'dev': 'dev (3.5)',
-    '3.4.2': '3.4.2',
-    '3.3.5': '3.3.5',
-    '3.2.4': '3.2.4',
-    '3.1.14': '3.1.14',
-    '3.0.4': '3.0.4',
-    '2.7.4': '2.7.4',
+    VERSIONS_PLACEHOLDER
   };
 
   var all_doctypes = {
Signature · 1 line
2.32.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [docs] [PATCH 1/2] set_versions/switchers.js: Allow switchers.js version information to be autogenerated

Quoted 8 lines · Richard Purdie

A horrible blunt hammer approach to updating the version information in switchers.js based on the available tag information.

To merge and work correctly, this will need a change to the autobuilder-helper docs generation code to pull the swicthers.js and script from master, then to run the script. That should hopefully remove the need for other patching even on old docs branches though.

Quoted 7 lines
---
 documentation/.gitignore                      |  1 +
 documentation/set_versions.py                 | 20 +++++++++++++++++++
 .../{switchers.js => switchers.js.in}         |  8 +-------
 3 files changed, 22 insertions(+), 7 deletions(-)
 rename documentation/sphinx-static/{switchers.js => switchers.js.in} (97%)

Thanks for the patch.

... and merged into master-next.

Thanks again
Michael.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw

PATCH 2/2 set_versions: Various improvements

In reply to Richard Purdie

- Allow specifying the version from the commandline
- Add all previous release series/version mappings (to support transitions branch)
- Add poky mapping for 3.4 as some releases erronously use it
- Improve git branch 'guessing' code to work properly
- Handle poky '.0' release mappings correctly
- Only write poky.yaml if poky.yaml.in exists
- Ensure older non-active releases are shown in the switchers.js release list.
- Ensure current version and current release series are shown in switcher.

---
 documentation/set_versions.py | 119 +++++++++++++++++++++++++---------
 1 file changed, 89 insertions(+), 30 deletions(-)
documentation/set_versions.py +89 -30
index 4cdea8f42..392a48d18 100755
@@ -12,10 +12,16 @@
 import subprocess
 import collections
 import sys
+import os
+import itertools
+
+ourversion = None
+if len(sys.argv) == 2:
+    ourversion = sys.argv[1]
 
 activereleases = ["honister", "hardknott", "dunfell"]
-devbranch = "kirkstone"
 #devbranch = "langdale"
+devbranch = "kirkstone"
 ltsseries = ["kirkstone", "dunfell"]
 
 release_series = collections.OrderedDict()
@@ -25,6 +31,27 @@ release_series["honister"] = "3.4"
 release_series["hardknott"] = "3.3"
 release_series["gatesgarth"] = "3.2"
 release_series["dunfell"] = "3.1"
+release_series["zeus"] = "3.0"
+release_series["warrior"] = "2.7"
+release_series["thud"] = "2.6"
+release_series["sumo"] = "2.5"
+release_series["rocko"] = "2.4"
+release_series["pyro"] = "2.3"
+release_series["morty"] = "2.2"
+release_series["krogoth"] = "2.1"
+release_series["jethro"] = "2.0"
+release_series["jethro-pre"] = "1.9"
+release_series["fido"] = "1.8"
+release_series["dizzy"] = "1.7"
+release_series["daisy"] = "1.6"
+release_series["dora"] = "1.5"
+release_series["dylan"] = "1.4"
+release_series["danny"] = "1.3"
+release_series["denzil"] = "1.2"
+release_series["edison"] = "1.1"
+release_series["bernard"] = "1.0"
+release_series["laverne"] = "0.9"
+
 
 bitbake_mapping = {
     "langdale" : "2.2",
@@ -36,13 +63,14 @@ bitbake_mapping = {
 }
 
 # 3.4 onwards doesn't have poky version
+# Early 3.4 does do reference it though
 poky_mapping = {
+    "3.4" : "26.0",
     "3.3" : "25.0",
     "3.2" : "24.0",
     "3.1" : "23.0",
 }
 
-ourversion = None
 ourseries = None
 ourbranch = None
 bitbakeversion = None
@@ -69,31 +97,38 @@ if ourversion:
         if release_series[i] == baseversion:
             ourseries = i
             ourbranch = i
-            bitbakeversion = bitbake_mapping[i]
+            if i in bitbake_mapping:
+                bitbakeversion = bitbake_mapping[i]
 else:
     # We're floating on a branch
     branch = subprocess.run(["git", "branch", "--show-current"], capture_output=True, text=True).stdout.strip()
     ourbranch = branch
     if branch != "master" and branch not in release_series:
-        possible_branches = []
-        for b in release_series.keys():
-            result = subprocess.run(["git", "show-ref", "heads/" + b], capture_output=True, text=True)
+        # We're not on a known release branch so we have to guess. Compare the numbers of commits
+        # from each release branch and assume the smallest number of commits is the one we're based off
+        possible_branch = None
+        branch_count = 0
+        for b in itertools.chain(release_series.keys(), ["master"]):
+            result = subprocess.run(["git", "log", "--format=oneline",  "HEAD..origin/" + b], capture_output=True, text=True)
             if result.returncode == 0:
-                possible_branches.append(b)
-                continue
-            result = subprocess.run(["git", "show-ref", "origin/" + b], capture_output=True, text=True)
-            if result.returncode == 0:
-                possible_branches.append("origin/" + b)
-        nearestbranch = subprocess.run('git show-branch master ' + ' '.join(possible_branches) + ' | grep "*" | grep -v "$(git rev-parse --abbrev-ref HEAD)" | head -n1', shell=True, capture_output=True, text=True).stdout
-        branch = nearestbranch.split('[')[1].split('~')[0]
-        print("Nearest release branch esimtated to be %s" % branch)
+                count = result.stdout.count('\n')
+                if not possible_branch or count < branch_count:
+                    print("Branch %s has count %s" % (b, count))
+                    possible_branch = b
+                    branch_count = count
+        if possible_branch:
+            branch = possible_branch
+        else:
+            branch = "master"
+        print("Nearest release branch estimated to be %s" % branch)
     if branch == "master":
         ourseries = devbranch
         docconfver = "dev"
         bitbakeversion = ""
     elif branch in release_series:
         ourseries = branch
-        bitbakeversion = bitbake_mapping[branch]
+        if i in bitbake_mapping:
+            bitbakeversion = bitbake_mapping[branch]
     else:
         sys.exit("Unknown series for branch %s" % branch)
 
@@ -111,8 +146,8 @@ else:
         docconfver = ourversion
 
 series = [k for k in release_series]
-previousseries = series[series.index(ourseries)+1:]
-lastlts = [k for k in previousseries if k in ltsseries]
+previousseries = series[series.index(ourseries)+1:] or [""]
+lastlts = [k for k in previousseries if k in ltsseries] or "dunfell"
 
 print("Version calculated to be %s" % ourversion)
 print("Release series calculated to be %s" % ourseries)
@@ -130,21 +165,40 @@ replacements = {
 }
 
 if release_series[ourseries] in poky_mapping:
-    pokyversion = poky_mapping[release_series[ourseries]] + "." + ourversion.rsplit(".", 1)[1]
+    pokyversion = poky_mapping[release_series[ourseries]]
+    if ourversion != release_series[ourseries]:
+        pokyversion = pokyversion + "." + ourversion.rsplit(".", 1)[1]
+    else:
+        pokyversion = pokyversion + ".0"
     replacements["POKYVERSION"] = pokyversion
 
-with open("poky.yaml.in", "r") as r, open("poky.yaml", "w") as w:
-    lines = r.readlines()
-    for line in lines:
-        data = line.split(":")
-        k = data[0].strip()
-        if k in replacements:
-            w.write("%s : \"%s\"\n" % (k, replacements[k]))
-        else:
-            w.write(line)
-
-print("poky.yaml generated from poky.yaml.in")
-
+if os.path.exists("poky.yaml.in"):
+    with open("poky.yaml.in", "r") as r, open("poky.yaml", "w") as w:
+        lines = r.readlines()
+        for line in lines:
+            data = line.split(":")
+            k = data[0].strip()
+            if k in replacements:
+                w.write("%s : \"%s\"\n" % (k, replacements[k]))
+            else:
+                w.write(line)
+
+    print("poky.yaml generated from poky.yaml.in")
+
+
+# In the switcher list of versions we display:
+#  - latest dev
+#  - latest stable release
+#  - latest LTS
+#  - latest for each releases listed as active
+#  - latest doc version in current series
+#  - current doc version
+# (with duplicates removed)
+
+if ourseries not in activereleases:
+    activereleases.append(ourseries)
+
+versions = []
 with open("sphinx-static/switchers.js.in", "r") as r, open("sphinx-static/switchers.js", "w") as w:
     lines = r.readlines()
     for line in lines:
@@ -155,10 +209,15 @@ with open("sphinx-static/switchers.js.in", "r") as r, open("sphinx-static/switch
                     continue
                 versions = subprocess.run('git tag --list yocto-%s*' % (release_series[branch]), shell=True, capture_output=True, text=True).stdout.split()
                 versions = sorted([v.replace("yocto-" +  release_series[branch] + ".", "").replace("yocto-" +  release_series[branch], "0") for v in versions], key=int)
+                if not versions:
+                    continue
                 version = release_series[branch]
                 if versions[-1] != "0":
                     version = version + "." + versions[-1]
+                versions.append(version)
                 w.write("    '%s': '%s',\n" % (version, version))
+            if ourversion not in versions:
+                w.write("    '%s': '%s',\n" % (ourversion, ourversion))
         else:
             w.write(line)
 
Signature · 1 line
2.32.0
Tested-by on v1 2/2
#4 lore raw

Re: [docs] [PATCH 2/2] set_versions: Various improvements

Hi Richard,

Quoted 11 lines · Richard Purdie

- Allow specifying the version from the commandline
- Add all previous release series/version mappings (to support transitions branch)
- Add poky mapping for 3.4 as some releases erronously use it
- Improve git branch 'guessing' code to work properly
- Handle poky '.0' release mappings correctly
- Only write poky.yaml if poky.yaml.in exists
- Ensure older non-active releases are shown in the switchers.js release list.
- Ensure current version and current release series are shown in switcher.

Thanks for the patch!

... and merged into master-next.

Cheers
Michael.

Quoted 212 lines
---
 documentation/set_versions.py | 119 +++++++++++++++++++++++++---------
 1 file changed, 89 insertions(+), 30 deletions(-)
documentation/set_versions.py +89 -31
index 4cdea8f42..392a48d18 100755
@@ -12,10 +12,16 @@
 import subprocess
 import collections
 import sys
+import os
+import itertools
+
+ourversion = None
+if len(sys.argv) == 2:
+    ourversion = sys.argv[1]
 
 activereleases = ["honister", "hardknott", "dunfell"]
-devbranch = "kirkstone"
 #devbranch = "langdale"
+devbranch = "kirkstone"
 ltsseries = ["kirkstone", "dunfell"]
 
 release_series = collections.OrderedDict()
@@ -25,6 +31,27 @@ release_series["honister"] = "3.4"
 release_series["hardknott"] = "3.3"
 release_series["gatesgarth"] = "3.2"
 release_series["dunfell"] = "3.1"
+release_series["zeus"] = "3.0"
+release_series["warrior"] = "2.7"
+release_series["thud"] = "2.6"
+release_series["sumo"] = "2.5"
+release_series["rocko"] = "2.4"
+release_series["pyro"] = "2.3"
+release_series["morty"] = "2.2"
+release_series["krogoth"] = "2.1"
+release_series["jethro"] = "2.0"
+release_series["jethro-pre"] = "1.9"
+release_series["fido"] = "1.8"
+release_series["dizzy"] = "1.7"
+release_series["daisy"] = "1.6"
+release_series["dora"] = "1.5"
+release_series["dylan"] = "1.4"
+release_series["danny"] = "1.3"
+release_series["denzil"] = "1.2"
+release_series["edison"] = "1.1"
+release_series["bernard"] = "1.0"
+release_series["laverne"] = "0.9"
+
 
 bitbake_mapping = {
     "langdale" : "2.2",
@@ -36,13 +63,14 @@ bitbake_mapping = {
 }
 
 # 3.4 onwards doesn't have poky version
+# Early 3.4 does do reference it though
 poky_mapping = {
+    "3.4" : "26.0",
     "3.3" : "25.0",
     "3.2" : "24.0",
     "3.1" : "23.0",
 }
 
-ourversion = None
 ourseries = None
 ourbranch = None
 bitbakeversion = None
@@ -69,31 +97,38 @@ if ourversion:
         if release_series[i] == baseversion:
             ourseries = i
             ourbranch = i
-            bitbakeversion = bitbake_mapping[i]
+            if i in bitbake_mapping:
+                bitbakeversion = bitbake_mapping[i]
 else:
     # We're floating on a branch
     branch = subprocess.run(["git", "branch", "--show-current"], capture_output=True, text=True).stdout.strip()
     ourbranch = branch
     if branch != "master" and branch not in release_series:
-        possible_branches = []
-        for b in release_series.keys():
-            result = subprocess.run(["git", "show-ref", "heads/" + b], capture_output=True, text=True)
+        # We're not on a known release branch so we have to guess. Compare the numbers of commits
+        # from each release branch and assume the smallest number of commits is the one we're based off
+        possible_branch = None
+        branch_count = 0
+        for b in itertools.chain(release_series.keys(), ["master"]):
+            result = subprocess.run(["git", "log", "--format=oneline",  "HEAD..origin/" + b], capture_output=True, text=True)
             if result.returncode == 0:
-                possible_branches.append(b)
-                continue
-            result = subprocess.run(["git", "show-ref", "origin/" + b], capture_output=True, text=True)
-            if result.returncode == 0:
-                possible_branches.append("origin/" + b)
-        nearestbranch = subprocess.run('git show-branch master ' + ' '.join(possible_branches) + ' | grep "*" | grep -v "$(git rev-parse --abbrev-ref HEAD)" | head -n1', shell=True, capture_output=True, text=True).stdout
-        branch = nearestbranch.split('[')[1].split('~')[0]
-        print("Nearest release branch esimtated to be %s" % branch)
+                count = result.stdout.count('\n')
+                if not possible_branch or count < branch_count:
+                    print("Branch %s has count %s" % (b, count))
+                    possible_branch = b
+                    branch_count = count
+        if possible_branch:
+            branch = possible_branch
+        else:
+            branch = "master"
+        print("Nearest release branch estimated to be %s" % branch)
     if branch == "master":
         ourseries = devbranch
         docconfver = "dev"
         bitbakeversion = ""
     elif branch in release_series:
         ourseries = branch
-        bitbakeversion = bitbake_mapping[branch]
+        if i in bitbake_mapping:
+            bitbakeversion = bitbake_mapping[branch]
     else:
         sys.exit("Unknown series for branch %s" % branch)
 
@@ -111,8 +146,8 @@ else:
         docconfver = ourversion
 
 series = [k for k in release_series]
-previousseries = series[series.index(ourseries)+1:]
-lastlts = [k for k in previousseries if k in ltsseries]
+previousseries = series[series.index(ourseries)+1:] or [""]
+lastlts = [k for k in previousseries if k in ltsseries] or "dunfell"
 
 print("Version calculated to be %s" % ourversion)
 print("Release series calculated to be %s" % ourseries)
@@ -130,21 +165,40 @@ replacements = {
 }
 
 if release_series[ourseries] in poky_mapping:
-    pokyversion = poky_mapping[release_series[ourseries]] + "." + ourversion.rsplit(".", 1)[1]
+    pokyversion = poky_mapping[release_series[ourseries]]
+    if ourversion != release_series[ourseries]:
+        pokyversion = pokyversion + "." + ourversion.rsplit(".", 1)[1]
+    else:
+        pokyversion = pokyversion + ".0"
     replacements["POKYVERSION"] = pokyversion
 
-with open("poky.yaml.in", "r") as r, open("poky.yaml", "w") as w:
-    lines = r.readlines()
-    for line in lines:
-        data = line.split(":")
-        k = data[0].strip()
-        if k in replacements:
-            w.write("%s : \"%s\"\n" % (k, replacements[k]))
-        else:
-            w.write(line)
-
-print("poky.yaml generated from poky.yaml.in")
-
+if os.path.exists("poky.yaml.in"):
+    with open("poky.yaml.in", "r") as r, open("poky.yaml", "w") as w:
+        lines = r.readlines()
+        for line in lines:
+            data = line.split(":")
+            k = data[0].strip()
+            if k in replacements:
+                w.write("%s : \"%s\"\n" % (k, replacements[k]))
+            else:
+                w.write(line)
+
+    print("poky.yaml generated from poky.yaml.in")
+
+
+# In the switcher list of versions we display:
+#  - latest dev
+#  - latest stable release
+#  - latest LTS
+#  - latest for each releases listed as active
+#  - latest doc version in current series
+#  - current doc version
+# (with duplicates removed)
+
+if ourseries not in activereleases:
+    activereleases.append(ourseries)
+
+versions = []
 with open("sphinx-static/switchers.js.in", "r") as r, open("sphinx-static/switchers.js", "w") as w:
     lines = r.readlines()
     for line in lines:
@@ -155,10 +209,15 @@ with open("sphinx-static/switchers.js.in", "r") as r, open("sphinx-static/switch
                     continue
                 versions = subprocess.run('git tag --list yocto-%s*' % (release_series[branch]), shell=True, capture_output=True, text=True).stdout.split()
                 versions = sorted([v.replace("yocto-" +  release_series[branch] + ".", "").replace("yocto-" +  release_series[branch], "0") for v in versions], key=int)
+                if not versions:
+                    continue
                 version = release_series[branch]
                 if versions[-1] != "0":
                     version = version + "." + versions[-1]
+                versions.append(version)
                 w.write("    '%s': '%s',\n" % (version, version))
+            if ourversion not in versions:
+                w.write("    '%s': '%s',\n" % (ourversion, ourversion))
         else:
             w.write(line)
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#2646): https://lists.yoctoproject.org/g/docs/message/2646
Mute This Topic: https://lists.yoctoproject.org/mt/89890472/1051844
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/docs/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Reviewed-by on v1 1/1
#5 lore raw
In reply to Richard Purdie
Quoted 11 lines · Richard Purdie

This allows an improved and custmomised switcher for each release showing the current doc version, the latest in that series and the latest releases for the project overall.

---
 documentation/.gitignore                 |   1 +
 documentation/Makefile                   |   9 +-
 documentation/sphinx-static/switchers.js | 233 -----------------------
 3 files changed, 9 insertions(+), 234 deletions(-)
 delete mode 100644 documentation/sphinx-static/switchers.js

Looks good to me.

Thanks :)

Michael.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#6 lore raw
In reply to Richard Purdie

Hi Richard,

Quoted 4 lines · Richard Purdie

This allows an improved and custmomised switcher for each release showing the current doc version, the latest in that series and the latest releases for the project overall.

Not sure to understand the reason for this patch?

We anyway cannot fix already-tagged releases, for which yocto-autobuilder-helper will checkout the script and handle changes as required, why would the transition branch require something different/specific?

Cheers,
Quentin

Quoted 289 lines
---
  documentation/.gitignore                 |   1 +
  documentation/Makefile                   |   9 +-
  documentation/sphinx-static/switchers.js | 233 -----------------------
  3 files changed, 9 insertions(+), 234 deletions(-)

delete mode 100644 documentation/sphinx-static/switchers.js

documentation/.gitignore +1 -0
index c1e43630d..f7d91141a 100644
@@ -1,2 +1,3 @@
  _build/
  sphinx/__pycache__/
+sphinx-static/switchers.js
\ No newline at end of file
documentation/Makefile +8 -1
index 564a906e2..433e880c4 100644
@@ -8,9 +8,16 @@ TRANSITIONS   = $(sort $(patsubst $(SOURCEDIR)/transition/%/index.rst,%,$(wildca
 
  .PHONY: Makefile publish transition clean $(TRANSITIONS)
 
+sphinx-static/switchers.js.in:
+	git checkout master sphinx-static/switchers.js.in
+
+set_versions.py:
+	git checkout master set_versions.py
+
  transition: $(TRANSITIONS)
 
-$(TRANSITIONS):
+$(TRANSITIONS): sphinx-static/switchers.js.in set_versions.py
+	./set_versions.py $@
  	@$(SPHINXBUILD) -M html "$(SOURCEDIR)"/transition/$@/ "$(BUILDDIR)"/$@ $(SPHINXOPTS) $(O) -c "$(SOURCEDIR)"
 
  publish: transition
documentation/sphinx-static/switchers.js deleted +0 -234
deleted file mode 100644
index e52032ead..000000000
@@ -1,233 +0,0 @@
-(function() {
-  'use strict';
-
-  var all_versions = {
-    'dev': 'dev (3.2)',
-    '3.1.4': '3.1.4',
-    '3.0.4': '3.0.4',
-    '2.7.4': '2.7.4',
-  };
-
-  var all_doctypes = {
-      'single': 'Individual Webpages',
-      'mega': "All-in-one 'Mega' Manual",
-  };
-
-  // Simple version comparision
-  // Return 1 if a > b
-  // Return -1 if a < b
-  // Return 0 if a == b
-  function ver_compare(a, b) {
-    if (a == "dev") {
-       return 1;
-    }
-
-    if (a === b) {
-       return 0;
-    }
-
-    var a_components = a.split(".");
-    var b_components = b.split(".");
-
-    var len = Math.min(a_components.length, b_components.length);
-
-    // loop while the components are equal
-    for (var i = 0; i < len; i++) {
-        // A bigger than B
-        if (parseInt(a_components[i]) > parseInt(b_components[i])) {
-            return 1;
-        }
-
-        // B bigger than A
-        if (parseInt(a_components[i]) < parseInt(b_components[i])) {
-            return -1;
-        }
-    }
-
-    // If one's a prefix of the other, the longer one is greater.
-    if (a_components.length > b_components.length) {
-        return 1;
-    }
-
-    if (a_components.length < b_components.length) {
-        return -1;
-    }
-
-    // Otherwise they are the same.
-    return 0;
-  }
-
-  function build_version_select(current_series, current_version) {
-    var buf = ['<select>'];
-
-    $.each(all_versions, function(version, title) {
-      var series = version.substr(0, 3);
-      if (series == current_series) {
-        if (version == current_version)
-            buf.push('<option value="' + version + '" selected="selected">' + title + '</option>');
-        else
-            buf.push('<option value="' + version + '">' + title + '</option>');
-
-        if (version != current_version)
-            buf.push('<option value="' + current_version + '" selected="selected">' + current_version + '</option>');
-      } else {
-        buf.push('<option value="' + version + '">' + title + '</option>');
-      }
-    });
-
-    buf.push('</select>');
-    return buf.join('');
-  }
-
-  function build_doctype_select(current_doctype) {
-    var buf = ['<select>'];
-
-    $.each(all_doctypes, function(doctype, title) {
-      if (doctype == current_doctype)
-        buf.push('<option value="' + doctype + '" selected="selected">' +
-                 all_doctypes[current_doctype] + '</option>');
-      else
-        buf.push('<option value="' + doctype + '">' + title + '</option>');
-    });
-    if (!(current_doctype in all_doctypes)) {
-        // In case we're browsing a doctype that is not yet in all_doctypes.
-        buf.push('<option value="' + current_doctype + '" selected="selected">' +
-                 current_doctype + '</option>');
-        all_doctypes[current_doctype] = current_doctype;
-    }
-    buf.push('</select>');
-    return buf.join('');
-  }
-
-  function navigate_to_first_existing(urls) {
-    // Navigate to the first existing URL in urls.
-    var url = urls.shift();
-
-    // Web browsers won't redirect file:// urls to file urls using ajax but
-    // its useful for local testing
-    if (url.startsWith("file://")) {
-      window.location.href = url;
-      return;
-    }
-
-    if (urls.length == 0) {
-      window.location.href = url;
-      return;
-    }
-    $.ajax({
-      url: url,
-      success: function() {
-        window.location.href = url;
-      },
-      error: function() {
-        navigate_to_first_existing(urls);
-      }
-    });
-  }
-
-  function get_docroot_url() {
-    var url = window.location.href;
-    var root = DOCUMENTATION_OPTIONS.URL_ROOT;
-
-    var urlarray = url.split('/');
-    // Trim off anything after '/'
-    urlarray.pop();
-    var depth = (root.match(/\.\.\//g) || []).length;
-    for (var i = 0; i < depth; i++) {
-      urlarray.pop();
-    }
-
-    return urlarray.join('/') + '/';
-  }
-
-  function on_version_switch() {
-    var selected_version = $(this).children('option:selected').attr('value');
-    var url = window.location.href;
-    var current_version = DOCUMENTATION_OPTIONS.VERSION;
-    var docroot = get_docroot_url()
-
-    var new_versionpath = selected_version + '/';
-    if (selected_version == "dev")
-        new_versionpath = '';
-
-    // dev versions have no version prefix
-    if (current_version == "dev") {
-        var new_url = docroot + new_versionpath + url.replace(docroot, "");
-        var fallback_url = docroot + new_versionpath;
-    } else {
-        var new_url = url.replace('/' + current_version + '/', '/' + new_versionpath);
-        var fallback_url = new_url.replace(url.replace(docroot, ""), "");
-    }
-
-    console.log(get_docroot_url())
-    console.log(url + " to url " + new_url);
-    console.log(url + " to fallback " + fallback_url);
-
-    if (new_url != url) {
-      navigate_to_first_existing([
-        new_url,
-        fallback_url,
-        'https://urldefense.proofpoint.com/v2/url?u=https-3A__www.yoctoproject.org_docs_&d=DwIDAg&c=_sEr5x9kUWhuk4_nFwjJtA&r=LYjLexDn7rXIzVmkNPvw5ymA1XTSqHGq8yBP6m6qZZ4njZguQhZhkI_-172IIy1t&m=isfW44ZF5kuhyY44oJjXbmrJNH56s7PcZf_DXMb5wvx3gOochEh79xvv4mCES4kQ&s=zUSdVp19IAPikzuZt7DkZZkEB7r83pTjRI3cpZI80as&e= ',
-      ]);
-    }
-  }
-
-  function on_doctype_switch() {
-    var selected_doctype = $(this).children('option:selected').attr('value');
-    var url = window.location.href;
-    if (selected_doctype == 'mega') {
-      var docroot = get_docroot_url()
-      var current_version = DOCUMENTATION_OPTIONS.VERSION;
-      // Assume manuals before 3.2 are using old docbook mega-manual
-      if (ver_compare(current_version, "3.2") < 0) {
-        var new_url = docroot + "mega-manual/mega-manual.html";
-      } else {
-        var new_url = docroot + "singleindex.html";
-      }
-    } else {
-      var new_url = url.replace("singleindex.html", "index.html")
-    }
-
-    if (new_url != url) {
-      navigate_to_first_existing([
-        new_url,
-        'https://urldefense.proofpoint.com/v2/url?u=https-3A__www.yoctoproject.org_docs_&d=DwIDAg&c=_sEr5x9kUWhuk4_nFwjJtA&r=LYjLexDn7rXIzVmkNPvw5ymA1XTSqHGq8yBP6m6qZZ4njZguQhZhkI_-172IIy1t&m=isfW44ZF5kuhyY44oJjXbmrJNH56s7PcZf_DXMb5wvx3gOochEh79xvv4mCES4kQ&s=zUSdVp19IAPikzuZt7DkZZkEB7r83pTjRI3cpZI80as&e= ',
-      ]);
-    }
-  }
-
-  // Returns the current doctype based upon the url
-  function doctype_segment_from_url(url) {
-    if (url.includes("singleindex") || url.includes("mega-manual"))
-      return "mega";
-    return "single";
-  }
-
-  $(document).ready(function() {
-    var release = DOCUMENTATION_OPTIONS.VERSION;
-    var current_doctype = doctype_segment_from_url(window.location.href);
-    var current_series = release.substr(0, 3);
-    var version_select = build_version_select(current_series, release);
-
-    $('.version_switcher_placeholder').html(version_select);
-    $('.version_switcher_placeholder select').bind('change', on_version_switch);
-
-    var doctype_select = build_doctype_select(current_doctype);
-
-    $('.doctype_switcher_placeholder').html(doctype_select);
-    $('.doctype_switcher_placeholder select').bind('change', on_doctype_switch);
-
-    if (ver_compare(release, "3.1") < 0) {
-      $('#outdated-warning').html('Version ' + release + ' of the project is now considered obsolete, please select and use a more recent version');
-      $('#outdated-warning').css('padding', '.5em');
-    } else if (release != "dev") {
-      $.each(all_versions, function(version, title) {
-        var series = version.substr(0, 3);
-        if (series == current_series && version != release) {
-          $('#outdated-warning').html('This document is for outdated version ' + release + ', you should select the latest release version in this series, ' + version + '.');
-          $('#outdated-warning').css('padding', '.5em');
-        }
-      });
-    }
-  });
-})();
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#2644): https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_g_docs_message_2644&d=DwIFaQ&c=_sEr5x9kUWhuk4_nFwjJtA&r=LYjLexDn7rXIzVmkNPvw5ymA1XTSqHGq8yBP6m6qZZ4njZguQhZhkI_-172IIy1t&m=isfW44ZF5kuhyY44oJjXbmrJNH56s7PcZf_DXMb5wvx3gOochEh79xvv4mCES4kQ&s=c4JwO4ulmWCUvNf7cVgYgdb-hJY955ob7lZroYQalqc&e=
Mute This Topic: https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_mt_89890470_6293953&d=DwIFaQ&c=_sEr5x9kUWhuk4_nFwjJtA&r=LYjLexDn7rXIzVmkNPvw5ymA1XTSqHGq8yBP6m6qZZ4njZguQhZhkI_-172IIy1t&m=isfW44ZF5kuhyY44oJjXbmrJNH56s7PcZf_DXMb5wvx3gOochEh79xvv4mCES4kQ&s=fkx7Ua5fATrcGS7x9mKIhwjmEZYXo9ZKh0J62bUitSs&e=
Group Owner: [email protected]
Unsubscribe: https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_g_docs_unsub&d=DwIFaQ&c=_sEr5x9kUWhuk4_nFwjJtA&r=LYjLexDn7rXIzVmkNPvw5ymA1XTSqHGq8yBP6m6qZZ4njZguQhZhkI_-172IIy1t&m=isfW44ZF5kuhyY44oJjXbmrJNH56s7PcZf_DXMb5wvx3gOochEh79xvv4mCES4kQ&s=K5AsX3XjfLfuAVh9csLO14g9CT8R-wrL9UG1npdX4A8&e= [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#7 lore raw
Quoted 9 lines · Quentin Schulz

Hi Richard,

Quoted 4 lines · Richard Purdie

This allows an improved and custmomised switcher for each release showing the current doc version, the latest in that series and the latest releases for the project overall.

Not sure to understand the reason for this patch?

For every other docs branch we can run set_versions.py once and have the correct information in switchers.js. For transitions, we have multiple runs of the documentation generation and we want to customise switchers.js in each case. This is so we can show the current version, and the current release series latest version which allows the switcher to work properly. To do that, it is easiest just to fix the transitions branch to handle that.

Cheers,

Richard

Reviewed-by
#8 lore raw

Hi Richard,

Quoted 9 lines · Richard Purdie
Quoted 8 lines · Quentin Schulz

Hi Richard,

Quoted 4 lines · Richard Purdie

This allows an improved and custmomised switcher for each release showing the current doc version, the latest in that series and the latest releases for the project overall.

Quoted 9 lines
Quoted 1 line

Not sure to understand the reason for this patch?

For every other docs branch we can run set_versions.py once and have the correct information in switchers.js. For transitions, we have multiple runs of the documentation generation and we want to customise switchers.js in each case. This is so we can show the current version, and the current release series latest version which allows the switcher to work properly. To do that, it is easiest just to fix the transitions branch to handle that.

Makes perfect sense, would have loved to have this in the commit log :)

Thanks!
Quentin

#9 lore raw
Quoted 22 lines · Quentin Schulz

Hi Richard,

Quoted 9 lines · Richard Purdie
Quoted 8 lines · Quentin Schulz

Hi Richard,

Quoted 4 lines · Richard Purdie

This allows an improved and custmomised switcher for each release showing the current doc version, the latest in that series and the latest releases for the project overall.

Quoted 9 lines
Quoted 1 line

Not sure to understand the reason for this patch?

For every other docs branch we can run set_versions.py once and have the correct information in switchers.js. For transitions, we have multiple runs of the documentation generation and we want to customise switchers.js in each case. This is so we can show the current version, and the current release series latest version which allows the switcher to work properly. To do that, it is easiest just to fix the transitions branch to handle that.

Quoted 1 line

Makes perfect sense, would have loved to have this in the commit log :)

I did try and say that, just not very clearly. I've added to the commit log as it hasn't merged yet.

Cheers,

Richard