-
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
Remove some kinds of doc comments #1373
Conversation
I believe currently all the comment forms are defined to desugar to the attribute forms, so it seems like removing the latter would break things. I think they are currently the only way to handle documentation in macros, for instance. I don't think that humans should be writing the attribute forms or that things like rustfmt should be expected to handle them, but they seem to be a useful representation for processing code programatically. |
@wthrowe doc comments are treated as attributes, but it's a messy hack and should be re-done anyway (we should distinguish doc comments in the AST and lower them to attributes in the HIR, or something). I don't think that needs to affect the surface syntax in any way. I'm curious about the macros thing - aiui, doc comments work fine in So, I don't see any reason for attribute comments to be exposed to the user at all (including via tools or syntax extensions). |
@nrc they work fine in macros but the macro definition has to treat the comments as attributes: https://github.com/sfackler/rust-postgres/blob/master/src/types/mod.rs#L101. We'd need to add a matcher for doc comments if the desugaring was changed. |
Removing the |
I would also be interested in some hard data about how many crates use each of the mentioned forms, and whether we could do some automated PRs to amend them. |
One thing I'd still like to see in the documentation system is the ability to reference external Markdown files for the purpose of documenting items. It would be particularly nice for crate-level or module-level documentation, which tend to (and should!) be rather long and full of details, explanation, and examples:
Does this RFC still allow a feature like that in the future? |
@tomjakubowski sure, that seems pretty orthogonal to this issue - we could always add such an attribute (hopefully with scoped attributes in the future, it wouldn't even need to be a language issue). |
... why?! I use block doc comments because they're significantly easier to deal with than constantly having to manually reflow and re-comment line comments (which are for lines not blocks). Removing them just makes my life (and anyone who prefers them) more difficult for, from what I can tell, basically no benefit. Removing the
This is an unbelievably low bar. As in, I don't seriously believe this is an actual reason.
Now this, I would buy... if it hadn't taken me all of one or two hours to support both in They're there. They're useful. Just... why?! |
I think using doc comments in macros where metadata tokens are expected works now. For example, this definition produces correct rustdoc output, with all pieces of documentation in their place. |
Doc comments as purely sugar for attributes works really well. This can tie in really well with |
👎 |
I don't like the idea of removing 👍 for the rest sheds a single tear for the block doc comment 💧 |
@Manishearth, assuming doc comments are still associated with nodes in the AST, why are attributes easier for macros to deal with? (I'm assuming that doc comments would be lowered to attributes in the HIR, but kept explicit in the AST, but would be fairly identical to attributes, just distinguishable). |
@chris-morgan I don't think anything in the RFC would break that, in particular I'm not proposing any changes to the representation of doc comments in the compiler (perhaps only superficial changes to their representation in the AST). |
Macros operate on the AST and not the HIR. So I can capture all attributes, including doc comments, using a |
@DanielKeep why? - because we do everything we can to make the language small and only have multiple ways of doing things when there is a real motivation for doing so. IMO, the different kinds of doc comments are not pulling their weight in this respect. Easier for users means a shorter, less confusing section in tutorials for beginners, less choice and thus variation between projects, etc. Easier for tools means fewer gotchas and smaller, easier to debug and maintain tools. |
@Manishearth (in reply to the earlier comment) removing the attribute form doesn't mean that we have to change the representation in the AST (although I was imagining we would, your later comment is some motivation for not doing so). In reply to the second comment, it seems somewhat awkward that a macro pattern like that captures a syntactic form which does not match the pattern. I can see why you might want this, but I'm not convinced it's a feature rather than a bug. |
I didn't even know |
In my opinion, line doc comments are vanishingly rare because proper documentation is almost always going to involve more than a single line and, in those few cases, wrapping said line in a block isn't that big a deal. So yes, let's kill single line doc comments! Keeping the language minimal is, in general, something I approve of. But documentation is not an area to skimp on. The last thing you want is to be putting up roadblocks to getting people to write more and better documentation. Line doc comments require either significantly more time and effort, or a specialised editor that's been contorted to do unnatural things with them. I have never, in my life, found an editor that made "block line" comments sane to deal with. If you're fine with them, well, fantastic. If the style guide wants to direct people to using them, OK. You actually take them away, however, and I'm just that much less likely to bother writing documentation when it means endlessly munging them by hand. |
Except that's the kind of doc comment that everyone seems to be using. I dunno, Sublime with Alt-Q works fine on wrapping block comments. I think vim does too. |
I could be mistaken, but I believe that's because its been advertised as |
This discussion demonstrates once again why we've never ever managed to pare down our menagerie of doc comments. :P I'll just leave this here: http://c2.com/cgi/wiki?WadlersLaw |
@nrc I hereby propose you break the eternal deadlock by actually and at last proposing some magic that would let us remove inner doc comments, instead of removing either line or block form. That would at least be a new and exciting bikeshed compared to this dreadfully bruised horse carcass. :) |
|
I agree with all @DanielKeep has said and would miss the non-prefixed block comments. While I appreciate the desire to keep the language minimal and easy for the users, I do not think this |
FWIW I really value block doc comments. It's unclear to me why anyone would want to use single line comments for any form of substantial documentation - it's just extra work for no obvious benefit. |
As I said before, I do like block doc comments for module docs. I would mourn their loss, but not for too long. With that said, there is an ancient utility called Let's say you end up with line doc comments like this:
I'm an 80 column zealot, so I run this command:
All you then need to do is configure your editor to replace highlighted text with the output of an arbitrary command. For vim, I have |
I personally never knew alternatives existed (not discussed in the book, etc), and have endured writing long essays using At the end of the day I don't really care, I'll keep putting up with If I had to vote (which luckily I dont! :) ), I'd be happy seeing it simplified down to two doc comments: outer-line + outer-block. |
Yeah, in that example. Probably for everything related to line doc comments too. It's good. I just can't remember now where it got hung up. I switched all line wrapping to |
FWIW, multi-line doc comments weren't even really documented decently at all until recently (I had to guess at how they were closed besides perhaps not realizing they existed). The book avoids using them because they're not the official style so even if they aren't used much, the deck was loaded against them to begin with. Usage statistics aren't a very useful indicator here since by all indication, official policy is to hinder their usage. Stating multiple different types of comments is too complex for users to handle is basically a silly argument. No one ever complained that teal, aqua, navy, and royal blue as colors for blue are too complicated for people to handle and there are more colors than those. No one complains that we can walk, skip, run, or crawl which all stand for modes of physical transportation. People are very adept at comprehending a multitude of subtly different words properly. The improvements documentation would see from removing these are basically non-existent. Doc comment documentation is basically independent of all sections except comments and not difficult anyway. Consolidating all community commenting to a single type would be effective but not useful. You're removing something easy to understand which isn't ambiguous. Even if it was difficult to disambiguate between different comment types it still wouldn't matter. Almost all users write comments in an editor with syntax highlighting. Any comment will be syntax highlighted accordingly and so should be clear. Even if that wasn't the case, context should be highly effective at highlighting that a paragraph clearly isn't dense logical code. Even if that also wasn't the case, the compiler would point out that your poem (or paragraph or whatever) isn't valid for some reason and you'd comment it out. |
Big 👎. I'm not a fan of removing features for no large benefit. Block doc comments are not confusing and not hard to support. The fact that there are ways around most of the pain that removing block doc comments would cause does not in itself justify the removal of them. "It's not that bad" does not mean it's good either. (By the way, with the idea of all block comments being removed having been touched upon in #1371, I'd like to also mention I am completely against removing normal block comments as well.) |
👎 - this proposal feels like "simplify for simplification's sake", rather than addressing real confusion/friendliness issues among new users. I feel that much more can be gained by working on compiler diagnostics and messages, especially w.r.t. borrows and traits. |
I guess my overall feeling is indifference. Obviously I do feel like we should avoid backwards incompatibility in general, so in that sense I am not a big fan of this RFC. However, it's worth noting that the RFC itself proposed only deprecating the other comment forms, and then perhaps removing them at some future date. Ubiquitous use of rustfmt may have the same effect, if it starts to rewrite comments into the approved form. So perhaps we should just revisit this in the future, if that utopia (or dystopia, depending on your POV) has come to pass. Personally, I'm still a big fan of writing comments with |
@nikomatsakis |
@tbu- yes, but I at least find the |
@nikomatsakis I have never thought about that. It seems as really nice idea. |
Hear ye, hear ye. This RFC is now entering final comment period. |
I largely agree with the sentiments express on this thread. Regardless of its merits, we shipped these features in 1.0 and need to have a pretty strong reason (and consensus) to deprecate them. (I don't personally use these forms and would not miss them, but that's beside the point.) For this to be a realistic path, I think the first step would be getting consensus around comment conventions via widely-used |
|
Yeah, makes you wonder why there's a strong "preference" by compiler devs to use one, and not use the other. I use block docs, and see no reason to not to. Check, it would be a lot more preferable for me to just not update to (IMHO) insane Rust version, rather than not using them. I.e. if one useful thing would be broken for no reason, who knows what other, even more useful things would stop working, or would start to malfunction. https://github.com/zetok/tox/blob/bacaf781019bb2622446e5d3e1d2ac16b7b71325/src/lib.rs#L20 ← here you have a use case.
Are they? And if so, why would that be? Perhaps it's because there's some weird pressure from Rust lang devs to use line docs, and conveniently forget about block docs? If I may, I'd suggest to improve docs if they are confusing, and educate people about the _features_ they can use, rather than removing something useful just because you've failed to document & spread the word about the feature properly. If you're not convinced about the failure, feel free to look at comments even on this proposal, where people genuinely didn't know about the feature. Check, if not for @suhr who mentioned the feature to me when I was starting to learn Rust (1.0) I wouldn't know that I can do docs the better way. Just because docs sucked. Basically what @mdinger wrote.
No. What I notice, is some weird trend going on in Rust community to
Since when that thing became "widely-used" or an unbiased indicator of conventions? |
I'm really against this. Though my reason is odd. |
@camlorn Thanks so much for this feedback! As a separate point, if there are other things we can do to make Rust, its forums or our website more accessible to you, I'd love to hear about it. |
You guys are pretty good, as long as no one decides that we really need to take the emoji error handling RFC seriously. I'll be reporting stuff against playground at some point, but this is the first one where I can't work around the annoyance by changing some settings while programming. Given that I don't see how there's a maintenance burden from keeping them, I figured I'd pop out of the woodwork to say something. |
My opinion: The argument put forth in #1373 (comment) by @camlorn makes a strong case for not accepting this RFC. I will admit that I don't often consider the needs of blind programmers (and I now wonder how much material we put out in presentations etc that relies on visual diagrams to explain lifetimes et cetera). I'm glad to see people pointing out issues like this. |
@camlorn How much does using |
I can deal with //! comments. It's not unreadable, just very annoying. But for my own stuff, I want the choice. Even I use single-line If someone provides a good argument for this then I'll go away, but this To put this another way:
Is read as "Slash slash This is slash slash a long slash slash sample It's kind of hard to explain my heuristic for which style I use where in On 4/6/2016 14:57, tbu- wrote:
|
Since they're easier to deal with for blind programmers: rust-lang/rfcs#1373 (comment)
Big 👎 on this RFC. Rust should keep If anything, |
@Centril That is not what this RFC is about. |
We discussed this in the @rust-lang/lang meeting and we have decided not to accept this RFC. The basic reasoning is that this sort of deprecation is not really necessary, as it doesn't simplify the compiler in particular, and we must (for backwards compatibility) retain these various forms of comments anyhow. And of course the argument that |
Closes #287, #1371.