Skip to content

Introduce setters(doc(default(skip))) attribute#265

Merged
Veetaha merged 5 commits intomasterfrom
feat/skip-default-in-docs
Mar 16, 2025
Merged

Introduce setters(doc(default(skip))) attribute#265
Veetaha merged 5 commits intomasterfrom
feat/skip-default-in-docs

Conversation

@Veetaha
Copy link
Collaborator

@Veetaha Veetaha commented Mar 16, 2025

Closes #260

Member level example

Code:

#[derive(bon::Builder)]
pub struct MemberExample {
    /// Shows the default (no overrides).
    #[builder(default = 42)]
    shown: u32,

    /// Skips the default (overridden via the attribute).
    #[builder(default = 42, setters(doc(default(skip))))]
    hidden: u32,
}

Generated docs:

image

Top level example

Code:

#[derive(bon::Builder)]
#[builder(on(u32, setters(doc(default(skip)))))]
pub struct TopLevelExample {
    /// Doesn't match the `on(u32, ...)` type pattern, and thus shows
    /// the default in the docs.
    /// If you want to select all members, then use the pattern `_`.
    #[builder(default = 42)]
    shown: i32,

    /// Matches the `on(u32, ...)` type pattern, and thus skips the default
    /// in the docs.
    #[builder(default = 42)]
    hidden: u32,
}

Generated docs:

image

@Veetaha Veetaha merged commit 0c69168 into master Mar 16, 2025
27 checks passed
@Veetaha Veetaha deleted the feat/skip-default-in-docs branch March 16, 2025 18:33
@github-actions github-actions bot mentioned this pull request Mar 16, 2025
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.

Add an ability to customize the standard docs header for setters

2 participants