Skip to content

Commit

Permalink
docs(primitives): fix rustdoc for Signature
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Jun 22, 2024
1 parent ab0200f commit 554a049
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ arbitrary = [
]
k256 = ["alloy-primitives/k256"]
eip712 = ["alloy-sol-types?/eip712-serde", "alloy-dyn-abi?/eip712"]

unstable-doc = []
5 changes: 5 additions & 0 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<k256::ecdsa::Signature>;
Expand Down
3 changes: 3 additions & 0 deletions crates/primitives/src/signature/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions crates/primitives/src/signature/sig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ impl From<(k256::ecdsa::Signature, k256::ecdsa::RecoveryId)> for Signature<k256:

#[cfg(feature = "rlp")]
impl crate::Signature {
/// Decode an RLP-encoded VRS signature.
pub fn decode_rlp_vrs(buf: &mut &[u8]) -> Result<Self, alloy_rlp::Error> {
use alloy_rlp::Decodable;

Expand Down

0 comments on commit 554a049

Please sign in to comment.