From ba512d8df399c765947fba438d742022a942b9ab Mon Sep 17 00:00:00 2001 From: Antonin Godard Date: Wed, 6 Nov 2024 08:48:27 +0100 Subject: sphinx-static/switchers.js.in: do not refer to URL_ROOT anymore This variable was removed from the Sphinx-generated documentation_options.js, thus breaking the current implementation of our switchers.js. Like searchtools.js, which is also generated by Sphinx, use document.documentElement.dataset.content_root as a replacement. To be backwards-compatible to get one or the other. (From yocto-docs rev: 6c16f7481b8b175271072062925959bbaba2ec5f) Signed-off-by: Antonin Godard (cherry picked from commit 2849690abf94872e259e712128e90413f3b9a2f2) Signed-off-by: Antonin Godard Signed-off-by: Steve Sakoman --- documentation/sphinx-static/switchers.js.in | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'documentation') diff --git a/documentation/sphinx-static/switchers.js.in b/documentation/sphinx-static/switchers.js.in index 8c016859bc..b1c0812b53 100644 --- a/documentation/sphinx-static/switchers.js.in +++ b/documentation/sphinx-static/switchers.js.in @@ -133,7 +133,13 @@ by https://git.yoctoproject.org/yocto-autobuilder-helper/tree/scripts/run-docs-b function get_docroot_url() { var url = window.location.href; + // Try to get the variable from documentation_options.js var root = DOCUMENTATION_OPTIONS.URL_ROOT; + if (root == null) { + // In recent versions of Sphinx, URL_ROOT was removed from + // documentation_options.js, so get it like searchtools.js does. + root = document.documentElement.dataset.content_root; + } var urlarray = url.split('/'); // Trim off anything after '/' -- cgit v1.2.3-54-g00ecf