Search code examples
ocamldocumentation-generationocamldoc

Can ocamldoc reference type constructors?


I'm trying to refer to a type constructor in ocamldoc.

For example:

type x = Awesome | Boring

And later we want to refer to one of the constructors in some documentation:

(** {!Awesome} is a really great constructor for {!x}.  You should definitely use it instead of {!Boring}. *)

ocamldoc complains:

Warning: Element Awesome not found
Warning: Element Boring not found

Is there a way to reference type constructors such that ocamldoc can link to the corresponding type?


Solution

  • You cannot directly cross-link to a type constructor. However, you can link to the type itself:

    (** {{!x}Awesome} is a really great constructor for {!x}. *)
    

    If you want to have something more precise, you can write a small ocamldoc plugin to overwrite the html_of_Ref method.