diff --git a/crates/sol-macro-expander/src/expand/contract.rs b/crates/sol-macro-expander/src/expand/contract.rs index 7de532b40..03a4a4e3c 100644 --- a/crates/sol-macro-expander/src/expand/contract.rs +++ b/crates/sol-macro-expander/src/expand/contract.rs @@ -874,7 +874,10 @@ impl CallLikeExpander<'_> { let mut tokens = quote! { #(#attrs)* pub enum #name { - #(#variants(#types),)* + #( + #[allow(missing_docs)] + #variants(#types), + )* } #[automatically_derived] diff --git a/crates/sol-macro-expander/src/expand/event.rs b/crates/sol-macro-expander/src/expand/event.rs index 407b1dd10..fda18502b 100644 --- a/crates/sol-macro-expander/src/expand/event.rs +++ b/crates/sol-macro-expander/src/expand/event.rs @@ -151,10 +151,7 @@ pub(super) fn expand(cx: &ExpCtxt<'_>, event: &ItemEvent) -> Result #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields, clippy::style)] #[derive(Clone)] pub struct #name { - #( - #[allow(missing_docs)] - pub #fields, - )* + #( #fields, )* } #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields, clippy::style)] @@ -259,5 +256,10 @@ fn expand_event_topic_field( } else { cx.expand_rust_type(¶m.ty) }; - quote!(#name: #ty) + let attrs = ¶m.attrs; + quote! { + #(#attrs)* + #[allow(missing_docs)] + pub #name: #ty + } } diff --git a/crates/sol-macro-expander/src/expand/mod.rs b/crates/sol-macro-expander/src/expand/mod.rs index 6abe9491f..c892f51da 100644 --- a/crates/sol-macro-expander/src/expand/mod.rs +++ b/crates/sol-macro-expander/src/expand/mod.rs @@ -778,6 +778,7 @@ fn expand_fields<'a, P>( let attrs = &var.attrs; quote! { #(#attrs)* + #[allow(missing_docs)] pub #name: #ty } }) diff --git a/tests/core-sol/src/lib.rs b/tests/core-sol/src/lib.rs index 72a4cafdb..6a317ab38 100644 --- a/tests/core-sol/src/lib.rs +++ b/tests/core-sol/src/lib.rs @@ -64,6 +64,70 @@ sol! { } } +/// Docs +#[deny(missing_docs)] +pub mod no_missing_docs { + alloy_core::sol! { + #[allow(missing_docs)] + contract Allowed { + uint256 public number; + + struct MyStruct { + uint256 a; + bool b; + } + + function setNumber(uint256 newNumber) public { + number = newNumber; + } + + function increment() public { + number++; + } + + event Transfer(address indexed from, address indexed to, uint256 value); + event Approval(address indexed owner, address indexed spender, uint256 value); + + error Transfer2(address from, address to, uint256 value); + error Approval2(address owner, address spender, uint256 value); + } + + /// Docs + contract NotAllowed { + /// Docs + uint256 public number; + + /// Docs + struct MyStruct { + /// Docs + uint256 a; + /// Docs + bool b; + } + + /// Docs + function setNumber(uint256 newNumber) public { + number = newNumber; + } + + /// Docs + function increment() public { + number++; + } + + /// Docs + event Transfer(address indexed from, address indexed to, uint256 value); + /// Docs + event Approval(address indexed owner, address indexed spender, uint256 value); + + /// Docs + error Transfer2(address from, address to, uint256 value); + /// Docs + error Approval2(address owner, address spender, uint256 value); + } + } +} + #[test] #[cfg_attr(miri, ignore = "foldhash queries time (orlp/foldhash#4)")] fn do_stuff() {