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

Multiline doc comments should use newline delimiter #310

Closed
peterhuene opened this issue Dec 20, 2019 · 1 comment
Closed

Multiline doc comments should use newline delimiter #310

peterhuene opened this issue Dec 20, 2019 · 1 comment

Comments

@peterhuene
Copy link

peterhuene commented Dec 20, 2019

The fix for #25 joined multiline doc comments with a space.

However, clap supports newlines in help text and properly aligns it.

For the original example:

#[derive(StructOpt, Debug)]
struct Args {
    /// Doc comment: First line
    /// Doc comment: Second line
    parameter: String,
}

This outputs:

<parameter>    Doc comment: First line Doc comment: Second line

If instead the lines join with \n instead of space, clap would output:

<parameter>    Doc comment: First line
               Doc comment: Second line
@CreepySkeleton
Copy link
Collaborator

In clap, multiline help messages and one-big-line messages are different.

Multiline messages are displayed "as is", all the line breaks are to be preserved and clap will make no attempt to wrap such a message to the terminal's width.

One line messages are to be wrapped to the terminal's width.

structopt's doc comments implement the one line case by default because most people don't really care about precise formatting when they write a doc comment and they do want their help to be wrapped (or we just think so).

The multiline use case is not possible toady with doc comments, but fear not! This is already in development in #296 which is about to be merged and released. From this moment on all you'll need to do would be adding #[structopt(verbatim_doc_comment)] attribute and structopt won't touch line breaks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants