How to get pleasant documentation for a library using Dune?

Thanks! It looks like these systems rely on an undocumented feature of the (documentation) stanza (or odoc), which is that a user-provided index.mld file will implicitly replace the automatically-generated index.mld file, giving a reasonably natural result.

The opium documentation also uses the {!modules: modulename ...} markup directive, which is a way to include the module index within this manually-written landing page without having to duplicate the markup. Streaming¹ uses inline html instead to get a nicer-looking result, but it is too much effort. Maybe there is a better way, or the tools could be improved to make this easier.

¹: I’m ashamed to admit that I wasn’t aware of this very nice library Streaming, am I consuming the wrong sources of information on the OCaml ecosystem?

Finally, the Opium documentation manifestly has a short synopsis for each module in its listing, which corresponds to my “It should briefly describe what each module does” requirement. I believe that this comes from the first line of the first documentation comment of the module. There are module-global documentation comments in the library I’m working on, but they do not include such first-line headers.

Once I have the impression of understanding what is a good way to do this, I may try to contribute better documentation in dune.

3 Likes