diff --git a/docs/_static/version-alert.js b/docs/_static/version-alert.js deleted file mode 100644 index c7f9803a..00000000 --- a/docs/_static/version-alert.js +++ /dev/null @@ -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 = - "

Note

" + - "

" + - "This document is for an unreleased development version. " + - "Documentation is available for the current stable release, " + - "or for older versions through the “v:” menu at bottom left." + - "

"; - 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(); -} diff --git a/docs/conf.py b/docs/conf.py index e1d575eb..1fb6b117 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -15,7 +15,7 @@ from anymail import VERSION as PACKAGE_VERSION -ON_READTHEDOCS = os.environ.get("READTHEDOCS", None) == "True" +ON_READTHEDOCS = os.environ.get("READTHEDOCS") == "True" DOCS_PATH = Path(__file__).parent PROJECT_ROOT_PATH = DOCS_PATH.parent @@ -31,7 +31,12 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ["sphinx.ext.intersphinx", "sphinx.ext.extlinks", "sphinx_rtd_theme"] +extensions = [ + "sphinx.ext.intersphinx", + "sphinx.ext.extlinks", + "sphinx_rtd_theme", + "sphinxcontrib.googleanalytics", +] # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] @@ -96,6 +101,12 @@ # -- Options for HTML output --------------------------------------------------- +# Set canonical URL from the Read the Docs Domain. +html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "") + +# Let templates know whether the build is running on Read the Docs. +html_context = {"READTHEDOCS": ON_READTHEDOCS} + # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = "sphinx_rtd_theme" @@ -271,14 +282,23 @@ "urllib3": ("https://urllib3.readthedocs.io/en/stable/", None), } +# -- Options for Google Analytics ------------------------------------------- + +googleanalytics_id = os.environ.get("GOOGLE_ANALYTICS_ID", "") +googleanalytics_enabled = bool(googleanalytics_id) + +if not googleanalytics_enabled: + # Work around https://github.com/sphinx-contrib/googleanalytics/issues/14. + googleanalytics_id = "IGNORED" + +# -- App setup -------------------------------------------------------------- def setup(app): app.add_css_file("anymail-theme.css") # Inline