alloy-rs / core

High-performance, well-tested & documented core libraries for Ethereum, in Rust
https://alloy.rs
Apache License 2.0
763 stars 137 forks source link

feat(sol-macro): allow missing docs for event fields #619

Closed alexfertel closed 4 months ago

alexfertel commented 4 months ago

See https://github.com/alloy-rs/core/issues/588#issuecomment-2094823588

Motivation

We want this sol! invocation to not generate a missing_docs warning:

sol! {
    /// Emitted when `value` tokens are moved from one account (`from`) to
    /// another (`to`).
    ///
    /// Note that `value` may be zero.
    event Transfer(address indexed from, address indexed to, uint256 value);
    /// Emitted when the allowance of a `spender` for an `owner` is set by a
    /// call to `approve`. `value` is the new allowance.
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

Solution

We add an #[allow(missing_docs)] annotation to the generated event struct fields. The alternative would be supporting:

sol! {
    /// ...
    event Approval(
        /// ...
        address indexed owner,
        /// ...
        address indexed spender,
        /// ...
        uint256 value
    );
}

Which is less readable and redundant.

PR Checklist

I don't think the above apply, but lmk if that is not the case.

gakonst commented 4 months ago

OK with this as temp fix, and we can do the full solution in follow-up