-
Notifications
You must be signed in to change notification settings - Fork 83
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
Normalize multi-line Haddock comments to use multi-line comment syntax #674
Conversation
This prints pipe-style, multi-line Haddock comments using multi-line comment syntax where that is accepted. Note that it is not accepted everywhere. For example, you cannot use it on constructor definitions, so e.g. `operators.hs` remains unchanged. The decision about whether to break after a comment and what styles are acceptable is a bit obscure. I think an datatype enumerating all the places a Haddock coment can occur would be helpful, but I didn't want to bloat this PR too much, so I just added another boolean argument for now. Along the way, I tweaked the handling of doc comment content to always strip leading blank lines (it already always stripped trailing blank lines, and sometimes stripped leading ones). This makes it simpler to ensure idempotence. Fixes tweag#641.
Re-reading #641, I don't see that we have agreed that multi-line is better. It looks like most people argued that it would be nice to preserve multi-line comments without turning them into blocks of single-line while keeping blocks of single-line comments as they are. |
No, I don't think we've agreed, I'm just trying to lead with an example :) There are two reasons I think this way is reasonable:
|
These arguments make me lean towards not changing anything at all. |
I guess my argument is:
Anyway, I'm not sure there's much more I can usefully say on this. |
I have changed my opinion on this. If you bring it up to date with master I can review/merge it provided it implements the following logic:
Otherwise if there is no more interest in working on this we can close the PR and preserve the status quo. |
Do you mean comments like this?
This PR normalizes all multiline haddocks, including those, to use multiline comments. The reasons for that are here: #674 (comment) |
Perhaps there is a way to detect if a multilne or single line haddock was originally written... IIRC my position when you first opened this PR was that for normalization sake we should stick to a single style, that style being a sequence of singe-line comments. Now I think we could leave the decision to the user so that people who would like to leverage the benefits of |
I'd rebase this but I'm not interested in working on it more. So I guess I'll close it unless someone else wants to take it up. |
I still care about #641, and I thought it might be more likely to go somewhere with a patch.
The first commit has the meat, the second reformats ormolu with the new ormolu.
This prints pipe-style, multi-line Haddock comments using multi-line
comment syntax where that is accepted.
Note that it is not accepted everywhere. For example, you cannot use it on
constructor definitions, so e.g.
operators.hs
remains unchanged.The decision about whether to break after a comment and what styles are
acceptable is a bit obscure. I think an datatype enumerating all the
places a Haddock coment can occur would be helpful, but I didn't want to
bloat this PR too much, so I just added another boolean argument for
now.
Along the way, I tweaked the handling of doc comment content to always
strip leading blank lines (it already always stripped trailing blank
lines, and sometimes stripped leading ones). This makes it simpler
to ensure idempotence.
Fixes #641.