odoc icon indicating copy to clipboard operation
odoc copied to clipboard

Reference a polymorphic variant constructor belonging to a type

Open MisterDA opened this issue 2 years ago • 1 comments

Considering a polymorphic variant type:

type switch = [`On; `Off]

I'd like to be able to refer to the constructors in the documentation. It could be doable if the full path is specified; there's even an anchor generated in the html code, which suggests a possible syntax:

(** {!type-switch.On} *)

Thanks!

MisterDA avatar Nov 21 '22 13:11 MisterDA

This is not a parser problem but a missing feature in the reference resolver. Speaking of parser, there's room already in the syntax for the `: {!t."`Foo"}. This might be useful to disambiguate between a regular and a polymorphic constructor (as an alternative to a prefix like {!t.poly-Foo}).

We already have code to handle ambiguous references, so it might be possible to handle cases like {!"`Foo"}, which could mean "The constructor `Foo in any type declaration in scope.".

Julow avatar Nov 21 '22 14:11 Julow