Devlog 2026-W08 [6QYO]
- February 19, 2026
- Kento Okura
A setup for proper documentation [L3OL]
- February 19, 2026
- Kento Okura
Last week I wrote about shipping a default theme with forester using dune’s install mechanism. I realized that I could use this to bring a great offline documentation experience to forester. Achieving this ended being a simple exercise in some basic dune features.
Building the documentation [JODH]
- February 19, 2026
- Kento Okura
I wrote some code that builds a forest and produces a JSON blob using the JSON syndication feature. Here is the relevant part:
let syndication =
let blob_uri = URI.of_string_exn "http://forester-docs/index" in
let query = Datalog_expr.{ ... } in
Types.{blob_uri; query}
in
Forester.outputs_for_json_blob_syndication ~forest syndicationInstalling the documentation using dune [KVLS]
- February 19, 2026
- Kento Okura
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.
Delivering to the user [UNAU]
- February 19, 2026
- Kento Okura
Now that the documentation is installed on the user’s system, we will use dune sites to implant the documentation into the users forest in dev mode.
let config =
if dev then
let doc_json_blob =
List.hd Theme_site.Sites.docs ^"/forest/docs.json"
in
{
config with
foreign =
[
{
path = doc_json_blob;
route_locally = true;
include_in_manifest = true;
};
];
}
else configinclude_in_manifest = true means that the documentation is searchable using the familiar CTRL-k keybinding. In dev mode we render a link to the docs in the header:
let page_template =
html []
[
...
conditional dev render_doc_button;
...
]Future steps [9UD6]
- February 19, 2026
- Kento Okura
Besides actually writing the documentation, I’d like to find a good solution for documenting Forester’s features directly in the source code. An initial idea was to write a preprocessor that allows me to annotate Forester’s source code with Forester syntax. Anil has kindly made me aware of Jon Ludlam’s work on odoc. Having had a cursory look at what is possible makes me hopeful that we can come up with a system that easily allows us to keep the Forester’s documentation up to date at all times.