odoc icon indicating copy to clipboard operation
odoc copied to clipboard

Doc strings get dropped on includes across compilation units.

Open dbuenzli opened this issue 2 years ago • 4 comments

Following up on https://github.com/ocaml/odoc/issues/875 it seems that comments do get lost on current master. Below the include in B has no docs. The include in A does.

> cat a.mli
module type A = sig
  type t
  (** Pliz keep me. *)
end

include A
> cat b.mli

include A.A

Just in case, the compilation steps in which I see this are:

'/Users/dbuenzli/.opam/4.14.0/bin/odoc' 'compile-targets' '-o' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/b.odoc' '/private/tmp/bla/_b0/brzo/ocaml-doc/cmti/b.cmti' > '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/b.odoc.writes'
'/Users/dbuenzli/.opam/4.14.0/bin/odoc' 'compile' '--pkg' 'bla' '-o' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/b.odoc' '/private/tmp/bla/_b0/brzo/ocaml-doc/cmti/b.cmti'
'/Users/dbuenzli/.opam/4.14.0/bin/odoc' 'compile-targets' '-o' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/a.odoc' '/private/tmp/bla/_b0/brzo/ocaml-doc/cmti/a.cmti' > '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/a.odoc.writes'
'/Users/dbuenzli/.opam/4.14.0/bin/odoc' 'compile' '--pkg' 'bla' '-o' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/a.odoc' '/private/tmp/bla/_b0/brzo/ocaml-doc/cmti/a.cmti'
'/Users/dbuenzli/.opam/4.14.0/bin/odoc' 'compile-targets' '-o' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/page-index.odoc' '/private/tmp/bla/_b0/brzo/ocaml-doc/index.mld' > '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/page-index.odoc.writes'
'/Users/dbuenzli/.opam/4.14.0/bin/odoc' 'compile' '--pkg' 'bla' '-o' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/page-index.odoc' '/private/tmp/bla/_b0/brzo/ocaml-doc/index.mld' '-I' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/'
'/Users/dbuenzli/.opam/4.14.0/bin/odoc' 'html-deps' '/private/tmp/bla/_b0/brzo/ocaml-doc' > '/private/tmp/bla/_b0/brzo/ocaml-doc/bla.html.deps'
'/Users/dbuenzli/.opam/4.14.0/bin/odoc' 'html-targets' '-I' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/' '-o' '/private/tmp/bla/_b0/brzo/ocaml-doc/html' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/a.odoc' > '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/a.html.writes'
'/Users/dbuenzli/.opam/4.14.0/bin/odoc' 'html' '--theme-uri' '_odoc-theme' '-o' '/private/tmp/bla/_b0/brzo/ocaml-doc/html' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/a.odoc' '-I' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/'
'/Users/dbuenzli/.opam/4.14.0/bin/odoc' 'html-targets' '-I' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/' '-o' '/private/tmp/bla/_b0/brzo/ocaml-doc/html' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/b.odoc' > '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/b.html.writes'
'/Users/dbuenzli/.opam/4.14.0/bin/odoc' 'html' '--theme-uri' '_odoc-theme' '-o' '/private/tmp/bla/_b0/brzo/ocaml-doc/html' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/b.odoc' '-I' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/'
'/Users/dbuenzli/.opam/4.14.0/bin/odoc' 'html-targets' '-I' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/' '-o' '/private/tmp/bla/_b0/brzo/ocaml-doc/html' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/page-index.odoc' > '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/page-index.html.writes'
'/Users/dbuenzli/.opam/4.14.0/bin/odoc' 'html' '--theme-uri' '_odoc-theme' '-o' '/private/tmp/bla/_b0/brzo/ocaml-doc/html' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/page-index.odoc' '-I' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/'
'/Users/dbuenzli/.opam/4.14.0/bin/odoc' 'html-targets' '-I' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/' '-o' '/private/tmp/bla/_b0/brzo/ocaml-doc/html' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/b.odoc' > '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/b.html.writes'
'/Users/dbuenzli/.opam/4.14.0/bin/odoc' 'html' '--theme-uri' '_odoc-theme' '-o' '/private/tmp/bla/_b0/brzo/ocaml-doc/html' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/b.odoc' '-I' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/'
'/Users/dbuenzli/.opam/4.14.0/bin/odoc' 'html-targets' '-I' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/' '-o' '/private/tmp/bla/_b0/brzo/ocaml-doc/html' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/a.odoc' > '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/a.html.writes'
'/Users/dbuenzli/.opam/4.14.0/bin/odoc' 'html' '--theme-uri' '_odoc-theme' '-o' '/private/tmp/bla/_b0/brzo/ocaml-doc/html' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/a.odoc' '-I' '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc/bla/'
'/Users/dbuenzli/.opam/4.14.0/bin/odoc' 'support-files-targets' '--without-theme' '-o' '/private/tmp/bla/_b0/brzo/ocaml-doc/html' > '/private/tmp/bla/_b0/brzo/ocaml-doc/odoc-support-files.writes'
'/Users/dbuenzli/.opam/4.14.0/bin/odoc' 'support-files' '--without-theme' '-o' '/private/tmp/bla/_b0/brzo/ocaml-doc/html'

