odoc icon indicating copy to clipboard operation
odoc copied to clipboard

Reference to label in preamble are broken

Open Julow opened this issue 4 years ago • 2 comments

(** {1:L1 Some label} *)
module M : sig
  type t
  (** Ref 1: {!L1} *)
end

(** Ref 2: {!L1} *)

(** Ref 3: {!M.L1} *)

In this example, refs 1 and 2 resolve to Test/index.html#L1 and ref 3 doesn't. The heading labeled L1 is part of the preamble of M but not its synopsis. It is rendered into the page for M but not in the top-level page (where the anchor L1 doesn't exist).

The expected behavior is: refs 1 and 3 resolve to Test/M/index.html#L1 and ref 2 does not.

Julow avatar Oct 05 '21 15:10 Julow

The behavior I suggested above means resolving differently the first paragraph from the rest of the comment. The first paragraph is the synopsis and would be handled in the context of the top-level module and the rest of the comment (including the heading) would be handled in the context of M. This is inconsistent with what was decided in https://github.com/ocaml/odoc/pull/739.

A better solution is to disallow headings attached to items. I think this was already implemented at some point.

Julow avatar Oct 05 '21 16:10 Julow

I don't think you are supposed to have sections in your preamble (I can't find again the long discussion we had when we established the preamble / section structure).

dbuenzli avatar Jun 09 '22 10:06 dbuenzli