@@ -55,18 +55,57 @@ jobs:
5555
5656 - name : Build documentation (Linglib only, skip Mathlib)
5757 run : |
58- # Use Lake's docs facet directly. `library_facet docs` (defined
59- # in doc-gen4) only documents Linglib's own modules; transitive
60- # Mathlib oleans are loaded into memory for symbol resolution
61- # but not documented. Lake parallelizes per-module `docInfo`
62- # jobs natively. `-j 2` caps concurrency to keep memory under
63- # the 16 GB runner limit (each docInfo job loads the module's
64- # full Mathlib import closure into memory).
65- #
66- # Stale DB cleanup: doc-gen4 schema changes across versions
58+ # Use doc-gen4 CLI directly. The Lake `:docs` facet cascades
59+ # docInfo jobs into Mathlib (~2700+ targets for any Linglib
60+ # module that imports mathlib), which OOMs the runner. The
61+ # CLI's `single` only writes docs for the named module — its
62+ # imports are loaded into memory but not documented.
63+ lake build doc-gen4
64+
65+ BUILD=.lake/build
66+ DOCGEN="lake exe doc-gen4"
67+ REPO_URL="https://github.com/${{ github.repository }}"
68+ COMMIT="${{ github.sha }}"
69+ SRC_URI="$REPO_URL/blob/$COMMIT"
70+ DB=api-docs.db
71+ export BUILD DOCGEN SRC_URI DB
72+
73+ # Remove stale DB — schema changes across doc-gen4 versions
6774 # cause "no such table" errors if an old DB is reused.
68- rm -f .lake/build/api-docs.db api-docs.db
69- lake -j 2 build Linglib:docs
75+ rm -f "$BUILD/$DB" "$DB"
76+
77+ # Bibliography prepass
78+ if [ -f docs/references.bib ]; then
79+ $DOCGEN bibPrepass --build "$BUILD" docs/references.bib
80+ elif [ -f docs/references.json ]; then
81+ $DOCGEN bibPrepass --build "$BUILD" --json docs/references.json
82+ else
83+ $DOCGEN bibPrepass --build "$BUILD" --none
84+ fi
85+
86+ # Document root module (may fail if Linglib.olean missing — non-fatal)
87+ $DOCGEN single --build "$BUILD" Linglib "$DB" "$SRC_URI/Linglib.lean" || true
88+
89+ # Document all Linglib submodules in parallel (-P 4 cores).
90+ # Each invocation writes to a shared SQLite db with WAL +
91+ # 24h busy timeout (see doc-gen4/Main.lean:walCheckpoint),
92+ # and updateModuleDb uses immediate transactions per
93+ # 100-module batch, so concurrent writers are safe.
94+ # Memory: each `single` peaks ~3-4 GB (mathlib import closure);
95+ # 4 in parallel ≈ 12-16 GB on a 16 GB runner. If we OOM,
96+ # drop -P to 2.
97+ find Linglib -name '*.lean' | sort | \
98+ xargs -I{} -P 4 sh -c '
99+ f="$1"
100+ mod=$(echo "$f" | sed "s|/|.|g; s|\.lean$||")
101+ echo " doc: $mod"
102+ $DOCGEN single --build "$BUILD" "$mod" "$DB" "$SRC_URI/$f" || true
103+ ' _ {}
104+
105+ # Generate HTML + search index from database
106+ # NOTE: fromDb treats the db arg as a literal path (not relative
107+ # to --build), unlike single/genCore which prepend --build.
108+ $DOCGEN fromDb --build "$BUILD" "$BUILD/$DB"
70109
71110 - name : Install Hugo
72111 uses : peaceiris/actions-hugo@v3
0 commit comments