Skip to content

Commit

Permalink
Document unbounded_depth, raw_value feature-gated API via doc_cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
jplatte committed Jul 27, 2021
1 parent ea39063 commit e2978b6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
4 changes: 1 addition & 3 deletions src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ impl<'de, R: Read<'de>> Deserializer<R> {
/// 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
///
/// ```
Expand Down Expand Up @@ -196,6 +193,7 @@ impl<'de, R: Read<'de>> Deserializer<R> {
/// }
/// ```
#[cfg(feature = "unbounded_depth")]
#[cfg_attr(docsrs, doc(cfg(feature = "unbounded_depth")))]
pub fn disable_recursion_limit(&mut self) {
self.disable_recursion_limit = true;
}
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]

////////////////////////////////////////////////////////////////////////////////

Expand Down
12 changes: 2 additions & 10 deletions src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
/// ```
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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<T>(value: &T) -> Result<Box<RawValue>, Error>
where
T: Serialize,
Expand Down

0 comments on commit e2978b6

Please sign in to comment.