From c30bb388f99c81df3229554e7688b48688c2962a Mon Sep 17 00:00:00 2001 From: chyyran Date: Thu, 9 Jun 2022 13:29:44 -0400 Subject: [PATCH] doc: Show feature badges on docs.rs --- Cargo.toml | 1 + src/decode/stream.rs | 1 + src/lib.rs | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 04cd32a..63f2566 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,3 +27,4 @@ raw_decoder = [] [package.metadata.docs.rs] features = ["stream", "raw_decoder"] +rustdoc-args = ["--cfg", "docsrs"] diff --git a/src/decode/stream.rs b/src/decode/stream.rs index 43fca4f..15a2c30 100644 --- a/src/decode/stream.rs +++ b/src/decode/stream.rs @@ -61,6 +61,7 @@ where /// Lzma decompressor that can process multiple chunks of data using the /// `io::Write` interface. +#[cfg_attr(docsrs, doc(cfg(stream)))] pub struct Stream where W: Write, diff --git a/src/lib.rs b/src/lib.rs index 479e1c7..7bd7730 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ //! Pure-Rust codecs for LZMA, LZMA2, and XZ. - +#![cfg_attr(docsrs, feature(doc_cfg, doc_cfg_hide))] #![deny(missing_docs)] #![deny(missing_debug_implementations)] #![forbid(unsafe_code)] @@ -24,13 +24,17 @@ pub mod compress { /// Decompression helpers. pub mod decompress { pub use crate::decode::options::*; + #[cfg(feature = "raw_decoder")] + #[cfg_attr(docsrs, doc(cfg(raw_decoder)))] pub mod raw { //! Raw decoding primitives for LZMA/LZMA2 streams. pub use crate::decode::lzma::{LzmaDecoder, LzmaParams, LzmaProperties}; pub use crate::decode::lzma2::Lzma2Decoder; } + #[cfg(feature = "stream")] + #[cfg_attr(docsrs, doc(cfg(stream)))] pub use crate::decode::stream::Stream; }