New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot attach documentation to polymorphic variants #6966
Comments
Comment author: @lpw25 The issue here is that the second form is a type equation not a type definition. It is not entirely clear why that form should be supported without also supporting:
|
Comment author: @mmottl Fair enough, not sure whether the full generality of type equations should be supported. It's always possible to factor out the polymorphic variant part, e.g. with your example:
If we allow for special treatment of the case where the polymorphic variant is "immediate", then it becomes possible to document entries individually. It would be surprising to see a tuple or function with hundreds of entries, but having large polymorphic variant types with possibly thousands of entries can actually happen in practice with auto-generated code. It would be nice then to also have some documentation for each case in the API. |
Comment author: @lpw25 My personal preference is to support something like:
This is slightly less convenient, but it leaves the somewhat ad-hoc decision about which parts of type equations can be documented to the documentation tool rather than the compiler. I hope to add support for something like this to the (not yet released) codoc tool. |
Comment author: @mmottl That's a possibility and somewhat similar to using The current documentation system may not be expressive enough to fully cover all syntactic constructs. I believe there were some ideas for a standardized documentation system built on attributes as introduced in OCaml 4.02. Not sure what happened to this proposal. |
This is a duplicate of #4347. |
What's more, it's been fixed by #477. |
That is, the compiler side of things has been fixed: the docstring is now attached as an attributed in the AST. |
Original bug ID: 6966
Reporter: @mmottl
Status: acknowledged (set by @damiendoligez on 2016-02-03T11:45:31Z)
Resolution: open
Priority: normal
Severity: feature
Target version: undecided
Category: ocamldoc
Monitored by: @gasche @diml @hcarty @mmottl
Bug description
Consider the following example "foo.ml":
Compiling the above with "ocamlc -w A foo.ml" will give the following warning:
Obviously, this only happens with the polymorphic variant and not the sum type. I think polymorphic variants should be treated the same way.
The text was updated successfully, but these errors were encountered: