dsheets / codoc

OCaml documentation generator
34 stars 5 forks source link

pkg_dir is chopped incorrectly #94

Closed ivg closed 8 years ago

ivg commented 8 years ago

I've got the following error when running opam doc

   2 cmti under /home/ivg/.opam/bap-doc/lib/utop
   1 cmti under /home/ivg/.opam/bap-doc/lib/uuidm
codoc: source vg/.opam/bap-doc/build/bap-std.1.0.0~alpha does not exist
opam doc: 'codoc extract -f --index --package bap-std.1.0.0~alpha
          vg/.opam/bap-doc/build/bap-std.1.0.0~alpha -o opam-doc' exited with
          code 1

A correct path should be /home/ivg/.opam/..., but the first 7 characters were chopped away (exactly the length of _build/ string).

I've investigated a little, and find out that OpamDoc.extract function indeed chops out the first 7 characters if all cmtis to be extracted starts with the _build/ prefix. In mine use case it is incorrect, as /home/ivg/.opam/bap-doc/build/bap-std.1.0.0~alpha returns /home/ivg/.opam/bap-doc/build/bap-std.1.0.0~alpha, a string without _build in it.

Maybe the code that chops out _build/ is no longer needed (it is legacy to the older opam), or there're some other use cases that I don't know?

Note: I also investigated why extraction worked for other packages, but failed for bap-std. For all other packages list-extractions was able to find cmti files in the <PKG>:lib directory, so the code path with the _build chopping was never triggered. For a bap-std package codoc list-extractions didn't return anything on the lib folder and fell back to the build folder. The problem is that although the package is named bap-std it actually installs to a folder called bap and bap-std consists only from opam.config file.