Is there any way to generate code documentation for BuckleScript or Reason? I've tried using ocamldoc
, but I don't know how to include node package dependencies automatically.
2 Answers
There isn't an automatic resolution yet for node packages. You can manually specify each dependent package in the ocamldoc command, e.g.:
ocamldoc -html -d doc -I node_modules/bs-webapi/lib/ocaml -I node_modules/bs-fetch/lib/ocaml -I node_modules/bs-platform/lib/ocaml src/YourModule.re
The directory includes are fairly predictable, you just have to point at the lib/ocaml
directories in each package, ocamldoc will find their compiled .cmi
files and pull in the required type information from there.
This also means that you'll first need to have done bsb -make-world
, to compile all those .cmi
s.

- 11,272
- 4
- 48
- 80
There’s a tool which, supposedly, automatically performs a lot of the orchestration of ocamldoc
described by @Yawar, called BsDoc.
Note that I have not used this myself; but it it supposed to be the go-to for a lot of BuckleScript-specific projects (i.e. using bsb
with npm
-installed dependencies, not dune
with opam
-installed dependencies.)

- 17,185
- 12
- 62
- 78