Devlog 2026-W08 › A setup for proper documentation › Installing the documentation using dune [KVLS]

Below is an abbreviated version of the dune file.

(executable
 (public_name forester-docs)
 (name forester_docs)
 (libraries
  ...))

(rule
 (targets
  (dir output))
 (deps
  ./forester_docs.exe
  (source_tree trees))
 (action
  (run ./forester_docs.exe)))

(install
 (section
  (site
   (forester docs)))
 (dirs
  (output as forest)))

The rule stanza tells dune to run the forester_docs executable, which builds the documentation. The deps stanza tells dune that this depends on the files contained in the trees directory. The result is this file: _build/default/docs/output/docs.json.

The install stanza tells dune to copy the resulting file to the installation directory, which in this case is something like $OPAM_DIR/man/docs/forest.