dbuenzli avatar Jun 18 '22 13:06 dbuenzli

There seems to be something wrong with module level docs and includes indeed. Another case where docs just disappear is Re.Posix. Compare the generated docs with the mli . Even if I ensure that there is only one module level comment (with multiple everything but the last seems to be lost), only by clicking through to the docs of the included module can I see the doc comments, but not on the outer module where it was included: e.g. as in this PR .

I think the testcase in this issue is a good minimal repro case for that though.

edwintorok avatar Aug 05 '22 15:08 edwintorok

This issue was reported again on Discuss today, it looks like several libraries are affected with authors reporting that the documentation of their code on ocaml.org is missing content.

(cc @jonludlam I guess?)

gasche avatar Dec 31 '22 07:12 gasche

This is another issue related to includes. The ocaml website seems to use it's own .odoc file renderer. The issues reported on the ocaml website are (at least)

https://github.com/ocaml/ocaml.org/issues/203 https://github.com/ocaml/ocaml.org/issues/400

dbuenzli avatar Dec 31 '22 09:12 dbuenzli

The missing preambles (e.g. Re.Posix) will be back as soon as we get the ocaml-docs-ci pipeline updated together with ocaml.org to use the odoc html --as-json output format.

However, the issue with docstrings getting lost across includes is probably a different problem which warrants looking into it.

sabine avatar Jan 16 '23 17:01 sabine

I just retested this with odoc 2.4.2 and the original issue is still present.

dbuenzli avatar May 21 '24 13:05 dbuenzli

I think this is due to compilation order. This branch contains a reproduction for the bug and a demonstration of the right order: https://github.com/ocaml/odoc/compare/master...Julow:odoc:dropped-comment-include-878

Dependencies between odoc compile commands are the same as between OCaml compile commands, for example with the order reversed:

  $ ocamlc -bin-annot -I . b.mli a.mli
  File "b.mli", line 1, characters 8-11:
  1 | include A.A
              ^^^
  Error: Unbound module A
  [2]

The odoc compile-deps command shows the dependency:

  $ odoc compile-deps b.cmti
  Stdlib f4b8105ebd6e6055083019140b5caac1
  CamlinternalFormatBasics 19b059febe2d4c7c479d13b2c961fa93
  B c3b20184f7d6edd6b3a3eb8781a4b862
  A ff259811f7897a9697520b85792ce0eb

Julow avatar Jul 11 '24 14:07 Julow

@julow I didn't understand if you mean this is a driver issue or an odoc issue.

dbuenzli avatar Jul 23 '24 08:07 dbuenzli

This is a driver issue. A must be compiled before B.

Julow avatar Jul 25 '24 09:07 Julow

Thanks. I guess this explains that (this is the brzo driver, the odig driver uses the compile-deps). Sorry for the noise.

dbuenzli avatar Jul 25 '24 09:07 dbuenzli