Skip to content

Commit 5fd46a4

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 68805ad commit 5fd46a4

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

CONTRIBUTING.md

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

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

6598
These are the steps to create a new release:

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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ requires = [
33
"setuptools >= 65.3.0, < 66",
44
"setuptools_scm[toml] >= 7.0.5, < 8",
55
"wheel"
6-
76
]
87
build-backend = "setuptools.build_meta"
98

@@ -49,6 +48,7 @@ email = "[email protected]"
4948

5049
[project.optional-dependencies]
5150
docs = [
51+
"mike >= 1.1.2, < 2",
5252
"mkdocs-gen-files >= 0.4.0, < 0.5.0",
5353
"mkdocs-literate-nav >= 0.4.0, < 0.5.0",
5454
"mkdocs-material >= 8.5.7, < 9",

0 commit comments

Comments
 (0)