Documentation

DocGen4.Output.External

External documentation linking #

This module holds the hardcoded base URL and link constructors used when doc-gen4 needs to refer to a declaration or module that was NOT analyzed locally. The expected use case is that the consuming project documents only its own modules and links every other reference (Lean core, Mathlib, other dependencies) to the Mathlib documentation site.

The "find redirect" form for declarations is the same scheme used by Zulip's docs#Foo: the external site's static declaration-data.bmp + find.js resolve the owning module client-side, so we don't need to know it.

To point this at a different external site (e.g. a private Mathlib mirror or an entirely different ecosystem), edit externalDocBase below. This is intentionally a Lean constant rather than an environment variable so the behavior is reproducible and reviewable. See docs/dev/design/external-linking.md for the full rationale.

Callers:

The base URL all external references resolve under. Must end with a trailing slash. Edit this if your project targets a different external documentation site.

Equations
Instances For

    Decide whether a Name is worth emitting as an external find-redirect link.

    The Lean pretty printer occasionally tags single-character identifiers (bound variable names like x, n, c) and numeric literals (0, 3) with declaration metadata. When such a tag falls through to the external fallback in renderedCodeToHtmlAux, the resulting find/?pattern=<token>#doc URL is guaranteed to 404 on the external site. We filter those out and let the caller emit an un-linked span instead.

    Rule: a name is linkable if every component contains at least one alphabetic character AND the joined display form is at least two characters long. This keeps real short names like Eq, IO, Id linkable while dropping single-character bound variables and pure-numeric tokens.

    Equations
    Instances For