Revert option doc-comments-val and restore the values of 0.13.0#1354
Revert option doc-comments-val and restore the values of 0.13.0#1354gpetiot wants to merge 2 commits intoocaml-ppx:masterfrom gpetiot:revert-doc-comments-val
Conversation
reformat update tests revert value in ocamlformat profile
Julow
left a comment
There was a problem hiding this comment.
Looks good.
Two projects I know of did use this option:
- https://github.com/ocsigen/js_of_ocaml
Remove the unecessary option. - https://github.com/coq/coq
Must setdoc-comments=before
|
Note that this reintroduces the regression from 82da6c5 that makes it no longer possible to have docstrings before types and after values. This regression fix is one of the recent fixes that we need in order to be able to use a mainline version of ocamlformat. See also the revert of this in the branch that we currently need to use: e7acc28. What is the plan (and timeline?) for restoring the fix for not having docstrings before types and after values? |
|
I don't follow your comment, was #746 bad? This PR shouldn't have any impact on it. |
|
I think that "bad" might not be the right term, but it did make it impossible to have the docstrings (in signatures at least) for types come before and those for values come after. The |
|
The trajectory for doc-comments has not been defined yet.
So the short-term solution we chose is to release a 0.14.2 that has the exact behavior as 0.13.0 to not lose all of our users for this release cycle. We will start clean and can think of a new strategy for doc-comments in the 0.15.* release cycle. |
|
Note that #1340 (+ the revert of default released in 0.14.1) was enough to restore 0.13.0 behavior. |
|
Thanks @Julow, I was confused as I thought that If that understanding is correct, then while I appreciate the goal to have a small and clean interface, it is also important and useful to have essentially unfinished functionality in cases where what the right thing to do is unclear and needs experience and feedback. From that perspective, I'm wary that removing Separately, is there a summary of the overall constraints, feedback, etc. for the design of doc comments placement that I can read somewhere? It seems like a quite non-obvious problem, and maybe something new will strike me if I look at it with fresh eyes. |
The thing is currently we don't know what is going to replace it, and we don't want to make something in a hurry. So we are stuck in a state where we either:
And the more time we take to decide, the more this choice disappears and the first solution is silently adopted.
We are worried about sending the message of "you have this new option for now, maybe it will disappear in the next release, we don't know", but I agree with your point. The thing is we were aiming at reducing the number of options over the next releases. So of course I'm not saying we should just stop adding options all together but we need to be cautious. This option may also send the message that we may have a similar option for types, or modules, or something else, and no plan is defined yet. Is it what we want? |
|
Maybe it is helpful to summarize the history of these options:
The reasoning behind the design of 1) was to place docstrings before most items, since it seemed that usually in practice, the docstrings for e.g. module or type definitions were written in such a way, and contained information such that, it was more helpful to read them before the definition. On the other hand, the docstrings of Then step 2) happened since the Jane Street code style mandated docstrings come before their items. The possible values of this option were, in hindsight, confusingly named from the beginning. Then step 3) happened in response to feedback where some people wanted more docstrings to come after their associated items than just Now, there are two options controlling docstring placement, seeming to indicate that there are two orthogonal dimensions to the choice, when in fact the two options are only describing a number of different points along a single dimension. I think that we should consider what it would look like to collapse the
What I'm proposing is to remove My perception is that that situation would be reasonably clean. There would be one option, and all 3 values would have intuitive explanations. There is a point that the implementation of Based on feedback and experience on other code bases, are those 3 styles enough? I don't know of code bases which use doc comments after their items in all cases, so I'm particularly unsure about whether that option is needed or the constraints coming from the cases where it would be desired. Are there recent results from the harvest script somewhere? I'm thinking that another possible plan would be to remove the Do you also think that that one option with three values would be a reasonable interface going forward? If so, I think that we could get to a good state very quickly, that could be done with one small PR and used for 0.14.2. Maybe I'm overlooking something? Perhaps related, when looking at the current state of the documentation and implementation of (** docstring before since there are other docstrings in the type definition *)
type t = A of int (** doc of A *) | B of int (** doc of A *)
(** docstring before since there could be other docstrings in the type definition *)
type t = A of int | B of int
type t = int
(** docstring after since there can't be sub-docstrings *)
(** docstring before since there could be other docstrings in the struct *)
module M = struct
type t = int
endMy thinking is that the behavior of such a value could be defined in an objective non-arbitrary way, and might be enough to remove the "on structures, signatures and objects for readability" exception for There might be some refinement of the criterion so that e.g. a code change from type t = intto type t = Int of intdoesn't churn the docstring positions. I think that would amount to saying that the code deciding before vs after should only look at the signature item kind, and not dig deeper to e.g. see what the type declaration kind is. That seems quite reasonable to me at first glance. Something else to keep in mind is that when an item has two docstrings, there isn't a reasonable choice: no matter what the options are set to, one must come before and one after. For example: (** must come before *)
val f : int -> int
(** must come after *)I'm not sure whether it would be helpful, but instead probably harmful, to the documentation to get into those details. But good to keep in mind. |
|
We don't have data for the usage of I like the idea of On a general note I would like to keep the values of this option on a single cursor (and thus avoid orthogonal options). Currently we have: ( we can indeed imagine having intermediate values like |
|
I also think that it's important to try very hard to keep the option values just on a linear scale. It is much easier to maintain that way. Maybe we can't rule out ever needing something more, but it would be good to state that avoiding that is an objective/constraint. I agree that renaming Predictability is important. I have a lot of experience with the situation where "simple" is just My inclination would be to start with the smallest change from existing support, just adjusting the config option space, and then consider a situation supporting |
|
I agree with your proposition, since the work looks short enough we can make it for a 0.14.2 in the short term. To be more concise and make sure we all agree on these points: 0.14.2:
0.15.0:
Again having a 0.14.2 doesn't mean it's urgent, only that there is not enough changes to justify incrementing the middle version number. |
|
That summary and plan look good to me, thanks @gpetiot! Another point to possibly add to 0.15 is to decide whether |
|
Replaced with #1358 |
I tested the reformatting on some of main ocaml projects:
and there is not diff with the formatted output of Add doc-comments-val=unset #1340 (which has already been validated by maintainers of these projects)
Feel free to make more tests before merging