@@ -5,13 +5,13 @@ projects. However, it operates at a rather low level, taking individual files
55through several distinct phases until the HTML output is generated.
66
77For this reason, just like for building any multifiles OCaml project, [odoc]
8- needs to be driver by a higher level tool. The driver will take care of calling
8+ needs to be driven by a higher level tool. The driver will take care of calling
99the [odoc] command with the right arguments throughout the different
1010phases. Several drivers for [odoc] exist, such as:
1111{{:https://dune.readthedocs.io/en/stable/documentation.html}dune} and
1212{{:https://erratique.ch/software/odig}odig}.
1313
14- The [odoc] tools also contains a "reference driver", that is kept up-to-date
14+ The [odoc] tool also contains a "reference driver", that is kept up-to-date
1515with the latest development of [odoc].
1616
1717This document explains how to drive [odoc], as of version 3. It is not needed to
@@ -32,11 +32,11 @@ implementation code, but it can also help to simply look at all invocations of
3232
3333In its third major version, [odoc] has been improved so that the same
3434documentation can work on multiple scenarios, from local switches to big
35- monorepos, or the ocaml.org hub of documentation for all packages, without
35+ monorepos, or the {{:https:// ocaml.org/packages}ocaml.org} hub of documentation for all packages, without
3636anything breaking, especially references.
3737
38- The idea is that we have named group of documentation, that we'll call {e trees}
39- here. We have two kinds of them : page trees, and modules trees. Inside the
38+ The idea is that we have named groups of documentation, that we'll call {e trees}
39+ here. We have two kinds of trees : page trees, and modules trees. Inside the
4040trees, everything is managed by [odoc]. The driver is free to root them however
4141they like in the overall hierarchy. In order to reference another tree, a
4242documentation author can use the name of the tree in the reference.
@@ -58,16 +58,16 @@ file might reside in another one. However, [odoc] actually allows a particular
5858file to reference a module that depends on it, seemingly creating a circular
5959dependency.
6060
61- This circular dependency problem is one of the reason we have several phases in
61+ This circular dependency problem is one of the reasons we have several phases in
6262[odoc]. Let's review them:
6363
6464- The [compile] phase, which is used to create the [.odoc] artifacts from
6565 [.cm{i;t;ti}] and [.mld] files. This is where [odoc] does similar work to
66- that of OCaml, computing expansions for each module types. The dependencies
66+ that of the OCaml compiler , computing expansions for each module types. The dependencies
6767 between are the same as the ones for the [.cm{i;t;ti}] input.
6868
6969- The [link] phase transforms the [.odoc] artifacts to [.odocl]. The main result
70- of this phase is to resolve odoc reference , which also has an effect on
70+ of this phase is to resolve odoc references , which also has an effect on
7171 canonical modules.
7272
7373- The [indexing] phase generates [.odoc-index] files from sets of [.odocl]
@@ -95,7 +95,7 @@ Let's have a look at a generic invocation of [odoc] during the compile phase:
9595]}
9696
9797- [<input-file>.<ext>] is the input file, either a [.cm{i;t;ti}] file or an [.mld]
98- file. Prefer [.cmti] files over the other format !
98+ file. Prefer [.cmti] files over the other formats !
9999
100100- [--output-dir <od>] allows to specify the directory that will contain all the
101101 [.odoc] files. This directory has to be fully managed by [odoc] and should not
@@ -108,18 +108,30 @@ Let's have a look at a generic invocation of [odoc] during the compile phase:
108108 [.odoc] file will be located below the [<od>] output dir. The name of the
109109 output file is [<input-file>.odoc] for modules, and [page-<input-file>.odoc]
110110 for pages. Documentation artifacts that will be in the same {{!units}unit of
111- documentation} needs to hare a common root in their parent id.
111+ documentation} need to hare a common root in their parent id.
112112
113- - [-I <dir>] corresponds to the search path for other [.odoc] file . It can be
113+ - [-I <dir>] corresponds to the search path for other [.odoc] files . It can be
114114 given as many times as necessary, but should allow to access every [.odoc]
115115 file generated from a [.cm{i;t;ti}] listed when calling [odoc compile-deps] on
116116 the input file. [<dir>] are directories under the [<od>] directory, computed
117- from the [--parent-id] option given to previous call to [odoc compile].
117+ from the [--parent-id] option given to previous calls to [odoc compile].
118118
119119A concrete example for such command would be:
120120
121121{@shell[
122- $ odoc compile ~/.opam/5.2.0/lib/ppxlib/ppxlib__Extension.cmti --output-dir _odoc/ -I _odoc/ocaml-base-compiler/lib/compiler-libs.common -I _odoc/ocaml-base-compiler/lib/stdlib -I _odoc/ocaml-compiler-libs/lib/ocaml-compiler-libs.common -I _odoc/ppxlib/lib/ppxlib -I _odoc/ppxlib/lib/ppxlib.ast -I _odoc/ppxlib/lib/ppxlib.astlib -I _odoc/ppxlib/lib/ppxlib.stdppx -I _odoc/ppxlib/lib/ppxlib.traverse_builtins -I _odoc/sexplib0/lib/sexplib0 --parent-id ppxlib/lib/ppxlib
122+ $ odoc compile
123+ ~/.opam/5.2.0/lib/ppxlib/ppxlib__Extension.cmti
124+ --output-dir _odoc/
125+ -I _odoc/ocaml-base-compiler/lib/compiler-libs.common
126+ -I _odoc/ocaml-base-compiler/lib/stdlib
127+ -I _odoc/ocaml-compiler-libs/lib/ocaml-compiler-libs.common
128+ -I _odoc/ppxlib/lib/ppxlib
129+ -I _odoc/ppxlib/lib/ppxlib.ast
130+ -I _odoc/ppxlib/lib/ppxlib.astlib
131+ -I _odoc/ppxlib/lib/ppxlib.stdppx
132+ -I _odoc/ppxlib/lib/ppxlib.traverse_builtins
133+ -I _odoc/sexplib0/lib/sexplib0
134+ --parent-id ppxlib/lib/ppxlib
123135]}
124136
125137{3 Compiling implementations}
@@ -135,19 +147,32 @@ A [compile-impl] command is pretty similar:
135147- [--output-dir <od>] has the same meaning as for [odoc compile].
136148
137149- [--parent-id <pid>] also has the same meaning as for [odoc compile]. However,
138- the name of the output file is [impl-<input-file>.odoc]. Implementations needs
150+ the name of the output file is [impl-<input-file>.odoc]. Implementations need
139151 to be available through the [-I] search path, so it is very likely that one
140152 wants the implementation and interface [.odoc] files to share the same parent
141153 id.
142154
143- - [-I <dir>] also corresponds to the search path for other [.odoc] file .
155+ - [-I <dir>] also corresponds to the search path for other [.odoc] files .
144156
145157- [source-id <sid>] is a new argument specific to [compile-impl]. This corresponds to the location of the rendering of the source, which is required to generate links to it.
146158
147159A concrete example for such command would be:
148160
149161{@shell[
150- $ odoc compile-impl ~/.opam/5.2.0/lib/ppxlib/ppxlib__Spellcheck.cmt --output-dir _odoc/ -I _odoc/ocaml-base-compiler/lib/compiler-libs.common -I _odoc/ocaml-base-compiler/lib/stdlib -I _odoc/ocaml-compiler-libs/lib/ocaml-compiler-libs.common -I _odoc/ppxlib/lib/ppxlib -I _odoc/ppxlib/lib/ppxlib.ast -I _odoc/ppxlib/lib/ppxlib.astlib -I _odoc/ppxlib/lib/ppxlib.stdppx -I _odoc/sexplib0/lib/sexplib0 --enable-missing-root-warning --parent-id ppxlib/lib/ppxlib --source-id ppxlib/src/ppxlib/spellcheck.ml
162+ $ odoc compile-impl
163+ ~/.opam/5.2.0/lib/ppxlib/ppxlib__Spellcheck.cmt
164+ --output-dir _odoc/
165+ -I _odoc/ocaml-base-compiler/lib/compiler-libs.common
166+ -I _odoc/ocaml-base-compiler/lib/stdlib
167+ -I _odoc/ocaml-compiler-libs/lib/ocaml-compiler-libs.common
168+ -I _odoc/ppxlib/lib/ppxlib
169+ -I _odoc/ppxlib/lib/ppxlib.ast
170+ -I _odoc/ppxlib/lib/ppxlib.astlib
171+ -I _odoc/ppxlib/lib/ppxlib.stdppx
172+ -I _odoc/sexplib0/lib/sexplib0
173+ --enable-missing-root-warning
174+ --parent-id ppxlib/lib/ppxlib
175+ --source-id ppxlib/src/ppxlib/spellcheck.ml
151176]}
152177
153178{3 Compiling assets}
@@ -205,14 +230,14 @@ The indexing phase refers to the "crunching" of information split in several
205230
206231- Generating a search index. This requires all information from linked
207232 interfaces and pages, but also form linked implementations in order to sort
208- results (by number of occurrence ).
233+ results (by number of occurrences ).
209234
210235- Generating a global sidebar.
211236
212237{3 Counting occurrences}
213238
214239This step counts the number of occurrences of each value/type/... in the
215- implementation, and stores them in a big table. A generic invocation is:
240+ implementation, and stores them in a table. A generic invocation is:
216241
217242{@shell[
218243 $ odoc count-occurrences <dir1> <dir2> -o <path/to/name.odoc-occurrences>
@@ -233,13 +258,33 @@ To create an index for the page and documentation units, we use the [-P] and
233258[-L] arguments.
234259
235260{@shell[
236- $ odoc compile-index -o path/to/<indexname>.odoc-index -P <pname1>:<ppath1> -P <pname2>:<ppath2> -L <lname1>:<lpath1> -L <lname2>:<lpath2> --occurrences <path/to/name.odoc-occurrences>
261+ $ odoc compile-index
262+ -o path/to/<indexname>.odoc-index
263+ -P <pname1>:<ppath1>
264+ -P <pname2>:<ppath2>
265+ -L <lname1>:<lpath1>
266+ -L <lname2>:<lpath2>
267+ --occurrences <path/to/name.odoc-occurrences>
237268]}
238269
239270An example of such command:
240271
241272{@shell[
242- $ odoc compile-index -o _odoc/ppxlib/index.odoc-index -P ppxlib:_odoc/ppxlib/doc -L ppxlib:_odoc/ppxlib/lib/ppxlib -L ppxlib.ast:_odoc/ppxlib/lib/ppxlib.ast -L ppxlib.astlib:_odoc/ppxlib/lib/ppxlib.astlib -L ppxlib.metaquot:_odoc/ppxlib/lib/ppxlib.metaquot -L ppxlib.metaquot_lifters:_odoc/ppxlib/lib/ppxlib.metaquot_lifters -L ppxlib.print_diff:_odoc/ppxlib/lib/ppxlib.print_diff -L ppxlib.runner:_odoc/ppxlib/lib/ppxlib.runner -L ppxlib.runner_as_ppx:_odoc/ppxlib/lib/ppxlib.runner_as_ppx -L ppxlib.stdppx:_odoc/ppxlib/lib/ppxlib.stdppx -L ppxlib.traverse:_odoc/ppxlib/lib/ppxlib.traverse -L ppxlib.traverse_builtins:_odoc/ppxlib/lib/ppxlib.traverse_builtins --occurrences _odoc/occurrences-all.odoc-occurrences
273+ $ odoc compile-index
274+ -o _odoc/ppxlib/index.odoc-index
275+ -P ppxlib:_odoc/ppxlib/doc
276+ -L ppxlib:_odoc/ppxlib/lib/ppxlib
277+ -L ppxlib.ast:_odoc/ppxlib/lib/ppxlib.ast
278+ -L ppxlib.astlib:_odoc/ppxlib/lib/ppxlib.astlib
279+ -L ppxlib.metaquot:_odoc/ppxlib/lib/ppxlib.metaquot
280+ -L ppxlib.metaquot_lifters:_odoc/ppxlib/lib/ppxlib.metaquot_lifters
281+ -L ppxlib.print_diff:_odoc/ppxlib/lib/ppxlib.print_diff
282+ -L ppxlib.runner:_odoc/ppxlib/lib/ppxlib.runner
283+ -L ppxlib.runner_as_ppx:_odoc/ppxlib/lib/ppxlib.runner_as_ppx
284+ -L ppxlib.stdppx:_odoc/ppxlib/lib/ppxlib.stdppx
285+ -L ppxlib.traverse:_odoc/ppxlib/lib/ppxlib.traverse
286+ -L ppxlib.traverse_builtins:_odoc/ppxlib/lib/ppxlib.traverse_builtins
287+ --occurrences _odoc/occurrences-all.odoc-occurrences
243288]}
244289
245290{2 The generation phase}
@@ -249,14 +294,14 @@ previous files, and actually generates the documentation. It can take the form
249294of HTML, Latex and manpages, although currently HTML is the [odoc] backend that
250295supports the most functionalities (such as images, videos, ...).
251296
252- In this manual, we describe the situation for generating HTML . Usually,
297+ In this manual, we describe the HTML generation usecase . Usually,
253298generating for other backend boils down to replacing [html-generate] by
254299[latex-generate] or [man-generate], refer to the manpage to see the diverging
255300options.
256301
257302Given an [.odocl] file, [odoc] might generate a single [.html] file, or a
258303complete directory of [.html] files. The [--output-dir] option specifies the
259- root for generating those output .
304+ root for generating those outputs .
260305
261306{3 A JavaScript file for search requests}
262307
@@ -270,7 +315,7 @@ web worker to perform searches:
270315- The web worker has to send back the result as a message to the main thread,
271316 containing the list of results. The format is defined in the TODO.
272317
273- - The file must be manually put in the [--output-dir] values, the driver can
318+ - The JavaScript file must be manually put in the [--output-dir] values, the driver can
274319 decide where.
275320
276321{3 Interfaces and pages}
@@ -281,7 +326,8 @@ A generic [html-generate] command for interfaces has the following form:
281326 $ odoc html-generate
282327 --output-dir <odir>
283328 --index <path/to/file.odoc-index>
284- --search-uri <relative/to/output-dir/file.js> --search-uri <relative/to/output-dir/file2.js>
329+ --search-uri <relative/to/output-dir/file.js>
330+ --search-uri <relative/to/output-dir/file2.js>
285331 <path/to/file.odocl>
286332]}
287333
@@ -302,7 +348,12 @@ the page and the [.html] extension.
302348An example of such command is:
303349
304350{@shell[
305- $ odoc html-generate _odoc/ppxlib/doc/page-index.odocl --index _odoc/ppxlib/index.odoc-index --search-uri ppxlib/sherlodoc_db.js --search-uri sherlodoc.js -o _html/
351+ $ odoc html-generate
352+ _odoc/ppxlib/doc/page-index.odocl
353+ --index _odoc/ppxlib/index.odoc-index
354+ --search-uri ppxlib/sherlodoc_db.js
355+ --search-uri sherlodoc.js
356+ -o _html/
306357]}
307358
308359{3 Source code}
@@ -323,7 +374,10 @@ initial [--source-id] and [--name] given when creating the [impl-*.odoc] file.
323374An example of such command is:
324375
325376{@shell[
326- $ odoc html-generate-source --impl _odoc/ppxlib/lib/ppxlib/impl-ppxlib__Reconcile.odocl /home/panglesd/.opam/5.2.0/lib/ppxlib/reconcile.ml -o _html/
377+ $ odoc html-generate-source
378+ --impl _odoc/ppxlib/lib/ppxlib/impl-ppxlib__Reconcile.odocl
379+ /home/panglesd/.opam/5.2.0/lib/ppxlib/reconcile.ml
380+ -o _html/
327381]}
328382
329383{3 Generating docs for assets}
@@ -337,8 +391,8 @@ argument, and give the asset unit using [--asset-unit].
337391
338392{1 Convention for installed packages}
339393
340- In order to build the documentation for installed package , the driver needs to
341- give a meaning to various of the concept above. In particular, it needs to
394+ In order to build the documentation for installed packages , the driver needs to
395+ give a meaning to the various concepts above. In particular, it needs to
342396define the pages and libraries trees, know where to find the pages and assets,
343397what id to give them, when linking it needs to know to which trees the artifact
344398may be linking...
@@ -349,15 +403,15 @@ and the driver follow it, building the docs should go well!
349403
350404{2 The [-P] and [-L] trees, and their root ids}
351405
352- Each package define a set of trees, each of them having a root ids . These roots
406+ Each package defines a set of trees, each of them having a root id . These roots
353407will be used in [--parent-id] and in [-P] and [-L].
354408
355409The driver can decide any set of mutually disjoint set of roots, without posing
356410problem to the reference resolution. For instance, both [-P
357411pkg:<output_dir>/pkg/doc] and [-P pkg:<output_dir>/pkg/version/doc] are
358412acceptable versions. However, we define here "canonical" roots:
359413
360- Each installed package [<p>] define a single page root id: [<p>/doc].
414+ Each installed package [<p>] defines a single page root id: [<p>/doc].
361415
362416For each package [<p>], each library [<l>] defines a library root id:
363417[<p>/lib/<l>].
@@ -381,7 +435,7 @@ define three trees:
381435
382436Installed OPAM packages need to specify which trees they may be referencing
383437during the link phase, so that the proper [-P] and [-L] arguments are
384- added. (Note that these dependencies can be circular without problem , as they
438+ added. (Note that these dependencies can be circular, as they
385439happen during the link phase and only require the artifact from the compile
386440phase.)
387441
@@ -431,6 +485,6 @@ have the parent id from their page tree, followed by [_asset/<filename>]
431485
432486{2 The [--source-id] arguments}
433487
434- The driver could chose the source id without breaking references. However,
488+ The driver could choose the source id without breaking references. However,
435489following the canonical roots convention, implementation units must have as
436490source id: [<pkgname>/src/<libraryname>/<filename>.ml].
0 commit comments