Skip to content

Commit 42885bd

Browse files
committed
Fix broken cross-package Haddock links on hosted docs site
Fixes #601. Cross-package hrefs emitted by cabal haddock-project are relative paths (e.g. href="../cardano-ledger-api-1.2.3-hash/Foo.html") that don't resolve on the published site — we only host cardano-api's own output, not its dependencies, so every cross-package reference 404s by default. Add scripts/fix-haddock-links.sh and wire it into the github-page workflow between haddock-project and the artifact upload. The script replaces each cross-package href with one of: * an absolute URL on the upstream doc site, when the package is on CHaP and we find a valid hosted module page for it; * a tooltip-annotated, unclickable <span>, when the package is not on CHaP (bootlibs like base, bytestring, time are deliberately not linked — Haddock's URL shapes don't match Hackage's well and readers rarely follow the links anyway), or is on CHaP but has no known doc site, or the upstream module page itself 404s. The published site thus has zero clickable 404s. Doc-site resolution For each CHaP package, two lookups in order, first hit wins: 1. Name-suffix heuristic under *.cardano.intersectmbo.org: drop trailing "-token" segments of the package name, HEAD-probe each candidate's doc-index.html. Covers cardano-ledger-*, plutus-*, ouroboros-*, etc. 2. Fixed fallback against IOG_DOC_BASES: a six-entry list of known IOG doc-site roots for families whose subdomain isn't a name-suffix (cardano-base at base.cardano…, network-mux at ouroboros-network.cardano…, io-classes at io-sim, etc.). Misses become "Unmapped CHaP" and fall into the CI policy below. Post-rewrite: Phase 2b uses Haddock's emitted "Source" cabal-store links as ground truth to rewrite local re-export pages back to the defining upstream package (e.g. references to cardano-ledger-byron's Address via Cardano.Api.Byron). Phase 3 HEAD-validates each rewritten URL and rescues dead ones by probing subdirectories (api/, protocols/, framework/) and parent-module fallbacks with #t: fragment reconstruction. Dead-link CI policy (two buckets) Actionable (FAILS CI) — CHaP packages the probe couldn't resolve. Usually a gap in IOG_DOC_BASES; fix by adding the doc site or adding the package to KNOWN_UNDOCUMENTED if genuinely unpublished. Unfixable (logs only, does NOT fail CI) — three sub-causes, all outside this repo: a. Module-level 404s on valid upstream sites; empirically upstream publishes only umbrella modules (Cardano-Binary.html) while Haddock generates hrefs to the defining sub-module (Cardano-Binary-FromCBOR.html). b. Packages in KNOWN_UNDOCUMENTED (no published Haddocks anywhere — currently kes-agent and kes-agent-crypto). c. Haddock-emitted versionless Hackage URLs that Hackage's routing doesn't accept. GitHub Actions actionable entries emit ::warning:: annotations; unfixable ones are plain log lines so they don't flood the UI. Env escape FIX_HADDOCK_LINKS_ALLOW_DEAD=1 forces exit 0 anyway.
1 parent 12b4591 commit 42885bd

2 files changed

Lines changed: 752 additions & 0 deletions

File tree

.github/workflows/github-page.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ jobs:
3939
mkdir website
4040
cabal haddock-project --output=./website --internal --foreign-libraries
4141
42+
- name: Fix cross-package Haddock links
43+
run: |
44+
./scripts/fix-haddock-links.sh ./website
45+
4246
- name: Build typedoc documentation
4347
run: |
4448
nix build .#wasm-typedoc

0 commit comments

Comments
 (0)