Unverified Commit f28f8609 authored by Niklas Adolfsson's avatar Niklas Adolfsson Committed by GitHub
Browse files

fix: generate docs behind features (#741)

* fix: generate docs behind features

* address grumbles
parent 19aaf656
Pipeline #192244 passed with stages
in 5 minutes
......@@ -31,8 +31,10 @@
/// Websocket transport
#[cfg(feature = "ws")]
#[cfg_attr(docsrs, doc(cfg(feature = "ws")))]
pub mod ws;
/// Websocket transport via web-sys.
#[cfg(all(feature = "web", target_arch = "wasm32"))]
#[cfg_attr(docsrs, doc(cfg(feature = "web")))]
pub mod web;
//! Abstract async client.
mod helpers;
mod manager;
......@@ -119,6 +121,7 @@ impl ClientBuilder {
///
/// Panics if called outside of `tokio` runtime context.
#[cfg(feature = "async-client")]
#[cfg_attr(docsrs, doc(cfg(feature = "async-client")))]
pub fn build_with_tokio<S, R>(self, sender: S, receiver: R) -> Client
where
S: TransportSenderT + Send,
......@@ -141,6 +144,7 @@ impl ClientBuilder {
/// Build the client with given transport.
#[cfg(all(feature = "async-wasm-client", target_arch = "wasm32"))]
#[cfg_attr(docsrs, doc(cfg(feature = "async-wasm-client")))]
pub fn build_with_wasm<S, R>(self, sender: S, receiver: R) -> Client
where
S: TransportSenderT,
......
......@@ -48,12 +48,10 @@ pub mod __reexports {
pub use jsonrpsee_types::ParamsSer;
}
/// Async client abstraction that brings additional deps.
#[cfg(any(feature = "async-wasm-client", feature = "async-client"))]
mod async_client;
#[cfg(any(feature = "async-wasm-client", feature = "async-client"))]
pub use async_client::{Client, ClientBuilder};
cfg_async_client! {
pub mod async_client;
pub use async_client::{Client, ClientBuilder};
}
/// [JSON-RPC](https://www.jsonrpc.org/specification) client interface that can make requests and notifications.
#[async_trait]
......
......@@ -24,6 +24,8 @@
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//! Subscription ID providers.
use rand::distributions::Alphanumeric;
use rand::Rng;
......
......@@ -28,6 +28,10 @@
#![warn(missing_docs, missing_debug_implementations, unreachable_pub)]
#[doc(hidden)]
#[macro_use]
pub mod macros;
/// Error type.
pub mod error;
......@@ -37,21 +41,18 @@ pub mod traits;
/// Middleware trait and implementation.
pub mod middleware;
/// Shared hyper helpers.
#[cfg(feature = "http-helpers")]
pub mod http_helpers;
/// Different ways of setting the "id" in JSON-RPC responses and results.
#[cfg(feature = "server")]
pub mod id_providers;
cfg_http_helpers! {
pub mod http_helpers;
}
/// Shared code for JSON-RPC servers.
#[cfg(feature = "server")]
pub mod server;
cfg_server! {
pub mod id_providers;
pub mod server;
}
/// Shared code for JSON-RPC clients.
#[cfg(feature = "client")]
pub mod client;
cfg_client! {
pub mod client;
}
pub use async_trait::async_trait;
pub use error::Error;
......
#[macro_export]
macro_rules! cfg_feature {
($feature:literal, $($item:item)*) => {
$(
#[cfg(feature = $feature)]
#[cfg_attr(docsrs, doc(cfg(feature = $feature)))]
$item
)*
}
}
macro_rules! cfg_client {
($($item:item)*) => {
$crate::cfg_feature!("client", $($item)*);
};
}
macro_rules! cfg_server {
($($item:item)*) => {
$crate::cfg_feature!("server", $($item)*);
};
}
macro_rules! cfg_http_helpers {
($($item:item)*) => {
$crate::cfg_feature!("http-helpers", $($item)*);
};
}
macro_rules! cfg_async_client {
($($item:item)*) => {
$(
#[cfg(any(feature = "async-wasm-client", feature = "async-client"))]
#[cfg_attr(docsrs, doc(cfg(feature = "async-client")))]
#[cfg_attr(docsrs, doc(cfg(feature = "async-wasm-client")))]
$item
)*
}
}
......@@ -12,14 +12,16 @@ documentation = "https://docs.rs/jsonrpsee"
[dependencies]
# No support for namespaced features yet so workspace dependencies are prefixed with `jsonrpsee-`.
# See https://github.com/rust-lang/cargo/issues/5565 for more details.
jsonrpsee-http-client = { path = "../client/http-client", version = "0.11.0", package = "jsonrpsee-http-client", optional = true }
jsonrpsee-ws-client = { path = "../client/ws-client", version = "0.11.0", package = "jsonrpsee-ws-client", optional = true }
jsonrpsee-client-transport = { path = "../client/transport", version = "0.11.0", package = "jsonrpsee-client-transport", optional = true }
jsonrpsee-http-server = { path = "../http-server", version = "0.11.0", package = "jsonrpsee-http-server", optional = true }
jsonrpsee-ws-server = { path = "../ws-server", version = "0.11.0", package = "jsonrpsee-ws-server", optional = true }
jsonrpsee-proc-macros = { path = "../proc-macros", version = "0.11.0", package = "jsonrpsee-proc-macros", optional = true }
jsonrpsee-core = { path = "../core", version = "0.11.0", package = "jsonrpsee-core", optional = true }
jsonrpsee-types = { path = "../types", version = "0.11.0", package = "jsonrpsee-types", optional = true }
jsonrpsee-http-client = { path = "../client/http-client", version = "0.11.0", optional = true }
jsonrpsee-ws-client = { path = "../client/ws-client", version = "0.11.0", optional = true }
jsonrpsee-wasm-client = { path = "../client/wasm-client", version = "0.11.0", optional = true }
jsonrpsee-client-transport = { path = "../client/transport", version = "0.11.0", optional = true }
jsonrpsee-http-server = { path = "../http-server", version = "0.11.0", optional = true }
jsonrpsee-ws-server = { path = "../ws-server", version = "0.11.0", optional = true }
jsonrpsee-proc-macros = { path = "../proc-macros", version = "0.11.0", optional = true }
jsonrpsee-core = { path = "../core", version = "0.11.0", optional = true }
jsonrpsee-types = { path = "../types", version = "0.11.0", optional = true }
tracing = { version = "0.1", optional = true }
[features]
client-ws-transport = ["jsonrpsee-client-transport/ws", "jsonrpsee-client-transport/tls"]
......@@ -27,10 +29,11 @@ client-ws-transport-no-tls = ["jsonrpsee-client-transport/ws"]
async-client = ["jsonrpsee-core/async-client"]
http-client = ["jsonrpsee-http-client", "jsonrpsee-types", "jsonrpsee-core"]
http-server = ["jsonrpsee-http-server", "jsonrpsee-types", "jsonrpsee-core"]
ws-client = ["jsonrpsee-ws-client", "jsonrpsee-types", "jsonrpsee-core/async-client"]
wasm-client = ["jsonrpsee-wasm-client", "jsonrpsee-types", "jsonrpsee-core"]
ws-client = ["jsonrpsee-ws-client", "jsonrpsee-types", "jsonrpsee-core"]
ws-server = ["jsonrpsee-ws-server", "jsonrpsee-types", "jsonrpsee-core"]
macros = ["jsonrpsee-proc-macros", "jsonrpsee-types", "jsonrpsee-core/client"]
macros = ["jsonrpsee-proc-macros", "jsonrpsee-types", "jsonrpsee-core/client", "tracing"]
client = ["http-client", "ws-client"]
client = ["http-client", "ws-client", "wasm-client"]
server = ["http-server", "ws-server"]
full = ["client", "server", "macros", "async-client", "client-ws-transport"]
......@@ -24,7 +24,7 @@
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//! Jsonrpsee wrapper crate.
//! jsonrpsee wrapper crate.
//!
//! <br>
//!
......@@ -37,6 +37,7 @@
//!
//! - **`http-client`** - JSON-RPC client functionality over HTTP protocol.
//! - **`http-server`** - JSON-RPC server functionality over HTTP protocol.
//! - **`wasm-client`** - JSON-RPC client functionality over web-sys.
//! - **`ws-client`** - JSON-RPC client functionality over WebSocket protocol.
//! - **`ws-server`** - JSON-RPC server functionality over WebSocket protocol.
//! - **`macros`** - JSON-RPC API generation convenience by derive macros.
......@@ -47,53 +48,54 @@
//! - **`client-ws-transport`** - Enables `ws` transport with TLS.
//! - **`client-ws-transport-no-tls`** - Enables `ws` transport without TLS.
/// JSON-RPC HTTP client.
#[cfg(feature = "jsonrpsee-http-client")]
pub use jsonrpsee_http_client as http_client;
#[macro_use]
mod macros;
/// JSON-RPC WebSocket client.
#[cfg(feature = "jsonrpsee-ws-client")]
pub use jsonrpsee_ws_client as ws_client;
cfg_http_client! {
pub use jsonrpsee_http_client as http_client;
}
#[cfg(feature = "jsonrpsee-client-transport")]
pub use jsonrpsee_client_transport as client_transport;
cfg_ws_client! {
pub use jsonrpsee_ws_client as ws_client;
}
/// JSON-RPC client convenience macro to build params.
#[cfg(any(feature = "async-client", feature = "http-client", feature = "ws-client"))]
pub use jsonrpsee_core::rpc_params;
cfg_wasm_client! {
pub use jsonrpsee_wasm_client as wasm_client;
}
/// JSON-RPC HTTP server.
#[cfg(feature = "jsonrpsee-http-server")]
pub use jsonrpsee_http_server as http_server;
cfg_async_client! {
pub use jsonrpsee_core::client::async_client;
}
/// JSON-RPC WebSocket server.
#[cfg(feature = "jsonrpsee-ws-server")]
pub use jsonrpsee_ws_server as ws_server;
cfg_client_transport! {
pub use jsonrpsee_client_transport as client_transport;
}
/// Procedural macros for JSON-RPC implementations.
#[cfg(feature = "jsonrpsee-proc-macros")]
pub use jsonrpsee_proc_macros as proc_macros;
cfg_http_server! {
pub use jsonrpsee_http_server as http_server;
}
/// Common types used to implement JSON-RPC server and client.
#[cfg(feature = "jsonrpsee-types")]
pub use jsonrpsee_types as types;
cfg_ws_server! {
pub use jsonrpsee_ws_server as ws_server;
}
/// Set of RPC methods that can be mounted to the server.
#[cfg(any(feature = "http-server", feature = "ws-server"))]
pub use jsonrpsee_core::server::rpc_module::{PendingSubscription, RpcModule, SubscriptionSink};
cfg_proc_macros! {
pub use jsonrpsee_proc_macros as proc_macros;
pub use tracing;
}
#[cfg(any(
feature = "http-server",
feature = "ws-server",
feature = "client",
feature = "async-client",
feature = "http-client",
feature = "ws-client"
))]
pub use jsonrpsee_core as core;
cfg_types! {
pub use jsonrpsee_types as types;
}
#[cfg(feature = "http-server")]
pub use http_server::tracing;
cfg_server! {
pub use jsonrpsee_core::server::rpc_module::{PendingSubscription, RpcModule, SubscriptionSink};
}
#[cfg(all(feature = "ws-server", not(feature = "http-server")))]
pub use ws_server::tracing;
cfg_client_or_server! {
pub use jsonrpsee_core as core;
}
cfg_client! {
pub use jsonrpsee_core::rpc_params;
}
#[macro_export]
macro_rules! cfg_feature {
($feature:literal, $($item:item)*) => {
$(
#[cfg(feature = $feature)]
#[cfg_attr(docsrs, doc(cfg(feature = $feature)))]
$item
)*
}
}
macro_rules! cfg_client {
($($item:item)*) => {
$(
#[cfg(any(feature = "jsonrpsee-http-client", feature = "jsonrpsee-ws-client", feature = "client", feature = "async-client"))]
$item
)*
}
}
macro_rules! cfg_http_client {
($($item:item)*) => {
$crate::cfg_feature!("jsonrpsee-http-client", $($item)*);
};
}
macro_rules! cfg_ws_client {
($($item:item)*) => {
$crate::cfg_feature!("jsonrpsee-ws-client", $($item)*);
};
}
macro_rules! cfg_wasm_client {
($($item:item)*) => {
$crate::cfg_feature!("jsonrpsee-wasm-client", $($item)*);
};
}
macro_rules! cfg_async_client {
($($item:item)*) => {
$crate::cfg_feature!("async-client", $($item)*);
};
}
macro_rules! cfg_client_transport {
($($item:item)*) => {
$crate::cfg_feature!("jsonrpsee-client-transport", $($item)*);
};
}
macro_rules! cfg_server {
($($item:item)*) => {
$(
#[cfg(any(feature = "jsonrpsee-http-server", feature = "jsonrpsee-ws-server"))]
$item
)*
}
}
macro_rules! cfg_http_server {
($($item:item)*) => {
$(
#[cfg(feature = "jsonrpsee-http-server")]
#[cfg_attr(docsrs, doc(cfg(feature = "jsonrpsee-http-server")))]
$item
)*
}
}
macro_rules! cfg_ws_server {
($($item:item)*) => {
$crate::cfg_feature!("jsonrpsee-ws-server", $($item)*);
};
}
macro_rules! cfg_proc_macros {
($($item:item)*) => {
$crate::cfg_feature!("jsonrpsee-proc-macros", $($item)*);
};
}
macro_rules! cfg_types {
($($item:item)*) => {
$crate::cfg_feature!("jsonrpsee-types", $($item)*);
};
}
macro_rules! cfg_client_or_server {
($($item:item)*) => {
$(
#[cfg(any(feature = "jsonrpsee-http-client", feature = "jsonrpsee-ws-client", feature = "client", feature = "async-client", feature = "jsonrpsee-ws-server", feature = "jsonrpsee-http-client"))]
$item
)*
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment