From d821c7b82a4e787096a742205a6730c555edf969 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Fri, 13 May 2022 13:31:50 +0200 Subject: [PATCH] fix: generate docs for all features on docs.rs (#767) * fix: generate docs for all features * ci: check for --cfg docsrs * fix nit: rustdoc::broken_intra_doc_links --- .github/workflows/ci.yml | 18 ++++++++++++++++-- client/http-client/Cargo.toml | 7 +++++++ client/transport/Cargo.toml | 7 +++++++ client/transport/src/lib.rs | 1 + client/ws-client/Cargo.toml | 7 +++++++ core/Cargo.toml | 7 +++++++ core/src/lib.rs | 1 + jsonrpsee/Cargo.toml | 7 +++++++ jsonrpsee/src/lib.rs | 2 ++ 9 files changed, 55 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a114504e5..c3ae9135dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,8 +48,22 @@ jobs: command: clippy args: --all-targets - - name: Check rustdoc links - run: RUSTDOCFLAGS="--deny broken_intra_doc_links" cargo doc --verbose --workspace --no-deps --document-private-items + check-docs: + name: Check rustdoc + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@v3 + + - name: Install Rust nightly toolchain + uses: actions-rs/toolchain@v1.0.7 + with: + profile: minimal + toolchain: nightly + override: true + + - name: Check rustdoc + run: RUSTDOCFLAGS="--cfg docsrs --deny rustdoc::broken_intra_doc_links" cargo doc --verbose --workspace --no-deps --document-private-items --all-features check-code: name: Check diff --git a/client/http-client/Cargo.toml b/client/http-client/Cargo.toml index 3435e11a0f..eb373c0b7e 100644 --- a/client/http-client/Cargo.toml +++ b/client/http-client/Cargo.toml @@ -29,3 +29,10 @@ tokio = { version = "1.16", features = ["net", "rt-multi-thread", "macros"] } [features] default = ["tls"] tls = ["hyper-rustls/webpki-tokio"] + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.playground] +all-features = true diff --git a/client/transport/Cargo.toml b/client/transport/Cargo.toml index 5bf8cb7674..7f258a00c4 100644 --- a/client/transport/Cargo.toml +++ b/client/transport/Cargo.toml @@ -54,3 +54,10 @@ web = [ "anyhow", "thiserror", ] + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.playground] +all-features = true diff --git a/client/transport/src/lib.rs b/client/transport/src/lib.rs index 4cce4fbce3..088249a761 100644 --- a/client/transport/src/lib.rs +++ b/client/transport/src/lib.rs @@ -25,6 +25,7 @@ // DEALINGS IN THE SOFTWARE. #![warn(missing_debug_implementations, missing_docs, unreachable_pub)] +#![cfg_attr(docsrs, feature(doc_cfg))] //! # jsonrpsee-client-transports //! diff --git a/client/ws-client/Cargo.toml b/client/ws-client/Cargo.toml index ba947abee6..3c5433e397 100644 --- a/client/ws-client/Cargo.toml +++ b/client/ws-client/Cargo.toml @@ -23,3 +23,10 @@ serde_json = "1" [features] tls = ["jsonrpsee-client-transport/tls"] default = ["tls"] + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.playground] +all-features = true diff --git a/core/Cargo.toml b/core/Cargo.toml index 74587333ff..e24cc6f8c0 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -68,3 +68,10 @@ async-wasm-client = [ serde_json = "1.0" tokio = { version = "1.16", features = ["macros", "rt"] } jsonrpsee = { path = "../jsonrpsee", features = ["server", "macros"] } + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.playground] +all-features = true diff --git a/core/src/lib.rs b/core/src/lib.rs index f3fc4916e2..c1d77de7b3 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -27,6 +27,7 @@ //! Shared utilities for `jsonrpsee`. #![warn(missing_docs, missing_debug_implementations, unreachable_pub)] +#![cfg_attr(docsrs, feature(doc_cfg))] // Macros useful internally within this crate, but not to be exposed outside of it. #[macro_use] diff --git a/jsonrpsee/Cargo.toml b/jsonrpsee/Cargo.toml index e979f9543a..d5fc0cd0a7 100644 --- a/jsonrpsee/Cargo.toml +++ b/jsonrpsee/Cargo.toml @@ -37,3 +37,10 @@ macros = ["jsonrpsee-proc-macros", "jsonrpsee-types", "jsonrpsee-core/client", " client = ["http-client", "ws-client", "wasm-client"] server = ["http-server", "ws-server"] full = ["client", "server", "macros", "async-client", "client-ws-transport"] + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.playground] +all-features = true diff --git a/jsonrpsee/src/lib.rs b/jsonrpsee/src/lib.rs index dcc4b65d23..a792f32796 100644 --- a/jsonrpsee/src/lib.rs +++ b/jsonrpsee/src/lib.rs @@ -48,6 +48,8 @@ //! - **`client-ws-transport`** - Enables `ws` transport with TLS. //! - **`client-ws-transport-no-tls`** - Enables `ws` transport without TLS. +#![cfg_attr(docsrs, feature(doc_cfg))] + // Macros useful below, but not to be exposed outside of the crate. #[macro_use] mod macros;