forked from modelcontextprotocol/python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·75 lines (66 loc) · 3.74 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·75 lines (66 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
#
# Build the v2 documentation site for this checkout into `site/`: the English
# site at the root, then one translated site per language in
# i18n/languages.yml under `site/<code>/`.
#
# Zensical runs no MkDocs plugins or hooks, so the English build is three
# steps: materialise the API reference pages and the concrete config, build
# the site strictly (plus the order-independence and cross-reference checks
# Zensical doesn't do itself), then generate llms.txt and the per-page
# markdown renditions. A language site is lighter: the translation tool stages
# a docs tree (English pages overlaid with that language's translations),
# build_config.py writes its config, and Zensical builds it (non-strict: a
# dead link or anchor in a translation is a warning, counted at the end)
# straight into site/<code>/ — no API reference (it links the English one),
# so no render-order or cross-reference checks. This script is the single
# owner of that recipe, dependency sync included — CI (shared.yml,
# docs-preview.yml) and scripts/build-docs.sh all call it. The toolchain
# detection in docs-preview.yml and build-docs.sh keys on this file's path and
# expects the site under site/.
#
# Usage:
# scripts/docs/build.sh (DOCS_LANGUAGES=en-only skips the language sites)
#
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Snippet includes (`--8<--`) resolve against the working directory, which
# must therefore be the repo root.
cd "$SCRIPT_DIR/../.."
uv sync --frozen --group docs
# Zensical's incremental cache is unsound: a warm rebuild where only some
# pages re-render silently drops cross-references to cache-hit pages, and
# HTML for since-deleted pages lingers in site/. Build cold so the output
# (and the checks below) are deterministic. Staged language trees likewise.
rm -rf .cache site .build/i18n
uv run --frozen --no-sync python scripts/docs/build_config.py
uv run --frozen --no-sync zensical build -f mkdocs.gen.yml --strict
# The build above renders pages in one arbitrary (filesystem-dependent)
# order; prove the API reference renders in hostile orders too — see the
# check's docstring for the failure mode this guards.
uv run --frozen --no-sync python scripts/docs/check_render_order.py
# Zensical stays green even under --strict when a cross-reference fails to
# resolve (rendered as literal bracket text) or an objects.inv inventory
# fails to download (every link through it silently degrades to plain text);
# MkDocs strict mode aborted on both. Validate the built site instead.
uv run --frozen --no-sync python scripts/docs/check_crossrefs.py --site-dir site
uv run --frozen --no-sync python scripts/docs/llms_txt.py --site-dir site
# Language sites build after English: `zensical build` clears its site_dir, so
# the English build (site_dir site/) would wipe every site/<code>/, while a
# language build (site_dir site/<code>/) leaves its parent alone. All the
# language trees are staged in one pass, which reads the English pages once.
languages=""
if [[ "${DOCS_LANGUAGES:-}" != "en-only" ]]; then
languages="$(PYTHONPATH=scripts/docs uv run --frozen --no-sync python -c \
'import build_config; print(*(language.code for language in build_config.load_registry().languages))')"
uv run --frozen --no-sync python scripts/docs/translations.py stage
fi
for lang in $languages; do
echo "=== Building language site: ${lang} ==="
uv run --frozen --no-sync python scripts/docs/build_config.py --lang "$lang"
rm -rf .cache
log=".build/i18n/${lang}/build.log"
uv run --frozen --no-sync zensical build -f "mkdocs.${lang}.gen.yml" 2>&1 | tee "$log"
# Zensical reports each dead link/anchor as a "Warning:" diagnostic on stderr.
echo "${lang}: $(grep -c 'Warning:' "$log" || true) warnings"
done