Skip to content

Derive help from type comment iinstead of struct comment #2261

Answered by pksunkara
aThorp96 asked this question in Q&A
Discussion options

You must be logged in to vote

Ideally using the same code as before, clap's derivation would see that the type of Do::One is not actually BaseAction but Action1, and use its doc comment to derive help. I'm not sure how possible that is with the way clap derives, however.

That's not how rust derive macros work. They can't see outside the scope they are defined for. And type statements don't support derive macros either. Basically, this is impossible as of now.

The alternative is the recommended way to do this. Infact you don't even need to define the types separately here.

/// Do an action
#[derive(Clap, Debug, Clone, PartialEq)]
enum Do {
    /// Does some action
    One(BaseAction),
    /// Does some other action
    

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aThorp96
Comment options

Answer selected by pksunkara
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2261 on December 22, 2020 17:34.