diff --git a/src/common/proc_macro/src/config.rs b/src/common/proc_macro/src/config.rs index cacec6d280181..f553cc6237ee3 100644 --- a/src/common/proc_macro/src/config.rs +++ b/src/common/proc_macro/src/config.rs @@ -55,6 +55,13 @@ pub fn produce_cli_overwrite(input: DeriveInput) -> TokenStream { { let field_ident = field.ident; let field_type = field.ty; + // Forward rustdoc to derived struct. + let field_docs: Vec<_> = field + .attrs + .into_iter() + .filter(|attr| attr.path.is_ident("doc")) + .collect(); + // If the original type is wrapped by `Option`, keep it. // Otherwise extract the inner type. let is_option = { @@ -92,6 +99,7 @@ pub fn produce_cli_overwrite(input: DeriveInput) -> TokenStream { let opt_attrs = gen_clap_attribute(cli_overwrite_attrs); let opt_field = quote! { + #(#field_docs)* #opt_attrs pub #field_ident: #field_type };