Problem with generating sedlex doc with ocamldoc

As part of packaing sedlex for Debian, I need to generate doc with ocamldoc. I don’t have much experience on actually using ocamldoc so I’ve been doing it with trials and errors. For the previous versions (sedlex 1.x) it works, but for sedlex 2.1, I got some errors and would like to have some pointers.

Here is the command I used (given sedlex is already installed with opam install sedlex):

ocamlfind ocamldoc -sort \
\
-I ~/.opam/default/lib/sedlex  \
-I ~/.opam/default/lib/sedlex/ppx \
\
-package gen \
-package compiler-libs \
-package ocaml-migrate-parsetree \
-package ppx_tools_versioned \
-ppx "ocamlfind ppx_tools_versioned/metaquot_405/ppx.exe --as-ppx" \
\
~/.opam/default/lib/sedlex/ppx/sedlex_cset.mli \
~/.opam/default/lib/sedlex/ppx/ppx_sedlex.ml \
~/.opam/default/lib/sedlex/ppx/sedlex.mli \
~/.opam/default/lib/sedlex/ppx/sedlex_ppx.ml \
~/.opam/default/lib/sedlex/ppx/unicode.mli \
~/.opam/default/lib/sedlex/sedlexing.mli \
\
-html -stars -m A

output:

File "/home/andy/.opam/default/lib/sedlex/ppx/ppx_sedlex.ml", line 17, characters 14-25:
17 | module Cset = Sedlex_cset
                   ^^^^^^^^^^^
Error: Unbound module Sedlex_cset
File "/home/andy/.opam/default/lib/sedlex/ppx/sedlex.mli", line 7, characters 11-24:
7 | val chars: Sedlex_cset.t -> regexp
               ^^^^^^^^^^^^^
Error: Unbound module Sedlex_cset
File "/home/andy/.opam/default/lib/sedlex/ppx/unicode.mli", line 7, characters 11-24:
7 |   val cc : Sedlex_cset.t
               ^^^^^^^^^^^^^
Error: Unbound module Sedlex_cset
Warning: Module or module type Sedlex_ppx__Unicode not found
Warning: Module or module type Sedlex_ppx__Sedlex_cset not found
Warning: Module or module type Sedlex_ppx__Sedlex not found
Warning: Module or module type Sedlex_ppx__Ppx_sedlex not found
Warning: Module or module type Sedlex_ppx__Unicode not found
Warning: Module or module type Sedlex_ppx__Sedlex_cset not found
Warning: Module or module type Sedlex_ppx__Sedlex not found
Warning: Module or module type Sedlex_ppx__Ppx_sedlex not found
Warning: Element Uchar.t not found
Warning: Element Lexing.pos_fname not found
Warning: Element Lexing.position not found
Warning: Tag @canonical not handled by this generator
Warning: Tag @canonical not handled by this generator
Warning: Tag @canonical not handled by this generator
Warning: Tag @canonical not handled by this generator
3 error(s) encountered

I wanna ask why am I getting Error: Unbound module errors and how should I fix it?

I don’t exactly know how to run ocamldoc by hand, my first guess would be to check if the paths you used are correct after v2.0.

However, you could avoid it all probably. Afaik sedlex 2.1 uses dune for the build, so you can build the documentation by running dune build @doc or make doc The documentation should appear in _build/default/_doc

Thanks for the reply.

Sadly, dune build @doc depends on odoc, which hasn’t been packaged for Debian yet, so I cannot use it for the sedlex Debian package.

The problem is that the ppx library is now wrapped. While waiting for odoc integration, the experimental -lib option of ocamldoc seems to do a half-decent job:

where=$(ocamlfind query sedlex)
ocamlfind ocamldoc -sort \
\
-I $where  \
-I $where/ppx \
\
-package gen \
-package compiler-libs \
-package ocaml-migrate-parsetree \
-package ppx_tools_versioned \
-ppx "ocamlfind ppx_tools_versioned/metaquot_405/ppx.exe --as-ppx" \
-lib Sedlex_ppx \
$where/ppx/sedlex_cset.mli \
$where/ppx/ppx_sedlex.ml \
$where/ppx/sedlex.mli \
$where/ppx/sedlex_ppx.ml \
$where/ppx/unicode.mli \
$where/sedlexing.mli \
\
-html -stars -m A

2 Likes