From d368f426fbe4a888679fd4838f0b7bfe00e310a5 Mon Sep 17 00:00:00 2001 From: James Wilson Date: Tue, 11 Mar 2025 16:07:00 +0000 Subject: [PATCH 1/3] Add docs for subxt-rpcs and fix example --- CHANGELOG.md | 2 +- rpcs/README.md | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 rpcs/README.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d9ddb1eca7..6cacf872def 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,7 +27,7 @@ Example usage via `jsonrpsee` feature: use subxt_rpcs::{RpcClient, ChainHeadRpcMethods}; // Connect to a local node: -let client = RpcClient::("ws://127.0.0.1:9944").await?; +let client = RpcClient::from_url("ws://127.0.0.1:9944").await?; // Use chainHead/archive V2 methods: let methods = ChainHeadRpcMethods::new(client); diff --git a/rpcs/README.md b/rpcs/README.md new file mode 100644 index 00000000000..99819b5d14d --- /dev/null +++ b/rpcs/README.md @@ -0,0 +1,18 @@ +# subxt-rpcs + +This crate provides an interface for interacting with Substrate nodes via the available RPC methods. + +```rust +use subxt_rpcs::{RpcClient, ChainHeadRpcMethods}; + +// Connect to a local node: +let client = RpcClient::from_url("ws://127.0.0.1:9944").await?; +// Use a set of methods, here the V2 "chainHead" ones: +let methods = ChainHeadRpcMethods::new(client); + +// Call some RPC methods (in this case a subscription): +let mut follow_subscription = methods.chainhead_v1_follow(false).await.unwrap(); +while let Some(follow_event) = follow_subscription.next().await { + // do something with events.. +} +``` \ No newline at end of file From 3a34de5b7303b2fac12fc050e2bf1349c7949194 Mon Sep 17 00:00:00 2001 From: James Wilson Date: Tue, 11 Mar 2025 16:10:13 +0000 Subject: [PATCH 2/3] Add docs bits in Cargo.toml --- rpcs/Cargo.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rpcs/Cargo.toml b/rpcs/Cargo.toml index f3a62d63635..ef288dc54c5 100644 --- a/rpcs/Cargo.toml +++ b/rpcs/Cargo.toml @@ -94,5 +94,9 @@ tower = { workspace = true } hyper = { workspace = true } http-body = { workspace = true } +[package.metadata.docs.rs] +default-features = true +rustdoc-args = ["--cfg", "docsrs"] + [lints] workspace = true From 467a718c06f89b99053cd44e10e9f40655914676 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Tue, 11 Mar 2025 17:22:58 +0100 Subject: [PATCH 3/3] add missing docsrs cfg_attr --- rpcs/src/lib.rs | 2 ++ utils/fetch-metadata/src/lib.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/rpcs/src/lib.rs b/rpcs/src/lib.rs index e6db55fe409..27fe49d594a 100644 --- a/rpcs/src/lib.rs +++ b/rpcs/src/lib.rs @@ -16,6 +16,8 @@ //! The provided RPC client implementations can be used natively (with the default `native` feature //! flag) or in WASM based web apps (with the `web` feature flag). +#![cfg_attr(docsrs, feature(doc_cfg))] + #[cfg(any( all(feature = "web", feature = "native"), not(any(feature = "web", feature = "native")) diff --git a/utils/fetch-metadata/src/lib.rs b/utils/fetch-metadata/src/lib.rs index b906f99360e..779aceb7250 100644 --- a/utils/fetch-metadata/src/lib.rs +++ b/utils/fetch-metadata/src/lib.rs @@ -4,6 +4,8 @@ //! Subxt utils fetch metadata. +#![cfg_attr(docsrs, feature(doc_cfg))] + // Internal helper macros #[macro_use] mod macros;