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

Apply field doc-comments to builder methods #146

Merged
merged 1 commit into from
Jun 15, 2024

Conversation

sunsided
Copy link
Contributor

@sunsided sunsided commented Jun 15, 2024

I noticed that the builder has support for explicitly provided comments, e.g. via

#[builder(
    default,
    setter(strip_option, doc = "Set `y`. If you don't specify a value it'll default to no value.",)
)]

However, regular doccomments would be ignored even when no setter-specific doc attribute is provided. With this PR, the following is now possible:

struct Foo {
    /// `x` value.
    ///
    /// This field is mandatory.
    x: i32,

    /// This doccomment is ignored for the setter. 
    #[builder(
        default,
        setter(strip_option, doc = "Set `y`. If you don't specify a value it'll default to no value.",)
    )]
    y: Option<i32>,

    #[builder(default = 20)]
    z: i32,
}

On the builder, x(...) will be documented with the regular doccomment, y(...) is documented with the setter attribute as before and z(...) remains undocumented, as before.

When the builder emits deprecated functions, they also inherit the documentation. This was not previously the case.

Signed-off-by: Markus Mayer <widemeadows@gmail.com>
@idanarye
Copy link
Owner

Thanks!

@idanarye idanarye merged commit 20f59ae into idanarye:master Jun 15, 2024
9 checks passed
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

Successfully merging this pull request may close these issues.

2 participants