Docs: prep for upcoming RTD build changes

Read the Docs is changing their build process. Some docs/conf.py
manipulation they used to do automatically now must be manually
included.

https://about.readthedocs.com/blog/2024/07/addons-by-default/

Related changes:

* Drop our version-alert.js. RTD's new "addons" includes
  equivalent warning on unreleased versions.

* Integrate Google Analytics via sphinxcontrib-googleanalytics
  when GOOGLE_ANALYTICS_ID is set in docs build environment.
This commit is contained in:
Mike Edmunds
2024-08-28 13:20:57 -07:00
parent 9d4fb5daf9
commit 397dcf5f8a
4 changed files with 25 additions and 41 deletions

View File

@@ -1,38 +0,0 @@
"use strict";
// Similar to https://github.com/readthedocs/readthedocs.org/blob/5.2.3/readthedocs/core/static-src/core/js/doc-embed/version-compare.js
// but adds admonition for the "latest" version -- which is (unreleased) main branch.
function warnOnLatestVersion() {
// The warning text and link is really specific to RTD hosting,
// so we can just check their global to determine version:
if (!window.READTHEDOCS_DATA || window.READTHEDOCS_DATA.version !== "latest") {
return; // not latest, or not on RTD
}
var warning = document.createElement("div");
warning.setAttribute("class", "admonition danger");
warning.innerHTML =
"<p class='first admonition-title'>Note</p> " +
"<p class='last'> " +
"This document is for an <strong>unreleased development version</strong>. " +
"Documentation is available for the <a href='/en/stable/'>current stable release</a>, " +
"or for older versions through the &ldquo;v:&rdquo; menu at bottom left." +
"</p>";
warning.querySelector("a").href = window.location.pathname.replace(
"/latest",
"/stable"
);
var parent =
document.querySelector("div.body") ||
document.querySelector("div.document") ||
document.body;
parent.insertBefore(warning, parent.firstChild);
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", warnOnLatestVersion);
} else {
warnOnLatestVersion();
}