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

Multi-line doc comments overriding raw about attributes #514

Closed
fitzgen opened this issue Nov 30, 2021 · 2 comments
Closed

Multi-line doc comments overriding raw about attributes #514

fitzgen opened this issue Nov 30, 2021 · 2 comments

Comments

@fitzgen
Copy link
Contributor

fitzgen commented Nov 30, 2021

Summary

The section for help/about text in the crate-level docs say

Raw methods have priority over doc comments!

but that behavior is not exhibited when the doc comment has multiple lines.

Test Case

.tar.gz bundle with full source, Cargo.toml, and Cargo.lock

use structopt::StructOpt;

/// Doc comment.
///
/// Multi-line.
#[derive(StructOpt)]
#[structopt(about = "Raw method.")]
pub struct Options {}

fn main() {
    Options::from_args();
}

Steps to Reproduce

Untar the test case, cd into it, and run

$ cargo run -- --help

Expected Results

The about text should be

Raw method.

Actual Results

The about text reads

Doc comment.

Multi-line.

Misc.

If the doc comment is trimmed to a single line, e.g. just /// Doc comment., then the raw about method takes priority again.

Tested with structopt version 0.3.25.

@fitzgen fitzgen changed the title Multi-line doc comments overrriding raw about attributes Multi-line doc comments overriding raw about attributes Nov 30, 2021
@epage
Copy link
Contributor

epage commented Nov 30, 2021

I suspect this is the same thing we are seeing with clap_derive: clap-rs/clap#2983

@epage
Copy link
Contributor

epage commented Nov 30, 2021

Looked a little closer. This is similar to clap-rs/clap#2983 in that you are overriding about but not overriding long_about while your doc comment is setting both. You'll see this dual nature by passing -h instead of --help.

The way to resolve this is to also set long_about.

@TeXitoi TeXitoi closed this as completed Dec 9, 2021
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

3 participants