Skip to content

Commit 1c38504

Browse files
authored
docs(primitives): fix rustdoc for Signature (#680)
1 parent ab0200f commit 1c38504

File tree

6 files changed

+19
-0
lines changed

6 files changed

+19
-0
lines changed

crates/core/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,5 @@ arbitrary = [
6060
]
6161
k256 = ["alloy-primitives/k256"]
6262
eip712 = ["alloy-sol-types?/eip712-serde", "alloy-dyn-abi?/eip712"]
63+
64+
unstable-doc = ["alloy-primitives/unstable-doc"]

crates/core/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ pub use alloy_primitives as primitives;
1212
#[doc(no_inline)]
1313
pub use primitives::{hex, uint};
1414

15+
#[cfg(feature = "unstable-doc")]
16+
#[doc(hidden)]
17+
#[allow(unused_imports)]
18+
pub use primitives::PrivateSignature as _;
19+
1520
#[cfg(feature = "dyn-abi")]
1621
#[doc(inline)]
1722
pub use alloy_dyn_abi as dyn_abi;

crates/primitives/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ allocative = ["dep:allocative"]
110110
# Should not be needed most of the time.
111111
hex-compat = ["hex/hex"]
112112

113+
unstable-doc = []
114+
113115
[[bench]]
114116
name = "primitives"
115117
path = "benches/primitives.rs"

crates/primitives/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ pub use signed::{BigIntConversionError, ParseSignedError, Sign, Signed};
5353
mod signature;
5454
pub use signature::{to_eip155_v, Parity, SignatureError};
5555

56+
/// Only available for documentation purposes.
57+
// Without this visible (not `#[doc(hidden)]`) re-export, `rustdoc` will not generate documentation
58+
// for the `Signature` type alias below.
59+
#[cfg(feature = "unstable-doc")]
60+
pub use signature::Signature as PrivateSignature;
61+
5662
/// An ECDSA Signature, consisting of V, R, and S.
5763
#[cfg(feature = "k256")]
5864
pub type Signature = signature::Signature<k256::ecdsa::Signature>;

crates/primitives/src/signature/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ mod parity;
55
pub use parity::Parity;
66

77
mod sig;
8+
#[cfg(feature = "unstable-doc")]
9+
pub use sig::Signature;
10+
#[cfg(not(feature = "unstable-doc"))]
811
pub(crate) use sig::Signature;
912

1013
mod utils;

crates/primitives/src/signature/sig.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ impl From<(k256::ecdsa::Signature, k256::ecdsa::RecoveryId)> for Signature<k256:
101101

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

0 commit comments

Comments
 (0)