From d49c617776fc7cf09e11edd4bfee8cf1b157771e Mon Sep 17 00:00:00 2001 From: Keirthana T S Date: Wed, 8 Jul 2026 11:06:30 +0530 Subject: [PATCH 1/2] Update Sphinx configuration for migration --- docs/{_dev => }/_static/bundle.js | 0 docs/{_dev => }/_static/cookie-banner.css | 0 docs/_static/overwrite_links.js | 52 +++++++++++++++++++++++ docs/conf.py | 10 +++-- 4 files changed, 58 insertions(+), 4 deletions(-) rename docs/{_dev => }/_static/bundle.js (100%) rename docs/{_dev => }/_static/cookie-banner.css (100%) create mode 100644 docs/_static/overwrite_links.js diff --git a/docs/_dev/_static/bundle.js b/docs/_static/bundle.js similarity index 100% rename from docs/_dev/_static/bundle.js rename to docs/_static/bundle.js diff --git a/docs/_dev/_static/cookie-banner.css b/docs/_static/cookie-banner.css similarity index 100% rename from docs/_dev/_static/cookie-banner.css rename to docs/_static/cookie-banner.css diff --git a/docs/_static/overwrite_links.js b/docs/_static/overwrite_links.js new file mode 100644 index 0000000..5ca5234 --- /dev/null +++ b/docs/_static/overwrite_links.js @@ -0,0 +1,52 @@ +// Replaces rtd-address with new-address in links + +const rtd_address = 'https://canonical-ta-kernel-docs-ha-proxy.readthedocs-hosted.com/'; +const new_address = 'https://ubuntu.com/kernel/docs'; + +function escapeRegExp(value) { + return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); +} + +function overwriteMatchingAnchorUrls(container) { + if (!container) return; + + const rtd_addressRegex = new RegExp(escapeRegExp(rtd_address), 'g'); + container.querySelectorAll('a[href], link[href]').forEach((anchor) => { + anchor.href = anchor.href.replace(rtd_addressRegex, new_address); + }); +} + +function patchFlyout() { + const rtdFlyout = document.querySelector('readthedocs-flyout'); + if (!rtdFlyout) return false; + + overwriteMatchingAnchorUrls(rtdFlyout); + overwriteMatchingAnchorUrls(rtdFlyout.shadowRoot); + + rtdFlyout.addEventListener('click', () => { + overwriteMatchingAnchorUrls(rtdFlyout); + overwriteMatchingAnchorUrls(rtdFlyout.shadowRoot); + }); + + return true; +} + +function init() { + overwriteMatchingAnchorUrls(document.querySelector('header')); + + if (patchFlyout()) return; + + const observer = new MutationObserver(() => { + if (patchFlyout()) { + observer.disconnect(); + } + }); + + observer.observe(document.body, { childList: true, subtree: true }); +} + +if (document.body) { + init(); +} else { + document.addEventListener('DOMContentLoaded', init); +} \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index bc20aa8..ff381cc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -72,7 +72,7 @@ # NOTE: The Open Graph Protocol (OGP) enhances page display in a social graph # and is used by social media platforms; see https://ogp.me/ -ogp_site_url = "https://canonical-kernel-docs.readthedocs-hosted.com/" +ogp_site_url = "https://ubuntu.com/kernel/docs" # Preview name of the documentation website @@ -160,7 +160,7 @@ # TODO: If your documentation is hosted on https://docs.ubuntu.com/, # uncomment and update as needed. -# slug = '' +slug = 'https://ubuntu.com/kernel/docs' ####################### @@ -169,11 +169,12 @@ # Use RTD canonical URL to ensure duplicate pages have a specific canonical URL -html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "/") +html_baseurl = "https://ubuntu.com/kernel/docs" # sphinx-sitemap uses html_baseurl to generate the full URL for each page: sitemap_url_scheme = '{link}' +sitemap_filename = "doc-sitemap.xml" # Include `lastmod` dates in the sitemap: @@ -189,7 +190,7 @@ # Template and asset locations -html_static_path = ["_dev/_static"] +html_static_path = ["_static"] templates_path = ["_dev/_templates"] @@ -326,6 +327,7 @@ html_js_files = [ "bundle.js", + "overwrite_links.js", ] From 98eca740bc8a0008c0b6f2a882ae849dd57cd0d1 Mon Sep 17 00:00:00 2001 From: Keirthana T S Date: Wed, 8 Jul 2026 11:15:24 +0530 Subject: [PATCH 2/2] Fix slug and JS file paths --- docs/_static/{ => js}/bundle.js | 0 docs/_static/{ => js}/overwrite_links.js | 0 docs/conf.py | 6 +++--- 3 files changed, 3 insertions(+), 3 deletions(-) rename docs/_static/{ => js}/bundle.js (100%) rename docs/_static/{ => js}/overwrite_links.js (100%) diff --git a/docs/_static/bundle.js b/docs/_static/js/bundle.js similarity index 100% rename from docs/_static/bundle.js rename to docs/_static/js/bundle.js diff --git a/docs/_static/overwrite_links.js b/docs/_static/js/overwrite_links.js similarity index 100% rename from docs/_static/overwrite_links.js rename to docs/_static/js/overwrite_links.js diff --git a/docs/conf.py b/docs/conf.py index ff381cc..2303e60 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -160,7 +160,7 @@ # TODO: If your documentation is hosted on https://docs.ubuntu.com/, # uncomment and update as needed. -slug = 'https://ubuntu.com/kernel/docs' +slug = 'kernel/docs' ####################### @@ -326,8 +326,8 @@ # Adds custom JavaScript files, located under 'html_static_path' html_js_files = [ - "bundle.js", - "overwrite_links.js", + "js/bundle.js", + "js/overwrite_links.js", ]