Skip to content

Document Tree model

Jon Ludlam edited this page Sep 3, 2020 · 3 revisions

Currently odoc has a notion of packages from which a module / page belong. This proposal extends that scheme to be more general, to allow for better handling of Libraries, and to allow for the sidebar to be more useful. We replace the 'package' notion with a general parent-child relationship as follows.

  • Allow pages (mld files) and modules to have a parent/child relationship
  • Pages can have page children too
  • Only top-level modules can have specified page parents
  • Replace --package with '--parent'
  • Pages refer to their children with a tag {!child:page-Foo} or {!child:Module} - the latter will insert the text module Module : sig ... end with a link to the child.
  • Pages that don't explicitly refer to their children inline will get them appended to the bottom
  • The side-bar on the page will list the children
  • support {modulelist:Foo} and {modulelist:page-Bar} to list the modules in Foo or the children in a page

This effectively adds support for libraries, both wrapped and unwrapped, by allowing modules to be parented under a library page, which is in turn parented under a package page. This is of course optional, and so wrapped libraries may be parented directly under a package page. Dune/Odig could create these files if they're not explicitly written.

The sidebar would be created by finding the top-most parent and creating a tree from there, using either the module name or first {1 .. } heading in pages as the name. Rendering of the sidebar tree would depend upon how far down the hierarchy the current page/module is.