Haddock: better support for multiple components
Recently I enhanced support for publishing haddocks of multiple
components (see
this pull request).
It will be available in next release of GHC
(GHC-9.0.2). Note that there is still room for improvement (e.g.
external links to hackage). Currently, there's no tooling support, so it might
still feel a bit hacky.
First one needs to compile haddocks of all the components, which can be done
with either cabal or stack:
cabal haddock --haddock-html \
--haddock-quickjump \
--haddock-option="--use-index=../doc-index.html" \
--haddock-option="--use-contents=../index.html" \
--haddock-option="--base-url=.." \
all
The second step is to copy all the haddocks to a common directory, e.g.
docs folder. To compile the contents page (the haddock entry
page), index with support of quickjump one can run:
haddock -o docs \
--quickjump \
--gen-index \
--gen-contents \
--read-interface=package-a,docs/package-a/package-a.haddock
where one needs to list each component with --read-interface
pointing to the compiled *.haddock interface file.
The docs directory can be served with a local http server or
github-pages. Check out an example project
here. Note that some
settings are hidden in its
cabal.project
file. Its haddocks, which also include haddocks of base library
are available here.