diff --git a/Cargo.toml b/Cargo.toml index 6ecb159f4..f2a6d3f44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ members = ["tests/crate"] [package.metadata.docs.rs] features = ["raw_value", "unbounded_depth"] targets = ["x86_64-unknown-linux-gnu"] +rustdoc-args = ["--cfg", "docsrs"] [package.metadata.playground] features = ["raw_value"] diff --git a/src/de.rs b/src/de.rs index 15c8236b6..2041f537c 100644 --- a/src/de.rs +++ b/src/de.rs @@ -163,9 +163,6 @@ impl<'de, R: Read<'de>> Deserializer { /// completed, including, but not limited to, Display and Debug and Drop /// impls. /// - /// *This method is only available if serde_json is built with the - /// `"unbounded_depth"` feature.* - /// /// # Examples /// /// ``` @@ -196,6 +193,7 @@ impl<'de, R: Read<'de>> Deserializer { /// } /// ``` #[cfg(feature = "unbounded_depth")] + #[cfg_attr(docsrs, doc(cfg(feature = "unbounded_depth")))] pub fn disable_recursion_limit(&mut self) { self.disable_recursion_limit = true; } diff --git a/src/lib.rs b/src/lib.rs index 33665ddd5..737ad833e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -357,6 +357,7 @@ #![allow(non_upper_case_globals)] #![deny(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] +#![cfg_attr(docsrs, feature(doc_cfg))] //////////////////////////////////////////////////////////////////////////////// diff --git a/src/raw.rs b/src/raw.rs index c373b4ded..114de1ba6 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -18,16 +18,6 @@ use serde::ser::{Serialize, SerializeStruct, Serializer}; /// When serializing, a value of this type will retain its original formatting /// and will not be minified or pretty-printed. /// -/// # Note -/// -/// `RawValue` is only available if serde\_json is built with the `"raw_value"` -/// feature. -/// -/// ```toml -/// [dependencies] -/// serde_json = { version = "1.0", features = ["raw_value"] } -/// ``` -/// /// # Example /// /// ``` @@ -109,6 +99,7 @@ use serde::ser::{Serialize, SerializeStruct, Serializer}; /// } /// ``` #[repr(C)] +#[cfg_attr(docsrs, doc(cfg(feature = "raw_value")))] pub struct RawValue { json: str, } @@ -267,6 +258,7 @@ impl RawValue { /// /// println!("{}", serde_json::value::to_raw_value(&map).unwrap_err()); /// ``` +#[cfg_attr(docsrs, doc(cfg(feature = "raw_value")))] pub fn to_raw_value(value: &T) -> Result, Error> where T: Serialize,