-
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
Rustdoc should support inline or same-line doc comments for enums #3306
Comments
This would be especially useful for embedded libraries that have a large amount of register definitions. Readability would be significantly improved if the doc comments could be inlined. |
Note that Rust Style Guide specifically avoids visual-alignment (rust-lang/style-team#8, rust-lang/rustfmt#4108) because it is not diff-friendly (https://doc.rust-lang.org/stable/style-guide/principles.html). So your example if properly formatted (i.e. after 4108 is fixed) should look like enum Action {
Clone, //< Display file's information rights (size,rights).
Init, //< Create an empty Git repository or reinitialize an existing one
Add, //< Add file contents to the index
}
Using a new syntax
In practice when you #[derive(Subcommand)]
enum Action {
#[command(arg_required_else_help = true)]
Clone { //< Clones repos
remote: String, //< The remote to clone
},
#[command(arg_required_else_help = true)]
Add { //< adds things
#[arg(required = true)]
path: Vec<PathBuf>, //< Stuff to add
},
} Considering this the |
@ThomasMontanoGames If it is really so bad for you, you could always do |
Hi,
As suggested in an old and closed but still active discussion, I open another thread because it looks interesting to have the capability to have inline comments.
My use case concerns a CLI which should parse the arguments, so in order to not reinvent the wheel I have tried with Clap .
Clap looks to use the rust documentation to display the sub-command comments.
Unfortunately, it is not possible today to align the action with the comment.
Indeed it becomes more readable when the comment is on the same line (like it is displayed with the sub-command "help").
For this use case, the comment should be "short and pithy" but it does not look to be an anti pattern as discussed in this thread.
Thanks in advance for your feedback and the work you're realizing.
The text was updated successfully, but these errors were encountered: