Skip to content

Commit e018789

Browse files
ci: Use uv rather than a Dockerfile for mkdocs
1 parent 153eaa2 commit e018789

File tree

10 files changed

+704
-75
lines changed

10 files changed

+704
-75
lines changed

.github/ci_generator/templates/job_steps/build_docs.jinja

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,22 @@
99
run: |
1010
mkdir -p docs/api_reference
1111
cp -r target/doc/* docs/api_reference
12-
- name: Set up QEMU
13-
uses: docker/setup-qemu-action@v3
14-
- name: Set up Docker Buildx
15-
uses: docker/setup-buildx-action@v3
16-
- name: Build and export to Docker
17-
uses: docker/build-push-action@v5
18-
with:
19-
context: docs/
20-
load: true
21-
tags: pavex-docs
12+
- name: Install uv
13+
uses: astral-sh/setup-uv@v6
14+
- name: Install the project
15+
run: uv sync --locked
2216
- name: Build docs
2317
run: |
24-
docker run --rm -v ${PWD}:/docs pavex-docs build --strict
25-
- uses: actions/upload-artifact@v4
18+
uv run mkdocs build --strict
19+
- uses: actions/upload-artifact@v5
2620
with:
2721
name: docs
2822
path: site/
2923
- name: Fix base
3024
run: |
3125
# Convert all "absolute" guide links in the reference to relative links so that we can scan for dead links
32-
sudo find . -type f -exec sed -i "s#https://pavex.dev/docs/#file:///${PWD}/site/#g" {} +
33-
sudo find . -type f -exec sed -i "s#https://pavex.dev/#file:///${PWD}/site/#g" {} +
26+
sudo find ./site -type f -exec sed -i "s#https://pavex.dev/docs/#file:///${PWD}/site/#g" {} +
27+
sudo find ./site -type f -exec sed -i "s#https://pavex.dev/#file:///${PWD}/site/#g" {} +
3428
- name: Link Checker
3529
uses: lycheeverse/lychee-action@v2
3630
with:
@@ -45,6 +39,7 @@
4539
--exclude-path="site/api_reference/pavex/time"
4640
--exclude-path="site/api_reference/help.html"
4741
--exclude-path="site/api_reference/settings.html"
42+
--exclude-path="site/404.html"
4843
--exclude=".*crate#per-style$"
4944
--exclude="https://doc.rust-lang.org/*"
5045
--exclude="https://stackoverflow.com/*"
@@ -55,4 +50,12 @@
5550
--require-https
5651
--no-progress
5752
site
53+
- name: Update unstable documentation
54+
# if: github.ref == 'refs/heads/main' && github.event_name == 'push' && github.event.repository.full_name == github.repository)
55+
run: |
56+
# We made some destructive updates to perform link checking,
57+
# so best to regenerate the site
58+
rm -rf site
59+
uv run mkdocs build --strict
60+
uv run mike deploy --push --allow-empty unstable
5861
<%- endblock %>

.github/workflows/docs.yml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,28 +1717,22 @@ jobs:
17171717
run: |
17181718
mkdir -p docs/api_reference
17191719
cp -r target/doc/* docs/api_reference
1720-
- name: Set up QEMU
1721-
uses: docker/setup-qemu-action@v3
1722-
- name: Set up Docker Buildx
1723-
uses: docker/setup-buildx-action@v3
1724-
- name: Build and export to Docker
1725-
uses: docker/build-push-action@v5
1726-
with:
1727-
context: docs/
1728-
load: true
1729-
tags: pavex-docs
1720+
- name: Install uv
1721+
uses: astral-sh/setup-uv@v6
1722+
- name: Install the project
1723+
run: uv sync --locked
17301724
- name: Build docs
17311725
run: |
1732-
docker run --rm -v ${PWD}:/docs pavex-docs build --strict
1733-
- uses: actions/upload-artifact@v4
1726+
uv run mkdocs build --strict
1727+
- uses: actions/upload-artifact@v5
17341728
with:
17351729
name: docs
17361730
path: site/
17371731
- name: Fix base
17381732
run: |
17391733
# Convert all "absolute" guide links in the reference to relative links so that we can scan for dead links
1740-
sudo find . -type f -exec sed -i "s#https://pavex.dev/docs/#file:///${PWD}/site/#g" {} +
1741-
sudo find . -type f -exec sed -i "s#https://pavex.dev/#file:///${PWD}/site/#g" {} +
1734+
sudo find ./site -type f -exec sed -i "s#https://pavex.dev/docs/#file:///${PWD}/site/#g" {} +
1735+
sudo find ./site -type f -exec sed -i "s#https://pavex.dev/#file:///${PWD}/site/#g" {} +
17421736
- name: Link Checker
17431737
uses: lycheeverse/lychee-action@v2
17441738
with:
@@ -1753,6 +1747,7 @@ jobs:
17531747
--exclude-path="site/api_reference/pavex/time"
17541748
--exclude-path="site/api_reference/help.html"
17551749
--exclude-path="site/api_reference/settings.html"
1750+
--exclude-path="site/404.html"
17561751
--exclude=".*crate#per-style$"
17571752
--exclude="https://doc.rust-lang.org/*"
17581753
--exclude="https://stackoverflow.com/*"
@@ -1763,6 +1758,14 @@ jobs:
17631758
--require-https
17641759
--no-progress
17651760
site
1761+
- name: Update unstable documentation
1762+
# if: github.ref == 'refs/heads/main' && github.event_name == 'push' && github.event.repository.full_name == github.repository)
1763+
run: |
1764+
# We made some destructive updates to perform link checking,
1765+
# so best to regenerate the site
1766+
rm -rf site
1767+
uv run mkdocs build --strict
1768+
uv run mike deploy --push --allow-empty unstable
17661769
- uses: ./.github/actions/finalize-check
17671770
if: ${{ always() && github.event_name != 'push' }}
17681771
with:

docs/.dockerignore

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

docs/Dockerfile

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

docs/README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,32 @@ and [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/).
99

1010
## Prerequisites
1111

12-
We don't want to force you to set up a Python dev environment: we rely on Docker to build and preview the docs.
13-
Make sure you have [Docker](https://www.docker.com/) installed and running.
14-
15-
You'll then need to build the relevant image:
12+
Install [`uv`](https://docs.astral.sh/uv/getting-started/installation/), a Python toolchain manager and built tool.
13+
Then run:
1614

1715
```bash
18-
docker build -t pavex-docs .
16+
uv sync
1917
```
2018

19+
from the root of the repository.
20+
2121
## Commands
2222

2323
You can preview the docs locally by running from the root of the repository (i.e., the parent folder of
2424
the directory containing this README file):
2525

2626
```bash
27-
docker run --rm -it -p 8001:8000 \
28-
-v ${PWD}:/docs \
29-
pavex-docs
27+
uv run mkdocs serve --open
3028
```
3129

32-
The docs will be available at [http://localhost:8001](http://localhost:8001) and will auto-reload when you make changes.
30+
The docs will be available at [http://localhost:8000](http://localhost:8000) and will auto-reload when you make changes.
3331

3432
The docs embed the auto-generated API reference for the first-party Pavex crates: the command above mounts the
3533
relevant folders so that the docs can access the generated HTML files, but it **won't (re)generate them for you**.\
3634
If you want to generate or update the API reference,
37-
you'll need to run the following command from the root of the repository:
35+
you'll need to run the following commands from the root of the repository:
3836

3937
```bash
40-
cargo api_ref && cp -r target/doc/* ../docs/api_reference
38+
mkdir -p docs/api_reference
39+
cargo api_ref && cp -r target/doc/* docs/api_reference
4140
```

docs/tools/md_slash/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[project]
2-
name = "md-slash"
2+
name = "md_slash"
33
version = "0.1.0"
44
readme = "README.md"
55
description = "MkDocs extension to convert trailing slashes to <br>"
@@ -8,7 +8,7 @@ requires-python = ">=3.11"
88
dependencies = ["Markdown"]
99

1010
[project.entry-points."markdown.extensions"]
11-
trailing_slash = "md-slash:makeExtension"
11+
trailing_slash = "md_slash:makeExtension"
1212

1313
[build-system]
1414
requires = ["hatchling"]

docs/tools/md_slash/uv.lock

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

mkdocs.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
site_name: Pavex
2-
site_url: "https://pavex.dev/"
2+
site_url: "https://pavex.dev/docs/"
33
site_description: "The documentation for Pavex, a framework for building robust APIs in Rust."
44
repo_url: "https://github.com/LukeMathWalker/pavex"
55
repo_name: "LukeMathWalker/pavex"
66
edit_uri: "edit/main/docs/"
77
plugins:
88
# - social
99
- search
10+
- mike:
11+
canonical_version: "latest"
1012
- redirects:
1113
redirect_maps:
1214
"index.md": "overview/index.md"
15+
extra:
16+
version:
17+
provider: "mike"
1318
markdown_extensions:
1419
- admonition
1520
- pymdownx.details

pyproject.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[project]
2+
name = "pavex"
3+
version = "0.1.0"
4+
requires-python = ">=3.13"
5+
dependencies = [
6+
"mike>=2.1.3",
7+
"mkdocs-awesome-pages-plugin>=2.10.1",
8+
"mkdocs-material>=9.6.23",
9+
"mkdocs-redirects>=1",
10+
"pymdown-extensions>=10",
11+
"pygments-ansi-color>=0.3.0",
12+
"pip>=25",
13+
"md_slash"
14+
]
15+
16+
[project.entry-points."markdown.extensions"]
17+
trailing_slash = "md_slash:makeExtension"
18+
19+
[tool.uv.sources]
20+
md_slash = { workspace = true }
21+
22+
[tool.uv.workspace]
23+
members = ["docs/tools/md_slash"]

0 commit comments

Comments
 (0)