odoc
odoc copied to clipboard
Allow reference to polymorphic variants when possible
A break from the 3.0 design!
Fixes #907 by allowing references to polymorphic variants when the type is given in the reference and the type's manifest is a polymorphic variant.
The `
in the constructor name is allowed and not mandatory.
References without specifying the parent type were not requested in #907 and could be added in another PR.
The last commits illustrate a problem: the polymorphic variants do not have an ID, so the resolved references for polymorphic variants are turned into a normal constructor identifier. This is not ideal. If needed, the model could be modified to represent for "types whose manifest is a single polymorphic variant" in a way that allows to define ids to the polymorphic variants. That is a bigger refactoring, but I can do it if you think that is needed.
type switch = [ `On | `Off ]
(**
References with type as parent work:
- {!type-switch.On}
- {!type-switch.`Off}
- {!type-switch.constructor-On}
- {!type-switch.constructor-`Off}
- {!switch.On}
- {!switch.`Off}
- {!switch.constructor-On}
- {!switch.constructor-`Off}
References in the environment don't work:
- {!On}
- {!`On}
- {!constructor-On}
- {!constructor-`On}
*)