Skip to content

Haddock support for multiple packages

Marcin Szamotulski requested to merge coot/json-index into ghc-8.10

Description

This package allows to create documentation for multiple packages. This is useful if one has multiple packages in a single repository.

Workflow

Add the following lines to cabal.project.local file (for every package):

package some-package-1
  haddock-options: --use-index=../doc-index.html --use-contents=../index.html --base-url=..

package some-package-2
  haddock-options: --use-index=../doc-index.html --use-contents=../index.html --base-url=..

Run

cabal haddock --haddock-html --haddock-quickjump all

Copy documentation to a common directory (docs in this example), e.g.

cp -r ./dist-newstyle/build/x86_64-linux/ghc-8.10.2/some-pakcage-1-0.1.0.0/noopt/doc/html/some-package-1 docs
cp -r ./dist-newstyle/build/x86_64-linux/ghc-8.10.2/some-pakcage-2-0.1.0.0/noopt/doc/html/some-package-2 docs

Run:

haddock -o haddocks --quickjump --gen-index --gen-contents -isome-package-1,docs/some-package-1/some-package-1.haddock -isome-package-2,docs/some-package-2/some-package-2.haddock

Serve docs directory and enjoy the documentation with a single html index and QuickSearch working across all projects.

Changes

  • Using aeson for serialisation and deserialisation of doc-index.json files;
  • doc-index.json file for the summary page is generated from doc-index.json files of all packages included with --read-interface option (-i);
  • added --base-url flag (Flag_BaseURL). If given and not equal to . or ./ static files (css, js, json) will not be copied. All pages will load them from the given url.

Target branch

I am not sure which target branch I should pick for this PR, I choose ghc-8.10 as this is the current version of ghc.

Edited by Marcin Szamotulski

Merge request reports