Skip to content

Commit 4c84e22

Browse files
committed
docs: Add site version via mike
mike is a tool to keep several versions of a MkDocs site. Please see the project documentation for more info: https://github.com/jimporter/mike Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 5da37b7 commit 4c84e22

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

CONTRIBUTING.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,39 @@ Or you can just serve the documentation without building it using:
4848
mkdocs serve
4949
```
5050

51+
Your site will be updated **live** when you change your files (provided that
52+
you used `pip install -e .`, beware of a common pitfall of using `pip install`
53+
without `-e`, in that case the API reference won't change unless you do a new
54+
`pip install`).
55+
56+
To build multi-version documentation, we use
57+
[mike](https://github.com/jimporter/mike). If you want to see how the
58+
multi-version sites looks like locally, you can use:
59+
60+
```sh
61+
mike deploy my-version
62+
mike set-default my-version
63+
mike serve
64+
```
65+
66+
`mike` works in mysterious ways. Some basic information:
67+
68+
* `mike deploy` will do a `mike build` and write the results to your **local**
69+
`gh-pages` branch. `my-version` is an arbitrary name for the local version
70+
you want to preview.
71+
* `mike set-default` is needed so when you serve the documentation, it goes to
72+
your newly produced documentation by default.
73+
* `mike serve` will serve the contents of your **local** `gh-pages` branch. Be
74+
aware that, unlike `mkdocs serve`, changes to the sources won't be shown
75+
live, as the `mike deploy` step is needed to refresh them.
76+
77+
Be careful not to use `--push` with `mike deploy`, otherwise it will push your
78+
local `gh-pages` branch to the `origin` remote.
79+
80+
That said, if you want to test the actual website in **your fork**, you can
81+
always use `mike deploy --push --remote your-fork-remote`, and then access the
82+
GitHub pages produced for your fork.
83+
5184
Releasing
5285
=========
5386

docs/overrides/main.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{% extends "base.html" %}
2+
3+
{% block outdated %}
4+
You're not viewing the latest (stable) version.
5+
<a href="{{ '../' ~ base_url }}">
6+
<strong>Click here to go to latest (stable) version</strong>
7+
</a>
8+
{% endblock %}

mkdocs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ theme:
1919
icon:
2020
edit: material/file-edit-outline
2121
repo: fontawesome/brands/github
22+
custom_dir: docs/overrides
2223
features:
2324
- navigation.instant
2425
- navigation.tabs
@@ -47,6 +48,9 @@ extra:
4748
link: https://github.com/frequenz-floss
4849
- icon: fontawesome/brands/linkedin
4950
link: https://www.linkedin.com/company/frequenz-com
51+
version:
52+
provider: mike
53+
default: latest
5054

5155
extra_css:
5256
- css/style.css
@@ -76,6 +80,8 @@ plugins:
7680
- docs/mkdocstrings_autoapi.py
7781
- literate-nav:
7882
nav_file: SUMMARY.md
83+
- mike:
84+
canonical_version: latest
7985
- mkdocstrings:
8086
custom_templates: templates
8187
default_handler: python

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ email = "[email protected]"
3636

3737
[project.optional-dependencies]
3838
docs = [
39+
"mike >= 1.1.2, < 2",
3940
"mkdocs-gen-files >= 0.4.0, < 0.5.0",
4041
"mkdocs-literate-nav >= 0.4.0, < 0.5.0",
4142
"mkdocs-material >= 8.5.7, < 9",

0 commit comments

Comments
 (0)