Skip to content

Commit 9e87ecb

Browse files
committed
docs: single-source the Zensical build recipe in scripts/docs/build.sh
The three-step build (materialise config, zensical build --strict, generate llms.txt) was copy-pasted in shared.yml, docs-preview.yml, and build-docs.sh. Move it into scripts/docs/build.sh and call that everywhere. docs-preview.yml now picks the toolchain from the checkout: pull_request_target runs the workflow file from the base branch, so hardcoding the Zensical steps would break previews for older heads and v1.x-targeted PRs (and previews of this branch before it merges).
1 parent 4793412 commit 9e87ecb

3 files changed

Lines changed: 34 additions & 15 deletions

File tree

.github/workflows/shared.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,5 @@ jobs:
170170
enable-cache: true
171171
version: 0.9.5
172172

173-
- name: Install dependencies
174-
run: uv sync --frozen --all-extras --python 3.10
175-
176-
# Zensical runs no MkDocs plugins/hooks: generate the API reference and
177-
# the concrete config, build strictly, then generate llms.txt.
178173
- name: Build the docs in strict mode
179174
run: bash scripts/docs/build.sh

scripts/build-docs.sh

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,17 @@ trap cleanup EXIT
3636

3737
# Build the checked-out worktree into its local `site/`, picking the toolchain
3838
# from the branch's own files rather than hard-coding it here: a branch that
39-
# ships the Zensical generators (scripts/docs/build_config.py) builds with
40-
# Zensical, otherwise it falls back to MkDocs. This keeps the combined build
41-
# correct regardless of which branch triggered it. Zensical requires site_dir to
42-
# live within the project root, so both paths build to the local `site/` and let
39+
# ships the Zensical build recipe (scripts/docs/build.sh) builds with it,
40+
# otherwise it falls back to MkDocs. This keeps the combined build correct
41+
# regardless of which branch triggered it. Zensical requires site_dir to live
42+
# within the project root, so both paths build to the local `site/` and let
4343
# the caller copy it to its destination.
4444
build_site() {
45-
if [[ -f scripts/docs/build_config.py ]]; then
46-
uv run --frozen --no-sync python scripts/docs/build_config.py
47-
uv run --frozen --no-sync zensical build -f mkdocs.gen.yml --strict
48-
uv run --frozen --no-sync python scripts/docs/llms_txt.py --site-dir site
45+
if [[ -f scripts/docs/build.sh ]]; then
46+
bash scripts/docs/build.sh
4947
else
50-
uv run --frozen --no-sync mkdocs build --site-dir site
48+
uv sync --frozen --group docs
49+
NO_MKDOCS_2_WARNING=1 uv run --frozen --no-sync mkdocs build --site-dir site
5150
fi
5251
}
5352

@@ -62,7 +61,6 @@ build_branch() {
6261

6362
(
6463
cd "$worktree"
65-
uv sync --frozen --group docs
6664
rm -rf site
6765
build_site
6866
mkdir -p "$dest"

scripts/docs/build.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Build the v2 documentation site for this checkout into `site/`.
4+
#
5+
# Zensical runs no MkDocs plugins or hooks, so the build is three steps:
6+
# materialise the API reference pages and the concrete config, build the
7+
# site strictly, then generate llms.txt and the per-page markdown
8+
# renditions. This script is the single owner of that recipe, dependency
9+
# sync included — CI (shared.yml, docs-preview.yml) and scripts/build-docs.sh
10+
# all call it. The toolchain detection in docs-preview.yml and build-docs.sh
11+
# keys on this file's path and expects the site under site/.
12+
#
13+
# Usage:
14+
# scripts/docs/build.sh
15+
#
16+
set -euo pipefail
17+
18+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
19+
# Snippet includes (`--8<--`) resolve against the working directory, which
20+
# must therefore be the repo root.
21+
cd "$SCRIPT_DIR/../.."
22+
23+
uv sync --frozen --group docs
24+
uv run --frozen --no-sync python scripts/docs/build_config.py
25+
uv run --frozen --no-sync zensical build -f mkdocs.gen.yml --strict
26+
uv run --frozen --no-sync python scripts/docs/llms_txt.py --site-dir site

0 commit comments

Comments
 (0)