Skip to content

Commit

Permalink
Add support for overriding the setter documentation on a per-field ba…
Browse files Browse the repository at this point in the history
…sis. (Fixes #10)
  • Loading branch information
Lymia committed Aug 6, 2024
1 parent 8de3bd3 commit 553387b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ struct FieldAttrs {
/// Whether to skip this field regardless of global settings. Overwrites `generate`.
#[darling(default)]
skip: bool,

/// The documentation used for this field's setter.
#[darling(default)]
doc: Option<String>,
}

struct ContainerDef {
Expand Down Expand Up @@ -208,6 +212,8 @@ fn init_field_def(
let doc_str =
format!("Sets the [`{}`](#structfield.{}) field of this struct.", ident, ident);
quote! { #[doc = #doc_str] }
} else if let Some(x) = darling_attrs.doc {
quote! { #[doc = #x] }
} else {
let attrs = darling_attrs.attrs;
quote! { #( #attrs )* }
Expand Down

0 comments on commit 553387b

Please sign in to comment.