Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
By default doc-gen4 documents a library together with its entire import closure, so a project built on Mathlib regenerates all of Mathlib's documentation (often several GB). Add two environment variables that instead generate pages for only the project's own modules and link references to its dependencies out to their hosted documentation: - DOCGEN_LOCAL_MODULE_ROOTS: comma-separated local module namespaces. A module whose root is not listed is treated as external, and its pages are not generated. - DOCGEN_DEPS_DOCS_URL: base URL of the dependencies' documentation site, e.g. https://leanprover-community.github.io/mathlib4_docs. References to a declaration in an external module link to that site's /find resolver, which looks the declaration up by name and so tolerates the dependency's docs being built from a slightly different revision; module-level links point directly at the corresponding page. When DOCGEN_LOCAL_MODULE_ROOTS is unset the behaviour is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
b65d39c to
4cac5a7
Compare
…docs (#1092) Switch the /docs build to doc-gen4 with interproject linking (leanprover/doc-gen4#396, pinned to the fork until it lands upstream): render pages for only the TauCeti.* modules and link references to Mathlib and Lean core out to the hosted mathlib4_docs, instead of rendering the whole import closure locally. The published artifact drops from ~960 MB to ~33 MB, so deploys are fast and stay well under the GitHub Pages size limit as the library grows. docbuild now pins the fork's v4.32.0 revision, matching the repository toolchain. Claude-Session: https://claude.ai/code/session_01YNbagXozDSSffYZhLxvd98 Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Would this be hard to generalize to per-dependency URLs? |
Done. |
I note that this adds a bit of latency to actually navigating the docs. An alternative is to link to the exact url. |
Yes, but header-data.bmp won't work reliably if there is any version skew between the docs sites, while |
By default
doc-gen4documents a library together with its entire import closure, so a project built on top of a large dependency such as Mathlib regenerates the dependency's documentation too — often several GB, and close to the GitHub Pages ~1 GB artifact limit. This PR adds an opt-in mode that generates pages for only the project's own modules and links references to its dependencies out to their already-published documentation.Three environment variables control it (in the spirit of the existing
DOCGEN_SRC):DOCGEN_LOCAL_MODULE_ROOTS— a comma-separated list of the top-level module namespaces that belong to your project (e.g.MyProject). A module whose root is not listed is treated as external, and its pages are not generated.DOCGEN_DEPS_DOCS_URL— an optional fallback base URL for external dependency documentation, e.g.https://leanprover-community.github.io/mathlib4_docs.DOCGEN_DEPS_DOCS_URLS— optional comma-separated per-root overrides of the formRoot=URL, e.g.Mathlib=https://.../mathlib4_docs,Batteries=https://.../batteries_docs. List multiple roots separately when one dependency owns multiple top-level namespaces.For each external module, a per-root entry takes precedence over the fallback URL. A reference to an external declaration links to the selected site's
/findresolver (…/find/?pattern=<decl>#doc), which looks the declaration up by name and so tolerates the dependency's docs being built from a slightly different revision than the one being linked against; module-level links point directly at the corresponding page. Every external module root must have either a per-root entry or a fallback, anddoc-gen4reports a configuration error rather than producing broken local links when a mapping is missing.The excluded modules stay in the linking context so cross-references still resolve. When
DOCGEN_LOCAL_MODULE_ROOTSis unset, the behaviour is unchanged.The change is localized to the two link builders (
moduleNameToLink/declNameToLink), dependency-URL selection and validation, and a render-set filter infromDb, with the configuration read ingetSimpleBaseContext. The README documents the variables. The multi-library regression test now also covers distinct dependency sites, fallback links, trailing-slash normalization, omitted dependency pages, and incomplete-configuration errors.Validated end-to-end against Tau Ceti, a ~580-module Mathlib-downstream library: with
DOCGEN_LOCAL_MODULE_ROOTS=TauCeti, only the 581 TauCeti pages are generated (noMathlib/Init/Std/… trees), references to Mathlib declarations link tomathlib4_docs, and there are no broken local links — cutting the output from ~963 MB to tens of MB.