-
Notifications
You must be signed in to change notification settings - Fork 430
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
Converting warning-50-clean OCaml code results in misplaced doc comments #416
Comments
Only currently. Hopefully not for very long. Maybe you could help us sequence the features. Can you point me to the specification for the new ocaml document attribution policy? Is the following accurate? (I'm sure there's an error with it - can you help me correct it?) (* on x *)
let x = 10 (* on x *)
(* on x *)
(* on t *)
type t =
(* on A *)
| A of int (* on A *)
(* on A*)
(* on B *)
| B of int
(* on C *)
| C of int
(* on t *)
|
Yes, once we match the new ocaml documentation convention, warning
It would accurately preserve the attribution - but I think there's some information lost that we're going to need to do some work to recover. I mentioned above the distinction between end of line and "before the line" comments. That isn't encoded in the AST attributes IIRC so we have to do our custom trickery to preserve it. |
The closest thing to documentation I know of is ocaml/ocaml#149 (comment) .
None of these are doc comments
'Sub-items' (sum type alternates and record fields and maybe some other things?) only allow doc comments after the item. And also only 1 comment is allowed.
For the final comment to be associated with t, an empty (** on x ) (** on t ) (* NOT on B )
Absolutely! And we want this info to be accurate so that merlin-document can work well.
Yes, only the documentation comments are intended to show up in the ocaml ast
Argh, is it known if the situation is better with 4.03?
That sounds right. Although it may be that the "end of line" and "before the line" info is not needed for documentation comments, only the other free-form comments. The formatter could put doc comments on signature items (and top-level items of an .rei file) after the item, doc comments on structure items (and top-level item of an .re file) before the item, and doc comments on sum type alternates and records fields, etc. after the item. The end of line versus next line question could be based on whether it fits without breaking the line (later, when such sensitivity is possible since easy_format doesn't support it currently). At a high level, it would be nice if reason could have its own heuristics for associating comments in reason code, but use the attributes when converting, so that reason doesn't have to get into the business of replicating the ocaml heuristics. But I guess that isn't fully possible given the additional info and non-doc comments issues you mention. As an intermediate, would it make sense to add a warning to reasonfmt that compares the ocaml doc comment attributes and the doc comments that reason has found, and complain if they differ? That way for warning-50-clean ocaml code, converting to reason could check that its heuristics make the same choices for the doc comments. |
It seems that reasonfmt is not using the documentation comment attributes, and its own heuristics for comment association are incompatibly different. Is there a way to use the ocaml ast attributes? If so, then checking that ocaml code has no instances of warning 50 would be enough to ensure that converting it to reason would accurately preserve the documentation comments.
The text was updated successfully, but these errors were encountered: