From 1bfd62ff18dbc74a70b6ef1bff16dffa134e4a78 Mon Sep 17 00:00:00 2001 From: Philipp Salvisberg Date: Sat, 13 Aug 2022 14:01:20 +0200 Subject: [PATCH 1/3] activate instant page loading and use native version selector of mkdocs-material --- docs/js/version-select.js | 49 --------------------------------------- mkdocs.yml | 5 +++- 2 files changed, 4 insertions(+), 50 deletions(-) delete mode 100644 docs/js/version-select.js diff --git a/docs/js/version-select.js b/docs/js/version-select.js deleted file mode 100644 index 794b5cc8..00000000 --- a/docs/js/version-select.js +++ /dev/null @@ -1,49 +0,0 @@ -window.addEventListener("DOMContentLoaded", function() { - // This is a bit hacky. Figure out the base URL from a known CSS file the - // template refers to... - var ex = new RegExp("/?css/version-select.css$"); - var sheet = document.querySelector('link[href$="version-select.css"]'); - - var ABS_BASE_URL = sheet.href.replace(ex, ""); - var CURRENT_VERSION = ABS_BASE_URL.split("/").pop(); - - function makeSelect(options, selected) { - var select = document.createElement("select"); - select.classList.add("form-control"); - - options.forEach(function(i) { - var option = new Option(i.text, i.value, undefined, - i.value === selected); - select.add(option); - }); - - return select; - } - - var xhr = new XMLHttpRequest(); - xhr.open("GET", ABS_BASE_URL + "/../versions.json"); - xhr.onload = function() { - var versions = JSON.parse(this.responseText); - - var realVersion = versions.find(function(i) { - return i.version === CURRENT_VERSION || - i.aliases.includes(CURRENT_VERSION); - }).version; - - var select = makeSelect(versions.map(function(i) { - return {text: i.title, value: i.version}; - }), realVersion); - select.addEventListener("change", function(event) { - window.location.href = ABS_BASE_URL + "/../" + this.value; - }); - - var container = document.createElement("div"); - container.id = "version-selector"; - container.className = "md-nav__item"; - container.appendChild(select); - - var sidebar = document.querySelector(".md-nav--primary > .md-nav__list"); - sidebar.parentNode.insertBefore(container, sidebar); - }; - xhr.send(); -}); diff --git a/mkdocs.yml b/mkdocs.yml index 3e5284aa..7fbe6f0f 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -11,6 +11,8 @@ theme: repo: fontawesome/brands/github-alt name: 'material' custom_dir: custom-theme + features: + - navigation.instant favicon: images/favicon.ico palette: primary: 'white' @@ -18,7 +20,6 @@ theme: extra_css: - 'stylesheets/extra.css' - - 'css/version-select.css' extra_javascript: - 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML' - 'js/version-select.js' @@ -39,6 +40,8 @@ extra: link: https://github.com/Trivadis - icon: fontawesome/brands/twitter link: https://twitter.com/trivadis + version: + provider: mike plugins: - search From 4983ba6fcc4ff7977814f21a0fe747e62eb6136c Mon Sep 17 00:00:00 2001 From: Philipp Salvisberg Date: Sat, 13 Aug 2022 14:06:28 +0200 Subject: [PATCH 2/3] Do not display version number in HTML title --- custom-theme/main.html | 1 - custom-theme/partials/header.html | 161 ------------------------------ mkdocs.yml | 1 - 3 files changed, 163 deletions(-) delete mode 100644 custom-theme/main.html delete mode 100644 custom-theme/partials/header.html diff --git a/custom-theme/main.html b/custom-theme/main.html deleted file mode 100644 index 63913c18..00000000 --- a/custom-theme/main.html +++ /dev/null @@ -1 +0,0 @@ -{% extends "base.html" %} \ No newline at end of file diff --git a/custom-theme/partials/header.html b/custom-theme/partials/header.html deleted file mode 100644 index 31c4926f..00000000 --- a/custom-theme/partials/header.html +++ /dev/null @@ -1,161 +0,0 @@ - - - -{% set class = "md-header" %} -{% if "navigation.tabs.sticky" in features %} - {% set class = class ~ " md-header--lifted" %} -{% endif %} - - -
- - - - {% if "navigation.tabs.sticky" in features %} - {% if "navigation.tabs" in features %} - {% include "partials/tabs.html" %} - {% endif %} - {% endif %} -
\ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 7fbe6f0f..284ce445 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -10,7 +10,6 @@ theme: icon: repo: fontawesome/brands/github-alt name: 'material' - custom_dir: custom-theme features: - navigation.instant favicon: images/favicon.ico From 0946317eb76555ce13793d78b62be23cd158652a Mon Sep 17 00:00:00 2001 From: Philipp Salvisberg Date: Sat, 13 Aug 2022 14:21:57 +0200 Subject: [PATCH 3/3] custom-theme has been removed, no need to copy it in genpdf.sh --- tools/run-in-container/genpdf.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/run-in-container/genpdf.sh b/tools/run-in-container/genpdf.sh index 9602c739..6787b2b2 100755 --- a/tools/run-in-container/genpdf.sh +++ b/tools/run-in-container/genpdf.sh @@ -7,7 +7,6 @@ function create_target_dir(){ function copy_resources() { cp ${DATA_DIR}/mkdocs.yml ${TARGET_DIR}/mkdocs.yml - cp -r ${DATA_DIR}/custom-theme ${TARGET_DIR}/custom-theme cp -r ${DATA_DIR}/docs/images ${TARGET_DIR}/docs cp -r ${DATA_DIR}/docs/stylesheets ${TARGET_DIR}/docs/stylesheets }