1

I'm trying to document a small project of mine using ocamldoc.
I have one main .ml file which opens two others .ml files.

$ ocamldoc -html included1.ml included2.ml

Works just fine, but when I add the including file, like

$ ocamldoc -html included1.ml included2.ml including.ml

I get this:

File "including.ml", line 5, characters 5-16:
Error: Unbound module Included1
1 error(s) encountered  

I see from the ocamldoc documentation that opening modules is perfectly fine, until no conflict arises.
How should I proceed?

pimple
  • 338
  • 1
  • 11

1 Answers1

2

It's fine for a module to use other modules however it needs to be able to see the compiled interfaces for those. So in your case you first need to compile the .ml files to generate .cmi files. Then you need to indicate to ocamldoc where these files are. So something like this should do:

ocamlc -c included1.ml
ocamlc -c included2.ml
ocamlc -c -I . including.ml
ocamldoc -html -I . included1.ml included2.ml including.ml

Note that in general it's a good (essential) practice to create .mli files for each of your modules an document and ocamldoc these rather than the .ml files.

Daniel Bünzli
  • 5,119
  • 20
  • 21
  • 1
    damn, just wrote the same answer :) Btw, the `-I .` is not needed, as it will look in the current directory by default. – ivg Oct 07 '16 at 16:18
  • Sorry... Yeah that `-I .` may not be needed I think there's a tool in the toolchain were it's needed but I never remember which one (or maybe I dreamt). – Daniel Bünzli Oct 07 '16 at 17:04
  • Oh, ok... I thought it was only for external dependencies, and not for files in the same directory and included in the list! =) Thank you! – pimple Oct 07 '16 at 18:16