From f9086e703c13eb4c57e5eb4cf3d15a509973ac8b Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 8 Mar 2023 23:58:44 +0100 Subject: [PATCH] fix: docsrs builds final (#2235) * fix * fix: middleware * fix: update rustc flags * docs: add comment --- Cargo.toml | 1 + ethers-contract/Cargo.toml | 1 + .../ethers-contract-abigen/Cargo.toml | 1 + .../ethers-contract-derive/Cargo.toml | 1 + ethers-contract/src/lib.rs | 19 ++++++------------- ethers-core/Cargo.toml | 1 + ethers-etherscan/Cargo.toml | 1 + ethers-middleware/Cargo.toml | 1 + ethers-middleware/src/lib.rs | 16 ++++++++++++++++ ethers-providers/Cargo.toml | 1 + ethers-signers/Cargo.toml | 1 + src/lib.rs | 10 +++++----- 12 files changed, 36 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 76b03627..0e0ee19d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,6 +38,7 @@ default-members = [ [package.metadata.docs.rs] all-features = true +rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"] [package.metadata.playground] diff --git a/ethers-contract/Cargo.toml b/ethers-contract/Cargo.toml index d884690d..c0bf6e45 100644 --- a/ethers-contract/Cargo.toml +++ b/ethers-contract/Cargo.toml @@ -57,4 +57,5 @@ openssl = ["ethers-contract-abigen/openssl"] [package.metadata.docs.rs] all-features = true +rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"] diff --git a/ethers-contract/ethers-contract-abigen/Cargo.toml b/ethers-contract/ethers-contract-abigen/Cargo.toml index 4c810979..9fb480fe 100644 --- a/ethers-contract/ethers-contract-abigen/Cargo.toml +++ b/ethers-contract/ethers-contract-abigen/Cargo.toml @@ -43,6 +43,7 @@ getrandom = { version = "0.2", features = ["js"] } [package.metadata.docs.rs] all-features = true +rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"] [features] diff --git a/ethers-contract/ethers-contract-derive/Cargo.toml b/ethers-contract/ethers-contract-derive/Cargo.toml index 90ca8620..7a757406 100644 --- a/ethers-contract/ethers-contract-derive/Cargo.toml +++ b/ethers-contract/ethers-contract-derive/Cargo.toml @@ -30,4 +30,5 @@ eyre = "0.6" [package.metadata.docs.rs] all-features = true +rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"] diff --git a/ethers-contract/src/lib.rs b/ethers-contract/src/lib.rs index c72f7c93..8c8474bc 100644 --- a/ethers-contract/src/lib.rs +++ b/ethers-contract/src/lib.rs @@ -69,7 +69,8 @@ pub use once_cell::sync::Lazy; #[cfg(feature = "eip712")] pub use ethers_derive_eip712::*; -// For Abigen expansions in docs.rs builds. +// For macro expansions only, not public API. +// See: [#2235](https://github.com/gakonst/ethers-rs/pull/2235) #[doc(hidden)] #[allow(unused_extern_crates)] @@ -77,23 +78,15 @@ extern crate self as ethers_contract; #[doc(hidden)] #[allow(unused_extern_crates)] -#[cfg(docsrs)] extern crate self as ethers; #[doc(hidden)] -#[cfg(docsrs)] -pub mod core { - pub use ethers_core::*; -} - -#[doc(hidden)] -#[cfg(docsrs)] pub mod contract { pub use crate::*; } #[doc(hidden)] -#[cfg(docsrs)] -pub mod providers { - pub use ethers_providers::*; -} +pub use ethers_core as core; + +#[doc(hidden)] +pub use ethers_providers as providers; diff --git a/ethers-core/Cargo.toml b/ethers-core/Cargo.toml index 8be4b4d8..147eb874 100644 --- a/ethers-core/Cargo.toml +++ b/ethers-core/Cargo.toml @@ -66,4 +66,5 @@ macros = ["syn", "cargo_metadata", "once_cell"] [package.metadata.docs.rs] all-features = true +rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"] diff --git a/ethers-etherscan/Cargo.toml b/ethers-etherscan/Cargo.toml index 827257b1..44d68782 100644 --- a/ethers-etherscan/Cargo.toml +++ b/ethers-etherscan/Cargo.toml @@ -42,6 +42,7 @@ tracing-subscriber = { version = "0.3", default-features = false, features = ["e [package.metadata.docs.rs] all-features = true +rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"] [features] diff --git a/ethers-middleware/Cargo.toml b/ethers-middleware/Cargo.toml index 382ac2dd..431577b1 100644 --- a/ethers-middleware/Cargo.toml +++ b/ethers-middleware/Cargo.toml @@ -12,6 +12,7 @@ keywords = ["ethereum", "web3", "celo", "ethers"] [package.metadata.docs.rs] all-features = true +rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"] [dependencies] diff --git a/ethers-middleware/src/lib.rs b/ethers-middleware/src/lib.rs index 88aa042f..127b8337 100644 --- a/ethers-middleware/src/lib.rs +++ b/ethers-middleware/src/lib.rs @@ -40,3 +40,19 @@ pub use timelag::TimeLag; /// [`Middleware`](ethers_providers::Middleware) in a concise way pub mod builder; pub use builder::MiddlewareBuilder; + +// For macro expansions only, not public API. +// See: [#2235](https://github.com/gakonst/ethers-rs/pull/2235) + +#[doc(hidden)] +#[allow(unused_extern_crates)] +extern crate self as ethers; + +#[doc(hidden)] +pub use ethers_contract as contract; + +#[doc(hidden)] +pub use ethers_core as core; + +#[doc(hidden)] +pub use ethers_providers as providers; diff --git a/ethers-providers/Cargo.toml b/ethers-providers/Cargo.toml index 93934caf..60112918 100644 --- a/ethers-providers/Cargo.toml +++ b/ethers-providers/Cargo.toml @@ -12,6 +12,7 @@ keywords = ["ethereum", "web3", "celo", "ethers"] [package.metadata.docs.rs] all-features = true +rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"] [dependencies] diff --git a/ethers-signers/Cargo.toml b/ethers-signers/Cargo.toml index 94039a27..f90f93e7 100644 --- a/ethers-signers/Cargo.toml +++ b/ethers-signers/Cargo.toml @@ -12,6 +12,7 @@ keywords = ["ethereum", "web3", "celo", "ethers"] [package.metadata.docs.rs] all-features = true +rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"] [dependencies] diff --git a/src/lib.rs b/src/lib.rs index 59fc9519..8cdc5983 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -83,11 +83,6 @@ #![deny(rustdoc::broken_intra_doc_links)] #![doc(test(no_crate_inject, attr(deny(rust_2018_idioms), allow(dead_code, unused_variables))))] -// For macro expansion -#[doc(hidden)] -#[allow(unused_extern_crates)] -extern crate self as ethers; - #[doc(inline)] pub use ethers_addressbook as addressbook; #[doc(inline)] @@ -129,3 +124,8 @@ pub mod prelude { #[cfg(feature = "ethers-solc")] pub use super::solc::*; } + +// For macro expansions only, not public API. +#[doc(hidden)] +#[allow(unused_extern_crates)] +extern crate self as ethers;