From 7d20bdf1bdf797c42384c6e88c90b14e8a60cbf0 Mon Sep 17 00:00:00 2001 From: Gun9niR Date: Fri, 27 Jan 2023 12:48:44 +0000 Subject: [PATCH] forward rustdoc from config to opts --- src/common/proc_macro/src/config.rs | 8 ++++++++ 1 file changed, 8 insertions(+) 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 };