-
Notifications
You must be signed in to change notification settings - Fork 957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properly set rustdoc attr. Closing #2950 #2975
Changes from all commits
9ffb40b
60a1c35
de1d39a
1520174
6c9a646
10258c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,11 +33,14 @@ | |
//! All key types have functions to enable conversion to/from their binary representations. | ||
|
||
#[cfg(feature = "ecdsa")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "ecdsa")))] | ||
Comment on lines
35
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder whether it is worth it using a macro to remove this duplication. I can see a couple of downsides, not sure how critical they actually are:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just found #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] See https://github.com/tokio-rs/valuable/pull/80/files for example. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will try that, although if we decide to go with this, it would be much easier for me to do that in a new branch (and pull request). |
||
pub mod ecdsa; | ||
pub mod ed25519; | ||
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))] | ||
#[cfg_attr(docsrs, doc(cfg(all(feature = "rsa", not(target_arch = "wasm32")))))] | ||
pub mod rsa; | ||
#[cfg(feature = "secp256k1")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "secp256k1")))] | ||
pub mod secp256k1; | ||
|
||
pub mod error; | ||
|
@@ -70,12 +73,15 @@ pub enum Keypair { | |
Ed25519(ed25519::Keypair), | ||
/// An RSA keypair. | ||
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))] | ||
#[cfg_attr(docsrs, doc(cfg(all(feature = "rsa", not(target_arch = "wasm32")))))] | ||
Rsa(rsa::Keypair), | ||
/// A Secp256k1 keypair. | ||
#[cfg(feature = "secp256k1")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "secp256k1")))] | ||
Secp256k1(secp256k1::Keypair), | ||
/// An ECDSA keypair. | ||
#[cfg(feature = "ecdsa")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "ecdsa")))] | ||
Ecdsa(ecdsa::Keypair), | ||
} | ||
|
||
|
@@ -87,12 +93,14 @@ impl Keypair { | |
|
||
/// Generate a new Secp256k1 keypair. | ||
#[cfg(feature = "secp256k1")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "secp256k1")))] | ||
pub fn generate_secp256k1() -> Keypair { | ||
Keypair::Secp256k1(secp256k1::Keypair::generate()) | ||
} | ||
|
||
/// Generate a new ECDSA keypair. | ||
#[cfg(feature = "ecdsa")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "ecdsa")))] | ||
pub fn generate_ecdsa() -> Keypair { | ||
Keypair::Ecdsa(ecdsa::Keypair::generate()) | ||
} | ||
|
@@ -102,6 +110,7 @@ impl Keypair { | |
/// | ||
/// [RFC5208]: https://tools.ietf.org/html/rfc5208#section-5 | ||
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))] | ||
#[cfg_attr(docsrs, doc(cfg(all(feature = "rsa", not(target_arch = "wasm32")))))] | ||
pub fn rsa_from_pkcs8(pkcs8_der: &mut [u8]) -> Result<Keypair, DecodingError> { | ||
rsa::Keypair::from_pkcs8(pkcs8_der).map(Keypair::Rsa) | ||
} | ||
|
@@ -111,6 +120,7 @@ impl Keypair { | |
/// | ||
/// [RFC5915]: https://tools.ietf.org/html/rfc5915 | ||
#[cfg(feature = "secp256k1")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "secp256k1")))] | ||
pub fn secp256k1_from_der(der: &mut [u8]) -> Result<Keypair, DecodingError> { | ||
secp256k1::SecretKey::from_der(der) | ||
.map(|sk| Keypair::Secp256k1(secp256k1::Keypair::from(sk))) | ||
|
@@ -218,14 +228,17 @@ impl zeroize::Zeroize for keys_proto::PrivateKey { | |
pub enum PublicKey { | ||
/// A public Ed25519 key. | ||
Ed25519(ed25519::PublicKey), | ||
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))] | ||
/// A public RSA key. | ||
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))] | ||
#[cfg_attr(docsrs, doc(cfg(all(feature = "rsa", not(target_arch = "wasm32")))))] | ||
Rsa(rsa::PublicKey), | ||
#[cfg(feature = "secp256k1")] | ||
/// A public Secp256k1 key. | ||
#[cfg(feature = "secp256k1")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "secp256k1")))] | ||
Secp256k1(secp256k1::PublicKey), | ||
/// A public ECDSA key. | ||
#[cfg(feature = "ecdsa")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "ecdsa")))] | ||
Ecdsa(ecdsa::PublicKey), | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,8 @@ | |
//! define how to upgrade each individual substream to use a protocol. | ||
//! See the `upgrade` module. | ||
|
||
#![cfg_attr(docsrs, feature(doc_cfg))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These seems like it is a left over from another attempt at solving this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No I don't think so. This turns the required feature gate on. I.e. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes, my bad! Thanks for clarifying! |
||
|
||
#[allow(clippy::derive_partial_eq_without_eq)] | ||
mod keys_proto { | ||
include!(concat!(env!("OUT_DIR"), "/keys_proto.rs")); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ parking_lot = "0.12" | |
thiserror = "1.0" | ||
yamux = "0.10.0" | ||
log = "0.4" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,7 @@ required-features = ["async-io"] | |
name = "use-tokio" | ||
required-features = ["tokio"] | ||
|
||
[package.metadata.docs.rs] | ||
all-features = true | ||
rustdoc-args = ["--cfg", "docsrs"] | ||
rustc-args = ["--cfg", "docsrs"] | ||
Comment on lines
+49
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it may be worthwhile to just copy-paste this into all manifests? Otherwise, if we add features later we may forget about this. We can include a link to this documentation to make this a bit easier to understand. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a newline so this icon goes away? 😇