diff --git a/docs/contributing/tests_formatting_docs.md b/docs/contributing/tests_formatting_docs.md index 62a2eab3..6d3227ce 100644 --- a/docs/contributing/tests_formatting_docs.md +++ b/docs/contributing/tests_formatting_docs.md @@ -60,8 +60,8 @@ hatch run test:autofix ``` ## Documentation -We use [mkdocs](https://www.mkdocs.org/) with [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) for -generating our documentation from markdown. +We use [mkdocs](https://www.mkdocs.org/) with [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) and +[mike](https://github.com/jimporter/mike) for generating our documentation from markdown. To use it: ```{.sh .copy} @@ -70,7 +70,6 @@ hatch run docs:serve Then access the documentation website on [http://localhost:8000](). - ## Tools We keep a small set of scripts in the `tools/` directory: diff --git a/docs/javascript/extra.js b/docs/javascript/extra.js index 74e32c7c..076f7e4f 100644 --- a/docs/javascript/extra.js +++ b/docs/javascript/extra.js @@ -7,7 +7,7 @@ document.addEventListener("DOMContentLoaded", function () { // This is to support old links that are in gitlint's CLI Output // If the trailing slash is missing from /gitlint/configuration, mkdocs will redirect to the trailing slash version, // and then this code will redirect to the correct page - if (window.location.pathname == "/gitlint/configuration/") { + if (window.location.pathname.endsWith("configuration/")) { if (window.location.hash === "#regex-style-search") { window.location.href = "/gitlint/configuration/general_options/#regex-style-search"; } else if (window.location.hash === "#staged") { diff --git a/mkdocs.yml b/mkdocs.yml index 61e45c84..f2074abc 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -38,6 +38,9 @@ plugins: # URLs present in the generated .gitlint file contrib_rules.md : rules/contrib_rules.md user_defined_rules.md : rules/user_defined_rules/index.md + mike: + alias_type: copy + canonical_version: latest theme: name: material @@ -91,6 +94,8 @@ extra: - icon: simple/twitter link: https://twitter.com/jorisroovers name: Joris Roovers on twitter + version: + provider: mike nav: - Home: diff --git a/pyproject.toml b/pyproject.toml index 9b12d35f..162d3adc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -150,11 +150,13 @@ detached = true dependencies = [ "mkdocs-material==9.1.9", # "mkdocs-redirects==1.2.0", + # https://github.com/jimporter/mike/issues/130 + "mike @ https://github.com/jimporter/mike/archive/300593c338b18f61f604d18457c351e166318020.zip", ] [tool.hatch.envs.docs.scripts] build = "mkdocs build --clean --strict" -serve = "mkdocs serve" +serve = "mike serve" # Tool config ##########################################################################################################