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

Rustdoc should support inline or same-line doc comments for enums #920

Closed
felixc opened this issue Feb 28, 2015 · 11 comments
Closed

Rustdoc should support inline or same-line doc comments for enums #920

felixc opened this issue Feb 28, 2015 · 11 comments
Labels
T-lang Relevant to the language team, which will review and decide on the RFC. T-rustdoc Relevant to rustdoc team, which will review and decide on the RFC.

Comments

@felixc
Copy link

felixc commented Feb 28, 2015

Currently if you use the common documentation pattern:

enum Foo {
    Bar,  /// Bar is a value
    Baz,  /// This foo is a baz
    Quux
}

rustdoc will apply the documentation strings to the wrong values (specifically, to the next value after the intended one). Fortunately an error is generated if the last entry in the enum is documented (Quux in this example), but it's also fairly common for the last value to be something like Unknown or Invalid that may not be documented.

It would be nice if this same-line documentation style were supported, as it makes a lot of sense for simple enum values that only have short docs.

@bgamari
Copy link

bgamari commented Mar 1, 2015

Indeed you are not the only one who has felt the need for this. It would be great if you could write an RFC!

@shepmaster
Copy link
Member

Rustdoc supports //! to indicate documenting the thing the comments are "within", and Doxygen has some precedent of forms like ///<, so I'd suggest //< for rustdoc:

enum Foo {
    Bar,  //< Bar is a value
    Baz,  //< This foo is a baz
    Quux
}

@felixc
Copy link
Author

felixc commented Mar 18, 2015

I'm not familiar enough with rustdoc to know whether its parser/other implementation detail requires a different comment syntax to support this, but I'd like to note that I don't think that's a key part of this feature. I for one would be happy re-using the existing syntax, and having the interpretation be determined by context (i.e. inline vs. above).

@petrochenkov petrochenkov added T-lang Relevant to the language team, which will review and decide on the RFC. T-rustdoc Relevant to rustdoc team, which will review and decide on the RFC. labels Jan 30, 2018
@Centril
Copy link
Contributor

Centril commented Oct 7, 2018

Closing in favor of #2374.

@Centril Centril closed this as completed Oct 7, 2018
@rzumer
Copy link

rzumer commented Aug 11, 2019

Why was this issue closed in favor of an open RFC? Now that the pull request is closed, where is it tracked, if at all?

@Centril
Copy link
Contributor

Centril commented Aug 11, 2019

It does not need to be tracked since the RFC was closed.

@rzumer
Copy link

rzumer commented Aug 11, 2019

That's a shame. I don't think that the fact that particular solution was abandoned means that this is no longer an issue.

Current solutions for enum documentation have to compromise between code readability and access to documentation. For enums with many variants that do not require long comments, doubling the line count is not reasonable, and prefixing variant definitions with block comments or attributes is awkward at best.

Personally, I choose to favor code readability and use regular code comments, which is obviously not ideal, since no documentation will be generated for the variants, but I find it far preferable to adding hundreds of excess lines to get around this issue.

@steveklabnik
Copy link
Member

steveklabnik commented Aug 11, 2019 via email

@blueforesticarus
Copy link

blueforesticarus commented Aug 6, 2022

@rzumer is right, adding (likely 2) extra lines of code harms readability and there shouldn't be a tradeoff between readability and documentation.

@SOF3
Copy link

SOF3 commented Aug 7, 2022

would be great if editors had support to hide (not just collapse) all comments, then there is no tradeoff at all.

@blueforesticarus
Copy link

What would actually be good would be a 2 column view.
Code on one side, and the comments on the other.
like 2 column proofs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-lang Relevant to the language team, which will review and decide on the RFC. T-rustdoc Relevant to rustdoc team, which will review and decide on the RFC.
Projects
None yet
Development

No branches or pull requests

9 participants