Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Commit 93bf08c

Browse files
committed
Document multi component support
1 parent f2aaf7b commit 93bf08c

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

doc/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Contents:
1212
intro
1313
invoking
1414
markup
15+
multi-components
1516

1617

1718
Indices and tables

doc/multi-components.rst

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Haddocks of multiple components
2+
===============================
3+
4+
Haddock supports building documentation of multiple components. First, one
5+
needs to build haddocks of all components which can be done with:
6+
7+
.. code-block:: none
8+
9+
cabal haddock --haddock-html \
10+
--haddock-quickjump \
11+
--haddock-option="--use-index=../doc-index.html" \
12+
--haddock-option="--use-contents=../index.html" \
13+
--haddock-option="--base-url=.." \
14+
all
15+
16+
The new ``--base-url`` option will allow to access the static files from the
17+
main directory (in this example its the relative ``./..`` directory). It will
18+
also prevent ``haddock`` from copying its static file to each of the
19+
documentation folders, we're only need a single copy of them where the
20+
``--base-url`` option points to.
21+
22+
The second step requires to copy all the haddocks to a common directory, let's
23+
say ``./docs``, this will depend on your project and it might look like:
24+
25+
.. code-block:: none
26+
27+
cp -r dist-newstyle/build/x86_64-linux/ghc-9.0.1/package-a-0.1.0.0/doc/html/package-a/ docs
28+
cp -r dist-newstyle/build/x86_64-linux/ghc-9.0.1/package-b-0.1.0.0/doc/html/package-b/ docs
29+
30+
Note that you can also include documentation of other packages in this way,
31+
e.g. ``base``, but you need to know where it is hidden on your hard-drive.
32+
33+
To build html and js (``quickjump``) indexes one can now invoke ``haddock`` with:
34+
35+
.. code-block:: none
36+
37+
haddock \
38+
-o docs \
39+
--quickjump --gen-index --gen-contents \
40+
--read-interface=package-a,docs/package-a/package-a.haddock \
41+
--read-interface=package-b,docs/package-b/package-b.haddock
42+
43+
Note: the ``PATH`` in ``--read-interface=PATH,...`` must be a relative url of
44+
a package it points to (relative to the ``docs`` directory).
45+
46+
There's an example project which shows how to do that posted `here
47+
<https://github.com/coot/haddock-example>`_, which haddocks are served on
48+
`github-pages <https://coot.github.io/haddock-example>`_.

0 commit comments

Comments
 (0)