From 3e1979bf0f439867fd13a65f979eaf4190cf0e75 Mon Sep 17 00:00:00 2001 From: Jane Lusby Date: Sat, 11 Jan 2020 14:19:55 -0800 Subject: [PATCH 1/3] finish doc_cfg for tracing-tower --- tracing-tower/src/lib.rs | 4 ++++ tracing-tower/src/request_span.rs | 8 ++++++++ tracing-tower/src/service_span.rs | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/tracing-tower/src/lib.rs b/tracing-tower/src/lib.rs index 50d7ab651a..e2e22083c3 100644 --- a/tracing-tower/src/lib.rs +++ b/tracing-tower/src/lib.rs @@ -1,3 +1,4 @@ +#![cfg_attr(docsrs, feature(doc_cfg))] #![warn( missing_debug_implementations, // missing_docs, // TODO: add documentation! @@ -29,6 +30,7 @@ pub mod request_span; pub mod service_span; #[cfg(feature = "http")] +#[cfg_attr(docsrs, doc(cfg(feature = "http")))] pub mod http; pub type InstrumentedService = service_span::Service>; @@ -65,6 +67,7 @@ where } #[cfg(feature = "tower-util")] +#[cfg_attr(docsrs, doc(cfg(feature = "tower-util")))] pub trait InstrumentMake where Self: tower_util::MakeService + Sized, @@ -87,6 +90,7 @@ where impl InstrumentableService for S where S: Service + Sized {} #[cfg(feature = "tower-util")] +#[cfg_attr(docsrs, doc(cfg(feature = "tower-util")))] impl InstrumentMake for M where M: tower_util::MakeService {} pub trait GetSpan: crate::sealed::Sealed { diff --git a/tracing-tower/src/request_span.rs b/tracing-tower/src/request_span.rs index e248b535ff..9a04537c60 100644 --- a/tracing-tower/src/request_span.rs +++ b/tracing-tower/src/request_span.rs @@ -18,9 +18,11 @@ where } #[cfg(feature = "tower-layer")] +#[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))] pub use self::layer::*; #[cfg(feature = "tower-layer")] +#[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))] mod layer { use super::*; @@ -70,9 +72,11 @@ mod layer { } #[cfg(feature = "tower-make")] +#[cfg_attr(docsrs, doc(cfg(feature = "tower-make")))] pub use self::make::MakeService; #[cfg(feature = "tower-make")] +#[cfg_attr(docsrs, doc(cfg(feature = "tower-make")))] pub mod make { use super::*; use pin_project::pin_project; @@ -85,6 +89,7 @@ pub mod make { } #[cfg(feature = "tower-layer")] + #[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))] #[derive(Debug)] pub struct MakeLayer tracing::Span> where @@ -104,6 +109,7 @@ pub mod make { } #[cfg(feature = "tower-layer")] + #[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))] pub fn layer(get_span: G) -> MakeLayer where G: GetSpan + Clone, @@ -117,6 +123,7 @@ pub mod make { // === impl MakeLayer === #[cfg(feature = "tower-layer")] + #[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))] impl tower_layer::Layer for MakeLayer where S: tower_make::MakeService, @@ -130,6 +137,7 @@ pub mod make { } #[cfg(feature = "tower-layer")] + #[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))] impl Clone for MakeLayer where G: GetSpan + Clone, diff --git a/tracing-tower/src/service_span.rs b/tracing-tower/src/service_span.rs index 07e3e76ccd..3f80f0967e 100644 --- a/tracing-tower/src/service_span.rs +++ b/tracing-tower/src/service_span.rs @@ -13,12 +13,15 @@ pub struct Service { } #[cfg(feature = "tower-layer")] +#[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))] pub use self::layer::*; #[cfg(feature = "tower-util")] +#[cfg_attr(docsrs, doc(cfg(feature = "tower-util")))] pub use self::make::MakeService; #[cfg(feature = "tower-layer")] +#[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))] mod layer { use super::*; @@ -73,6 +76,7 @@ mod layer { } #[cfg(feature = "tower-layer")] +#[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))] pub mod make { use super::*; use pin_project::pin_project; @@ -105,6 +109,7 @@ pub mod make { } #[cfg(feature = "tower-layer")] + #[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))] pub fn layer(get_span: G) -> MakeLayer where G: GetSpan + Clone, @@ -118,6 +123,7 @@ pub mod make { // === impl MakeLayer === #[cfg(feature = "tower-layer")] + #[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))] impl tower_layer::Layer for MakeLayer where M: tower_make::MakeService, @@ -131,6 +137,7 @@ pub mod make { } #[cfg(feature = "tower-layer")] + #[cfg_attr(docsrs, doc(cfg(feature = "tower-layer")))] impl Clone for MakeLayer where G: GetSpan + Clone, From 3b75c20a58bb4c710b66b93830b86337bca4fc35 Mon Sep 17 00:00:00 2001 From: Jane Lusby Date: Sat, 11 Jan 2020 14:26:05 -0800 Subject: [PATCH 2/3] finish doc_cfg for tracing-log --- tracing-log/src/lib.rs | 6 ++++++ tracing-log/src/log_tracer.rs | 3 +++ 2 files changed, 9 insertions(+) diff --git a/tracing-log/src/lib.rs b/tracing-log/src/lib.rs index 77071e84cd..49d58cf5be 100644 --- a/tracing-log/src/lib.rs +++ b/tracing-log/src/lib.rs @@ -87,6 +87,7 @@ //! [`Subscriber`]: https://docs.rs/tracing/latest/tracing/trait.Subscriber.html //! [`tracing::Event`]: https://docs.rs/tracing/latest/tracing/struct.Event.html #![doc(html_root_url = "https://docs.rs/tracing-log/0.1.1")] +#![cfg_attr(docsrs, feature(doc_cfg))] #![warn( missing_debug_implementations, missing_docs, @@ -123,16 +124,20 @@ use tracing_core::{ }; #[cfg(feature = "log-tracer")] +#[cfg_attr(docsrs, doc(cfg(feature = "log-tracer")))] pub mod log_tracer; #[cfg(feature = "trace-logger")] +#[cfg_attr(docsrs, doc(cfg(feature = "trace-logger")))] pub mod trace_logger; #[cfg(feature = "log-tracer")] +#[cfg_attr(docsrs, doc(cfg(feature = "log-tracer")))] #[doc(inline)] pub use self::log_tracer::LogTracer; #[cfg(feature = "trace-logger")] +#[cfg_attr(docsrs, doc(cfg(feature = "trace-logger")))] #[deprecated( since = "0.1.1", note = "use the `tracing` crate's \"log\" feature flag instead" @@ -142,6 +147,7 @@ pub use self::log_tracer::LogTracer; pub use self::trace_logger::TraceLogger; #[cfg(feature = "env_logger")] +#[cfg_attr(docsrs, doc(cfg(feature = "env_logger")))] pub mod env_logger; /// Format a log record as a trace event in the current span. diff --git a/tracing-log/src/log_tracer.rs b/tracing-log/src/log_tracer.rs index 71dfc864a2..3dfa0d1b59 100644 --- a/tracing-log/src/log_tracer.rs +++ b/tracing-log/src/log_tracer.rs @@ -112,6 +112,7 @@ impl LogTracer { /// /// [`builder`]: #method.builder #[cfg(feature = "std")] + #[cfg_attr(docsrs, doc(cfg(feature = "std")))] pub fn init_with_filter(level: log::LevelFilter) -> Result<(), SetLoggerError> { Self::builder().with_max_level(level).init() } @@ -146,6 +147,7 @@ impl LogTracer { /// [`init_with_filter`]: #method.init_with_filter /// [`builder`]: #method.builder #[cfg(feature = "std")] + #[cfg_attr(docsrs, doc(cfg(feature = "std")))] pub fn init() -> Result<(), SetLoggerError> { Self::builder().init() } @@ -241,6 +243,7 @@ impl Builder { /// /// Setting a global logger can only be done once. #[cfg(feature = "std")] + #[cfg_attr(docsrs, doc(cfg(feature = "std")))] pub fn init(self) -> Result<(), SetLoggerError> { let ignore_crates = self.ignore_crates.into_boxed_slice(); let logger = Box::new(LogTracer { ignore_crates }); From 80385c275a6d0c930b19e7d1bd196ffe44323c63 Mon Sep 17 00:00:00 2001 From: Jane Lusby Date: Mon, 13 Jan 2020 10:54:17 -0800 Subject: [PATCH 3/3] Add cargo metadata to tower and log --- tracing-log/Cargo.toml | 4 ++++ tracing-tower/Cargo.toml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/tracing-log/Cargo.toml b/tracing-log/Cargo.toml index dd4113ade7..3e1e0f97d6 100644 --- a/tracing-log/Cargo.toml +++ b/tracing-log/Cargo.toml @@ -34,3 +34,7 @@ tracing = "0.1" [badges] azure-devops = { project = "tracing/tracing", pipeline = "tokio-rs.tracing", build = "1" } maintenance = { status = "actively-maintained" } + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] diff --git a/tracing-tower/Cargo.toml b/tracing-tower/Cargo.toml index 71c38f2e47..78ed6b16a0 100644 --- a/tracing-tower/Cargo.toml +++ b/tracing-tower/Cargo.toml @@ -36,3 +36,7 @@ http = { version = "0.1", optional = true } [badges] azure-devops = { project = "tracing/tracing", pipeline = "tokio-rs.tracing", build = "1" } maintenance = { status = "experimental" } + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"]