udoprog / genco

A whitespace-aware quasiquoter for beautiful code generation.
Apache License 2.0
181 stars 11 forks source link

Support generating documentation and comments #53

Closed adamcavendish closed 9 months ago

adamcavendish commented 9 months ago

I wonder whether there's support to help generate documentation.

quote! {
    #[derive(argh::FromArgs, PartialEq, Debug)]
    #[argh(subcommand)]
    pub enum Subcommand {
        // the command set A
        $(for v in command_a.iter() => a_$v(CommandA_$v),$['\r'])
        // the command set B
        $(for v in command_b.iter() => b_$v(CommandB_$v),$['\r'])
    }
}

In the generated code, the comments are removed i.e. // the command set A and // the command set B. I know it's expected since rust will eliminate comments on compilation. However, I do wonder whether we can support generating the comments into the generated code so we can have better documents in the generated code.

udoprog commented 9 months ago

I'd recommend using a helper like this. It's used like this.

adamcavendish commented 9 months ago

Yeah, this is pretty awesome. Thanks! Better to have it supported in the genco itself.