Skip to content

Commit e2978b6

Browse files
committed
Document unbounded_depth, raw_value feature-gated API via doc_cfg
1 parent ea39063 commit e2978b6

File tree

4 files changed

+5
-13
lines changed

4 files changed

+5
-13
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ members = ["tests/crate"]
3232
[package.metadata.docs.rs]
3333
features = ["raw_value", "unbounded_depth"]
3434
targets = ["x86_64-unknown-linux-gnu"]
35+
rustdoc-args = ["--cfg", "docsrs"]
3536

3637
[package.metadata.playground]
3738
features = ["raw_value"]

src/de.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,6 @@ impl<'de, R: Read<'de>> Deserializer<R> {
163163
/// completed, including, but not limited to, Display and Debug and Drop
164164
/// impls.
165165
///
166-
/// *This method is only available if serde_json is built with the
167-
/// `"unbounded_depth"` feature.*
168-
///
169166
/// # Examples
170167
///
171168
/// ```
@@ -196,6 +193,7 @@ impl<'de, R: Read<'de>> Deserializer<R> {
196193
/// }
197194
/// ```
198195
#[cfg(feature = "unbounded_depth")]
196+
#[cfg_attr(docsrs, doc(cfg(feature = "unbounded_depth")))]
199197
pub fn disable_recursion_limit(&mut self) {
200198
self.disable_recursion_limit = true;
201199
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@
357357
#![allow(non_upper_case_globals)]
358358
#![deny(missing_docs)]
359359
#![cfg_attr(not(feature = "std"), no_std)]
360+
#![cfg_attr(docsrs, feature(doc_cfg))]
360361

361362
////////////////////////////////////////////////////////////////////////////////
362363

src/raw.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@ use serde::ser::{Serialize, SerializeStruct, Serializer};
1818
/// When serializing, a value of this type will retain its original formatting
1919
/// and will not be minified or pretty-printed.
2020
///
21-
/// # Note
22-
///
23-
/// `RawValue` is only available if serde\_json is built with the `"raw_value"`
24-
/// feature.
25-
///
26-
/// ```toml
27-
/// [dependencies]
28-
/// serde_json = { version = "1.0", features = ["raw_value"] }
29-
/// ```
30-
///
3121
/// # Example
3222
///
3323
/// ```
@@ -109,6 +99,7 @@ use serde::ser::{Serialize, SerializeStruct, Serializer};
10999
/// }
110100
/// ```
111101
#[repr(C)]
102+
#[cfg_attr(docsrs, doc(cfg(feature = "raw_value")))]
112103
pub struct RawValue {
113104
json: str,
114105
}
@@ -267,6 +258,7 @@ impl RawValue {
267258
///
268259
/// println!("{}", serde_json::value::to_raw_value(&map).unwrap_err());
269260
/// ```
261+
#[cfg_attr(docsrs, doc(cfg(feature = "raw_value")))]
270262
pub fn to_raw_value<T>(value: &T) -> Result<Box<RawValue>, Error>
271263
where
272264
T: Serialize,

0 commit comments

Comments
 (0)