From 73dc62aaca4a19c314f9ef7fe9a1e41bf88e5f44 Mon Sep 17 00:00:00 2001 From: Yana Hontyk Date: Tue, 14 Jul 2026 09:48:39 +0200 Subject: [PATCH 1/4] Domain migration --- docs/_static/js/overwrite_links.js | 52 ++++++++++++++++++++++++++++++ docs/conf.py | 7 ++-- 2 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 docs/_static/js/overwrite_links.js diff --git a/docs/_static/js/overwrite_links.js b/docs/_static/js/overwrite_links.js new file mode 100644 index 00000000..672527a0 --- /dev/null +++ b/docs/_static/js/overwrite_links.js @@ -0,0 +1,52 @@ +// Replaces rtd-address with new-address in links + +const rtd_address = 'canonical-real-time-ubuntu-docs-migration.readthedocs-hosted.com'; +const new_address = 'ubuntu.com/real-time/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 1ef9ab10..f76201af 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -35,7 +35,7 @@ html_title = project + " documentation" # Documentation website URL -ogp_site_url = os.environ.get("READTHEDOCS_CANONICAL_URL", "/") +ogp_site_url = "https://canonical-real-time-ubuntu-docs-migration.readthedocs-hosted.com" # Preview name of the documentation website # TODO: To use a different name for the project in previews, update the next line. @@ -112,14 +112,14 @@ # Project slug # TODO: If your documentation is hosted on https://documentation.ubuntu.com/, # uncomment and set to the RTD slug. -slug = 'real-time' +slug = 'real-time/docs' ####################### # Sitemap configuration: https://sphinx-sitemap.readthedocs.io/ ####################### # Use RTD canonical URL to ensure duplicate pages have a specific canonical URL -html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "/") +html_baseurl = "https://canonical-real-time-ubuntu-docs-migration.readthedocs-hosted.com" # sphinx-sitemap uses html_baseurl to generate the full URL for each page: sitemap_url_scheme = "{link}" @@ -267,6 +267,7 @@ # Adds custom JavaScript files, located remotely or in 'html_static_path'. html_js_files = [ "js/bundle.js", + "js/overwrite_links.js", ] # Appends extra markup to the end of every document written in reST From fba3bc72b42dc56a65b58f08c29e990feb7d9340 Mon Sep 17 00:00:00 2001 From: Yana Hontyk Date: Tue, 14 Jul 2026 09:53:33 +0200 Subject: [PATCH 2/4] Quickfix --- docs/conf.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index f76201af..b34ec013 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -35,7 +35,7 @@ html_title = project + " documentation" # Documentation website URL -ogp_site_url = "https://canonical-real-time-ubuntu-docs-migration.readthedocs-hosted.com" +ogp_site_url = "https://ubuntu.com/real-time/docs/" # Preview name of the documentation website # TODO: To use a different name for the project in previews, update the next line. @@ -119,10 +119,11 @@ ####################### # Use RTD canonical URL to ensure duplicate pages have a specific canonical URL -html_baseurl = "https://canonical-real-time-ubuntu-docs-migration.readthedocs-hosted.com" +html_baseurl = "https://ubuntu.com/real-time/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: sitemap_show_lastmod = True From 246de84a80f1d7f2e8d2d5bbd57c76d5ff7ce3cb Mon Sep 17 00:00:00 2001 From: Yana Hontyk Date: Fri, 17 Jul 2026 14:25:23 +0200 Subject: [PATCH 3/4] Change migration URL to prod --- docs/_static/js/overwrite_links.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_static/js/overwrite_links.js b/docs/_static/js/overwrite_links.js index 672527a0..cb934e65 100644 --- a/docs/_static/js/overwrite_links.js +++ b/docs/_static/js/overwrite_links.js @@ -1,6 +1,6 @@ // Replaces rtd-address with new-address in links -const rtd_address = 'canonical-real-time-ubuntu-docs-migration.readthedocs-hosted.com'; +const rtd_address = 'documentation.ubuntu.com/real-time'; const new_address = 'ubuntu.com/real-time/docs'; function escapeRegExp(value) { From e9dbcc4c88d174fee6a0de442decc36b19294e1b Mon Sep 17 00:00:00 2001 From: Yana Hontyk Date: Mon, 20 Jul 2026 08:59:25 +0200 Subject: [PATCH 4/4] Apply suggestion from @yhontyk Signed-off-by: Yana Hontyk --- docs/_static/js/overwrite_links.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/_static/js/overwrite_links.js b/docs/_static/js/overwrite_links.js index cb934e65..d6c5c3ed 100644 --- a/docs/_static/js/overwrite_links.js +++ b/docs/_static/js/overwrite_links.js @@ -1,6 +1,7 @@ // Replaces rtd-address with new-address in links -const rtd_address = 'documentation.ubuntu.com/real-time'; +const rtd_address = 'http://canonical-real-time-ubuntu-documentation.readthedocs-hosted.com' + const new_address = 'ubuntu.com/real-time/docs'; function escapeRegExp(value) {