Skip to content

Commit

Permalink
Mike for docs versioning (#496)
Browse files Browse the repository at this point in the history
Using mike together with Material for Mkdocs to manage multiple
versions of the docs.
  • Loading branch information
jorisroovers committed May 15, 2023
1 parent 5a1cd61 commit 66601ba
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
5 changes: 2 additions & 3 deletions docs/contributing/tests_formatting_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion docs/javascript/extra.js
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
5 changes: 5 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -91,6 +94,8 @@ extra:
- icon: simple/twitter
link: https://twitter.com/jorisroovers
name: Joris Roovers on twitter
version:
provider: mike

nav:
- Home:
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##########################################################################################################

Expand Down

0 comments on commit 66601ba

Please sign in to comment.