diff --git a/.github/assets/tonic-docs.png b/.github/assets/tonic-docs.png new file mode 100644 index 0000000..ee20039 Binary files /dev/null and b/.github/assets/tonic-docs.png differ diff --git a/tonic-build/Cargo.toml b/tonic-build/Cargo.toml index 7c70f44..805f295 100644 --- a/tonic-build/Cargo.toml +++ b/tonic-build/Cargo.toml @@ -14,3 +14,6 @@ proc-macro2 = "1.0" default = ["transport", "rustfmt"] rustfmt = [] transport = [] + +[package.metadata.docs.rs] +all-features = true diff --git a/tonic/Cargo.toml b/tonic/Cargo.toml index 299ec42..9ac49a6 100644 --- a/tonic/Cargo.toml +++ b/tonic/Cargo.toml @@ -74,3 +74,7 @@ openssl1 = { package = "openssl", version = "0.10", optional = true } # rustls tokio-rustls = { version = "=0.12.0-alpha.4", optional = true } + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] diff --git a/tonic/src/lib.rs b/tonic/src/lib.rs index d5a350b..dd45ef0 100644 --- a/tonic/src/lib.rs +++ b/tonic/src/lib.rs @@ -1,16 +1,3 @@ -#![recursion_limit = "256"] -#![warn( - missing_debug_implementations, - missing_docs, - rust_2018_idioms, - unreachable_pub -)] -#![doc( - html_logo_url = "https://github.com/LucioFranco/tonic/raw/master/.github/assets/tonic-docs.svg?sanitize=true" -)] -#![doc(html_root_url = "https://docs.rs/tonic/0.1.0-alpha.1")] -#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))] - //! A Rust implementation of [gRPC], a high performance, open source, general //! RPC framework that puts mobile and HTTP/2 first. //! @@ -60,6 +47,9 @@ //! //! [gRPC]: https://grpc.io //! [`tonic`]: https://github.com/hyperium/tonic +//! [`tokio`]: https://docs.rs/tokio +//! [`hyper`]: https://docs.rs/hyper +//! [`tower`]: https://docs.rs/tower //! [`tonic-build`]: https://docs.rs/tonic-build //! [`tonic-examples`]: https://github.com/hyperium/tonic/tree/master/tonic-examples/src //! [`Codec`]: codec/trait.Codec.html @@ -68,6 +58,21 @@ //! [`rustls`]: https://docs.rs/rustls //! [`openssl`]: https://www.openssl.org +#![recursion_limit = "256"] +#![warn( + missing_debug_implementations, + missing_docs, + rust_2018_idioms, + unreachable_pub +)] +#![doc( + html_logo_url = "https://github.com/LucioFranco/tonic/raw/master/.github/assets/tonic-docs.svg?sanitize=true" +)] +#![doc(html_root_url = "https://docs.rs/tonic/0.1.0-alpha.1")] +#![doc(issue_tracker_base_url = "https://github.com/hyperium/tonic/issues/")] +#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))] +#![cfg_attr(docsrs, feature(doc_cfg))] + pub mod body; pub mod client; pub mod codec; @@ -75,6 +80,7 @@ pub mod metadata; pub mod server; #[cfg(feature = "transport")] +#[cfg_attr(docsrs, doc(cfg(feature = "transport")))] pub mod transport; mod macros; @@ -84,6 +90,7 @@ mod status; /// A re-export of [`async-trait`](https://docs.rs/async-trait) for use with codegen. #[cfg(feature = "codegen")] +#[cfg_attr(docsrs, doc(cfg(feature = "codegen")))] pub use async_trait::async_trait; #[doc(inline)] @@ -96,4 +103,5 @@ pub(crate) type Error = Box; #[doc(hidden)] #[cfg(feature = "codegen")] +#[cfg_attr(docsrs, doc(cfg(feature = "codegen")))] pub mod codegen; diff --git a/tonic/src/transport/endpoint.rs b/tonic/src/transport/endpoint.rs index fda3241..abd0e1e 100644 --- a/tonic/src/transport/endpoint.rs +++ b/tonic/src/transport/endpoint.rs @@ -101,6 +101,12 @@ impl Endpoint { self } + /// Enable TLS and apply the CA as the root certificate. + /// + /// Providing an optional domain to override. If `None` is passed to this + /// the TLS implementation will use the `Uri` that was used to create the + /// `Endpoint` builder. + /// /// ```no_run /// # use tonic::transport::{Certificate, Endpoint}; /// # fn dothing() -> Result<(), Box> { @@ -114,6 +120,7 @@ impl Endpoint { /// # } /// ``` #[cfg(feature = "openssl")] + #[cfg_attr(docsrs, doc(cfg(feature = "openssl")))] pub fn openssl_tls(&mut self, ca: Certificate, domain: impl Into>) -> &mut Self { let domain = domain .into() @@ -123,6 +130,12 @@ impl Endpoint { self } + /// Enable TLS and apply the CA as the root certificate. + /// + /// Providing an optional domain to override. If `None` is passed to this + /// the TLS implementation will use the `Uri` that was used to create the + /// `Endpoint` builder. + /// /// ```no_run /// # use tonic::transport::{Certificate, Endpoint}; /// # fn dothing() -> Result<(), Box> { @@ -136,6 +149,7 @@ impl Endpoint { /// # } /// ``` #[cfg(feature = "rustls")] + #[cfg_attr(docsrs, doc(cfg(feature = "rustls")))] pub fn rustls_tls(&mut self, ca: Certificate, domain: impl Into>) -> &mut Self { let domain = domain .into() diff --git a/tonic/src/transport/server.rs b/tonic/src/transport/server.rs index 41c6780..b746631 100644 --- a/tonic/src/transport/server.rs +++ b/tonic/src/transport/server.rs @@ -73,6 +73,7 @@ impl Server { /// # } /// ``` #[cfg(feature = "openssl")] + #[cfg_attr(docsrs, doc(cfg(feature = "openssl")))] pub fn openssl_tls(&mut self, identity: Identity) -> &mut Self { let acceptor = TlsAcceptor::new_with_openssl(identity).unwrap(); self.tls = Some(acceptor); @@ -95,6 +96,7 @@ impl Server { /// # } /// ``` #[cfg(feature = "rustls")] + #[cfg_attr(docsrs, doc(cfg(feature = "rustls")))] pub fn rustls_tls(&mut self, identity: Identity) -> &mut Self { let acceptor = TlsAcceptor::new_with_rustls(identity).unwrap(); self.tls = Some(acceptor);