odoc work?odoc is built in a very modular fashion, with several modules that take care of mostly orthogonal concerns.
Instead of namedropping them, we will describe a use-case and how they connect to each other as we analyze its execution superficially.
We will begin the flow with an odoc command that compiles a single cmti file, Player.cmti, into its corresponding html file. Then we will compile the intro.mld documentation file into html.
Off we go!
Superficially, what we need to do is straighforward.
# We must tell odoc what the name of this Package is!
$ odoc compile --package Game -o ./src/Player.odoc ./src/Player.cmti
$ ls src
Player.cmti Player.mli Player.odocVoila! We get a Player.odoc right where we expected it. But what really just happened?
Main the command was parsed and a decision was made to compile this file into an odoc fileMain.Compile.compile, that based on the input extension will delegate to one of many Compile functions. In this case Compile.cmticmti file is read by Odoc_loader.read_cmti into a Odoc_model.Root.t and a Compilation_unit.t is createdEnv.t (environment), expanding all found references between modulesCompilation_unit.save takes care of saving this compilation unit into the Player.odoc file in marshalled format.Now we can compile this to an HTML file:
$ odoc html -I src -o . ./src/Player.odoc
$ cat Game/Player/index.html
# mangled html output here!In this case, what happened was
Main the command is parsed as well, and it decides to compile the input into an html file.Main.Odoc_html.html, that will make sure some global flags are set up (depending on command flags), and delegate to Html_page.from_odocodoc file is read into a Odoc_model.Root.tOdoc_model.Root.Odoc_file.t.Compilation_unit, an Env.t (environment) will be built, with its references expanded, just like in the first stepOdoc_html.Html_tree.t will be built, depending on the syntax chosen (in this case the default is OCaml) by Odoc_html.To_html_tree.ML.compilation_unitGame/Player folder created, and the index.html file written to disk.We will begin by invoking odoc similarly than we did in the first step.
$ odoc compile --package Game -o ./src/page-intro.odoc ./src/page-intro.mld
$ ls src
page-intro.mld page-intro.odocMain the command was parsed and a decision was made to compile this file into an odoc fileMain.Compile.compile, and it delegates compilation to Compile.mld based on the extension of the inputOdoc_model.Lang.Page.t will be created from it, and an Env.t will be built resolving found referencesPage.save$ odoc html -I src -o . ./src/page-intro.odoc
$ cat Game/intro.html
# mangled html output here!This process is in fact almost the same as in the last html compilation. The main differences are that:
Odoc_model.Root.t contains a Odoc_model.Root.Odoc_file.t.Page instead,page- prefix,Odoc_html.Html_tree.t is built by Odoc_html.To_html_tree.ML.page