diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 35cfe84f7e..bbafaa5900 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -60,3 +60,5 @@ arbitrary = [ ] k256 = ["alloy-primitives/k256"] eip712 = ["alloy-sol-types?/eip712-serde", "alloy-dyn-abi?/eip712"] + +unstable-doc = ["alloy-primitives/unstable-doc"] diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index 255555b2b2..93a3ecc46d 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -12,6 +12,11 @@ pub use alloy_primitives as primitives; #[doc(no_inline)] pub use primitives::{hex, uint}; +#[cfg(feature = "unstable-doc")] +#[doc(hidden)] +#[allow(unused_imports)] +pub use primitives::PrivateSignature as _; + #[cfg(feature = "dyn-abi")] #[doc(inline)] pub use alloy_dyn_abi as dyn_abi; diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 04fdbe6454..3f4bd42d43 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -110,6 +110,8 @@ allocative = ["dep:allocative"] # Should not be needed most of the time. hex-compat = ["hex/hex"] +unstable-doc = [] + [[bench]] name = "primitives" path = "benches/primitives.rs" diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index bdb3ede209..6e8c65f30f 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -53,6 +53,12 @@ pub use signed::{BigIntConversionError, ParseSignedError, Sign, Signed}; mod signature; pub use signature::{to_eip155_v, Parity, SignatureError}; +/// Only available for documentation purposes. +// Without this visible (not `#[doc(hidden)]`) re-export, `rustdoc` will not generate documentation +// for the `Signature` type alias below. +#[cfg(feature = "unstable-doc")] +pub use signature::Signature as PrivateSignature; + /// An ECDSA Signature, consisting of V, R, and S. #[cfg(feature = "k256")] pub type Signature = signature::Signature; diff --git a/crates/primitives/src/signature/mod.rs b/crates/primitives/src/signature/mod.rs index ab4bc8448d..5dd8e22a60 100644 --- a/crates/primitives/src/signature/mod.rs +++ b/crates/primitives/src/signature/mod.rs @@ -5,6 +5,9 @@ mod parity; pub use parity::Parity; mod sig; +#[cfg(feature = "unstable-doc")] +pub use sig::Signature; +#[cfg(not(feature = "unstable-doc"))] pub(crate) use sig::Signature; mod utils; diff --git a/crates/primitives/src/signature/sig.rs b/crates/primitives/src/signature/sig.rs index bb85223c22..193d8ae07e 100644 --- a/crates/primitives/src/signature/sig.rs +++ b/crates/primitives/src/signature/sig.rs @@ -101,6 +101,7 @@ impl From<(k256::ecdsa::Signature, k256::ecdsa::RecoveryId)> for Signature Result { use alloy_rlp::Decodable;