-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
inline doc comments for enum
values are incorrectly associated with line below
#11249
Comments
I'm pretty sure this isn't a bug, but more of a feature request given I don't think inline comments are supported as far as I know. |
Right, and I would prefer not to do that. It's better to have a single unified way for this. Plus it's easier to read if it's at the top, you have more space |
It's certainly a bug that trailing line comments are attached as doc comments of the following expression. Whether trailing line comments are supposed to be doc comments of the expression in the same line is a different question. I agreed to the previous comments in why that wouldn't be a good Idea. |
If inline doc comments should be discouraged, they should probably be avoided in the language reference (see here). I think the example I provided above ( As @straight-shoota says, this can be broken into two issues:
I think the implementation for (1) will almost certainly cover (2) as well. I'll concede that it's largely a matter of personal preference, but I think that suggests that there's no "right" way and if both can be supported, IMO both should be. |
On said page in the language reference, the comments are merely annotations of the code. They're not intended as doc comments. I think we should stay with the semantics that inline comments are never considered doc comments. |
Bug Report
Most Crystal doc comments are written on the line(s) preceding the value they describe:
However,
enum
values often have doc comments written inline (though both forms are valid):Inline comments are incorrectly associated with the following line (as though they'd been written in the standard line-above style):
I'm not well-versed with the compiler's internals, but I'm fairly certain this is a bug in the parser, not the documentation generation. I would expect both forms to work equally, and would like to be able to mix them as well - here's a code sample from
libgit2
bindings that uses both in tandemThe text was updated successfully, but these errors were encountered: