Skip to content

Commit

Permalink
Merge pull request 788 from jplatte/doc-cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jul 28, 2021
2 parents ea39063 + 6f15a0e commit f205576
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ jobs:
- uses: dtolnay/rust-toolchain@clippy
- run: cargo clippy

docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@nightly
- run: cargo doc --features raw_value,unbounded_depth
env:
RUSTDOCFLAGS: --cfg docsrs

fuzz:
name: Fuzz
runs-on: ubuntu-latest
Expand Down
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
2 changes: 2 additions & 0 deletions src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,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 Expand Up @@ -2494,6 +2495,7 @@ where
/// the JSON map or some number is too big to fit in the expected primitive
/// type.
#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub fn from_reader<R, T>(rdr: R) -> Result<T>
where
R: crate::io::Read,
Expand Down
2 changes: 2 additions & 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 Expand Up @@ -453,6 +454,7 @@ pub mod de;
pub mod error;
pub mod map;
#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub mod ser;
#[cfg(not(feature = "std"))]
mod ser;
Expand Down
2 changes: 2 additions & 0 deletions src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,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 +268,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
1 change: 1 addition & 0 deletions src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ where

/// JSON input source that reads from a std::io input stream.
#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub struct IoRead<R>
where
R: io::Read,
Expand Down
3 changes: 3 additions & 0 deletions src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use serde::ser::{self, Impossible, Serialize};
use serde::serde_if_integer128;

/// A structure for serializing Rust values into JSON.
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub struct Serializer<W, F = CompactFormatter> {
writer: W,
formatter: F,
Expand Down Expand Up @@ -2141,6 +2142,7 @@ static ESCAPE: [u8; 256] = [
/// Serialization can fail if `T`'s implementation of `Serialize` decides to
/// fail, or if `T` contains a map with non-string keys.
#[inline]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub fn to_writer<W, T>(writer: W, value: &T) -> Result<()>
where
W: io::Write,
Expand All @@ -2159,6 +2161,7 @@ where
/// Serialization can fail if `T`'s implementation of `Serialize` decides to
/// fail, or if `T` contains a map with non-string keys.
#[inline]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub fn to_writer_pretty<W, T>(writer: W, value: &T) -> Result<()>
where
W: io::Write,
Expand Down

0 comments on commit f205576

Please sign in to comment.