Skip to content
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

Six forms of doc comments are five too many #287

Closed
rust-highfive opened this Issue Sep 24, 2014 · 5 comments

Comments

Projects
None yet
6 participants
@rust-highfive
Copy link

rust-highfive commented Sep 24, 2014

Issue by bstrie
Tuesday May 28, 2013 at 12:36 GMT

For earlier discussion, see rust-lang/rust#6782

This issue was labelled with: B-RFC in the Rust repository


Currently we have six forms of doc comments:

  • outer line ///
  • outer block /** */
  • inner line //!
  • inner block /*! */
  • outer attribute #[doc=""]
  • inner attribute #[doc="";]

Ideally this would be reduced to one, but if two are necessary then that's fine. It's perfectly acceptable to not cater to every miniscule style convention. Here is my proposal:

  1. Remove the direct attribute forms, since their unwieldiness was why we introduced the comment syntax in the first place. This reduces to four.
  2. Select either line or block, and remove the other. This reduces to two.
  3. Remove the inner form if possible. If we can find some special way to document modules without requiring a special syntax just for that, then so much the better.

Alternatively, we could conclude that it's simply too much trouble to have special forms for doc comments and just stick with the attribute forms. This would be somewhat uglier, but more consistent with the rest of the language

@quantheory

This comment has been minimized.

Copy link
Contributor

quantheory commented Jan 5, 2015

My personal opinion (acknowledging that probably none of these will happen until Rust 2.0, if ever):

  1. I totally agree with this. Once you have the doc comments as the standard, the attributes are pretty silly.
  2. I almost totally disagree with this. If both line and block comments exist, there should be doc comment versions of both. However, "outer line" adds an extra slash, while "outer block" adds an extra asterisk. This is strange to me, because it doesn't fit with the "add one more specific character" style of inner blocks. If this one discrepancy was resolved, I would argue that this doesn't even count as another "form of doc comment" at all, because the line vs. block question would be completely orthogonal to whether something was a normal vs. doc comment.
  3. I disagree completely, mostly because I think that this is impossible without adding more complexity (both in software and for humans). For crates and most modules some inner form must exist. For everything else (possibly including those rare "inline" modules defined in the same file as a parent crate/module) most people prefer the outer form, which I can think of some good reasons for. I think it's better to allow both forms everywhere (and let projects have their own style guides) than to pick and choose which form works for which items. Especially since that's already implemented and apparently works fine.
@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Jan 5, 2015

The attribute forms are useful since they can be passed through macros: https://github.com/sfackler/rust-postgres/blob/master/src/types/mod.rs#L244

@nixpulvis

This comment has been minimized.

Copy link

nixpulvis commented Aug 28, 2015

I think the distinction makes perfect sense, and each has a good use case. And despite being 6 forms, there are really only 3x2 with some consistencies. For example inner vs outer is always is a matter of a !.

@pradyunsg

This comment has been minimized.

Copy link

pradyunsg commented May 6, 2016

Please close this issue as it will be superseded by the discussion at #1371.

@nrc nrc added the T-lang label Aug 17, 2016

@nrc

This comment has been minimized.

Copy link
Member

nrc commented Aug 17, 2016

closing - dup of #1371

@nrc nrc closed this Aug 17, 2016

withoutboats pushed a commit to withoutboats/rfcs that referenced this issue Jan 15, 2017

wycats pushed a commit to wycats/rust-rfcs that referenced this issue Mar 5, 2019

Merge pull request rust-lang#287 from cibernox/make-in-element-public
Promote {{-in-element}} to public API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.