Skip to content

Commit 607757c

Browse files
authored
Merge pull request #139 from libranet/docs/migrate-to-mkdocs-material
docs: migrate from Sphinx to MkDocs + Material for MkDocs
2 parents 2c5f646 + fa97d93 commit 607757c

26 files changed

Lines changed: 798 additions & 1069 deletions

.github/workflows/docs.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Docs - Github Actions
2+
#
3+
# Builds the MkDocs site with --strict, so broken links, missing nav entries and
4+
# unresolved mkdocstrings cross-references fail the pull request instead of only
5+
# surfacing in the Read the Docs build after merge.
6+
#
7+
# Used actions:
8+
# - actions/checkout
9+
# repo: https://github.com/actions/checkout
10+
# releases: https://github.com/actions/checkout/tags
11+
#
12+
# - astral-sh/setup-uv: set up uv environment
13+
# repo: https://github.com/astral-sh/setup-uv
14+
# releases: https://github.com/astral-sh/setup-uv/tags
15+
# docs: https://docs.astral.sh/uv/guides/integration/github/
16+
17+
18+
name: Docs 📗
19+
20+
concurrency:
21+
# see https://docs.github.com/en/actions/using-jobs/using-concurrency
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
24+
env:
25+
# Silence Material for MkDocs' MkDocs-2.0 stderr banner (it is not a build warning)
26+
DISABLE_MKDOCS_2_WARNING: "true"
27+
28+
# Pin uv version for reproducible builds
29+
# https://github.com/astral-sh/uv/releases
30+
UV_VERSION: "0.12.6"
31+
32+
on:
33+
pull_request:
34+
types: [opened, reopened, synchronize]
35+
push:
36+
branches:
37+
- main
38+
39+
permissions:
40+
contents: read
41+
42+
jobs:
43+
build:
44+
name: mkdocs build --strict
45+
runs-on: ubuntu-latest
46+
timeout-minutes: 5
47+
steps:
48+
49+
# repo: https://github.com/actions/checkout
50+
# releases: https://github.com/actions/checkout/tags
51+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
52+
with:
53+
persist-credentials: false
54+
55+
# repo: https://github.com/astral-sh/setup-uv
56+
# releases: https://github.com/astral-sh/setup-uv/tags
57+
# docs: https://docs.astral.sh/uv/guides/integration/github
58+
- name: Install pinned version of uv
59+
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
60+
with:
61+
cache-dependency-glob: "uv.lock"
62+
enable-cache: true
63+
prune-cache: true
64+
python-version: "3.14" # match tools.python in .readthedocs.yaml
65+
version: ${{ env.UV_VERSION }}
66+
67+
# Mirrors the Read the Docs build: only the "docs" group, project included so
68+
# mkdocstrings can import autoread_dotenv from src/.
69+
- name: Install docs dependencies
70+
run: uv sync --only-group docs
71+
72+
- name: Build the docs
73+
run: uv run mkdocs build --strict

.just/mkdocs.justfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# MkDocs + Material -- see ../mkdocs.yaml
2+
3+
4+
# show which mkdocs is used
5+
[group: 'mkdocs']
6+
mkdocs-which:
7+
@ uv run mkdocs --version
8+
9+
10+
# build the static site into var/html-docs (strict: fail on broken refs/links)
11+
[group: 'mkdocs']
12+
mkdocs-docs *args:
13+
uv run mkdocs build --strict {{ args }}
14+
@echo
15+
@echo "Build finished -> var/html-docs (see site_dir in ../mkdocs.yaml)"
16+
17+
18+
# Extra args pass through, e.g.
19+
# just mkdocs-serve -a 0.0.0.0:8000 # bind all interfaces (then browse localhost, NOT 0.0.0.0)
20+
# just mkdocs-serve --no-strict
21+
# live-reloading preview on http://127.0.0.1:8000/ (or http://localhost:8000/ from a WSL2 browser)
22+
[group: 'mkdocs']
23+
mkdocs-serve *args:
24+
uv run mkdocs serve {{ args }}
25+
26+
27+
# alias for mkdocs-docs
28+
alias docs := mkdocs-docs

.just/sphinx.justfile

Lines changed: 0 additions & 19 deletions
This file was deleted.

.readthedocs.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
# - https://docs.readthedocs.io/en/stable/config-file/v2.html for details
55
# - https://docs.readthedocs.com/platform/stable/build-customization.html
66
# - https://github.com/astral-sh/uv/issues/10074
7+
#
8+
# Enable RTD "Build pull requests":
9+
# go to https://app.readthedocs.org/ → autoread-dotenv project → Admin
10+
# → Settings → Check "Build pull requests for this project" → Save
711

812
version: 2
913

@@ -22,10 +26,8 @@ build:
2226

2327
formats:
2428
- htmlzip
25-
- pdf
26-
# - epub
27-
# - all
29+
# pdf/epub are Sphinx-only on Read the Docs and not available for MkDocs builds.
2830

29-
sphinx:
30-
configuration: docs/conf.py
31-
fail_on_warning: false # true is too strict
31+
mkdocs:
32+
configuration: mkdocs.yaml
33+
fail_on_warning: false # Material for MkDocs prints an (unsuppressable) MkDocs-2.0 banner

docs/changes.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
44

55
## 1.0.7 (unreleased)
66

7+
- Migrate the documentation from Sphinx to MkDocs + Material for MkDocs. The API
8+
reference is now generated by `mkdocstrings` (Python handler) instead of
9+
`sphinx-autoapi`; `docs/conf.py`, `docs/index.rst` and the committed
10+
`docs/modules/` tree are gone, replaced by `mkdocs.yaml`, `docs/index.md` and
11+
`docs/reference/*.md`. Read the Docs keeps hosting the site (`htmlzip` output
12+
retained; `pdf` dropped -- Sphinx-only on RTD). Module/function docstrings that
13+
used reStructuredText markup (`.. code-block::`, `:func:` / `:class:` roles)
14+
were rewritten in Markdown so they render correctly. Adds a `docs/configuration.md`
15+
page documenting the `AUTOREAD_DOTENV_PATH` and `AUTOREAD_ENFORCE_DOTENV`
16+
environment-variables, which must be set outside `.env`.
17+
718
- Narrow the blanket `except OSError` in `get_dotenv_path()`. `PermissionError` from
819
`is_file()` itself (the documented Python < 3.12 case of an unreadable parent directory)
920
still returns the path optimistically and defers to `load_dotenv()`. Any other `OSError`

0 commit comments

Comments
 (0)