Description
I wrote 70% of a patch to add support for including fully linked up source files in the odoc output here. Unfortunately it is against the old version of odoc so will need some work to rebase.
The basic idea is that we add two new types to the model Decl.t
and Defn.t
, which represent points in .mli
and .ml
files respectively. They are just pairs of root names and fresh stamps.
Each kind of component in the model has an optional Decl.t
and an optional Defn.t
that represent where the component is declared and where it is defined. We can use these to generate links from the docs of the components to the appropriate points in the .ml
and .mli
files.
We keep a map from Decl.t
s and Defn.t
s to locations in the .ml
and .mli
files for each compilation unit, so that the .ml
and .mli
files can be appropriately annotated with link targets. We do not keep the .ml
and .mli
files in the .odoc
files: we ask for them at HTML generation time instead.
Most of the code in the branch is about is mapping the Defn.t
s to the right places. We do a pass over the .cmt
file building a kind of trie containing Defn.t
s and we traverse that trie as we process the .cmti
file copying in the Defn.t
s appropriately. If we reach something in the .cmti
that will get expanded during expansion then we attach the trie to that component and use it later to annotate the expanded form with Defn.t
s as well.
We also keep lists of all the non-local paths used in the .ml
/.mli
files. These uses are stored as a pair of a path and a location. We resolve the paths during resolution and then use them during HTML generation to annotate the .ml
and .mli
files with links back into the main documentation. Note that this requires dealing with paths to values, which are not currently handled by the model since they cannot appear in interfaces.