diff --git a/src/format/mod.rs b/src/format/mod.rs index c3db7ade..af7eb4cf 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -16,7 +16,8 @@ //! C's `strftime` format. The available options can be found [here](./strftime/index.html). //! //! # Example -//! ```rust +#![cfg_attr(not(feature = "std"), doc = "```ignore")] +#![cfg_attr(feature = "std", doc = "```rust")] //! # use std::error::Error; //! use chrono::prelude::*; //! diff --git a/src/lib.rs b/src/lib.rs index acd4f4a0..8472a6fc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -110,7 +110,8 @@ //! or in the local time zone //! ([`Local::now()`](./offset/struct.Local.html#method.now)). //! -//! ```rust +#![cfg_attr(not(feature = "clock"), doc = "```ignore")] +#![cfg_attr(feature = "clock", doc = "```rust")] //! use chrono::prelude::*; //! //! let utc: DateTime = Utc::now(); // e.g. `2014-11-28T12:45:59.324310806Z` @@ -122,7 +123,8 @@ //! This is a bit verbose due to Rust's lack of function and method overloading, //! but in turn we get a rich combination of initialization methods. //! -//! ```rust +#![cfg_attr(not(feature = "std"), doc = "```ignore")] +#![cfg_attr(feature = "std", doc = "```rust")] //! use chrono::prelude::*; //! use chrono::offset::LocalResult; //! @@ -314,7 +316,8 @@ //! [`DateTime.timestamp_subsec_nanos`](./struct.DateTime.html#method.timestamp_subsec_nanos) //! to get the number of additional number of nanoseconds. //! -//! ```rust +#![cfg_attr(not(feature = "std"), doc = "```ignore")] +#![cfg_attr(feature = "std", doc = "```rust")] //! // We need the trait in scope to use Utc::timestamp(). //! use chrono::{DateTime, TimeZone, Utc}; //! @@ -333,7 +336,8 @@ //! It also has time zones attached, and have to be constructed via time zones. //! Most operations available to `DateTime` are also available to `Date` whenever appropriate. //! -//! ```rust +#![cfg_attr(not(feature = "std"), doc = "```ignore")] +#![cfg_attr(feature = "std", doc = "```rust")] //! use chrono::prelude::*; //! use chrono::offset::LocalResult; //! diff --git a/src/naive/time/mod.rs b/src/naive/time/mod.rs index 14e22fe6..444c8dc1 100644 --- a/src/naive/time/mod.rs +++ b/src/naive/time/mod.rs @@ -818,7 +818,8 @@ impl Timelike for NaiveTime { /// ([Why?](#leap-second-handling)) /// Use the proper [formatting method](#method.format) to get a human-readable representation. /// - /// ``` + #[cfg_attr(not(feature = "std"), doc = "```ignore")] + #[cfg_attr(feature = "std", doc = "```")] /// # use chrono::{NaiveTime, Timelike}; /// let leap = NaiveTime::from_hms_milli_opt(23, 59, 59, 1_000).unwrap(); /// assert_eq!(leap.second(), 59); @@ -846,7 +847,8 @@ impl Timelike for NaiveTime { /// You can reduce the range with `time.nanosecond() % 1_000_000_000`, or /// use the proper [formatting method](#method.format) to get a human-readable representation. /// - /// ``` + #[cfg_attr(not(feature = "std"), doc = "```ignore")] + #[cfg_attr(feature = "std", doc = "```")] /// # use chrono::{NaiveTime, Timelike}; /// let leap = NaiveTime::from_hms_milli_opt(23, 59, 59, 1_000).unwrap(); /// assert_eq!(leap.nanosecond(), 1_000_000_000); diff --git a/src/offset/fixed.rs b/src/offset/fixed.rs index 04ffa3b9..02691da7 100644 --- a/src/offset/fixed.rs +++ b/src/offset/fixed.rs @@ -46,7 +46,8 @@ impl FixedOffset { /// /// # Example /// - /// ``` + #[cfg_attr(not(feature = "std"), doc = "```ignore")] + #[cfg_attr(feature = "std", doc = "```")] /// use chrono::{FixedOffset, TimeZone}; /// let hour = 3600; /// let datetime = FixedOffset::east_opt(5 * hour).unwrap().ymd_opt(2016, 11, 08).unwrap() @@ -79,7 +80,8 @@ impl FixedOffset { /// /// # Example /// - /// ``` + #[cfg_attr(not(feature = "std"), doc = "```ignore")] + #[cfg_attr(feature = "std", doc = "```")] /// use chrono::{FixedOffset, TimeZone}; /// let hour = 3600; /// let datetime = FixedOffset::west_opt(5 * hour).unwrap().ymd_opt(2016, 11, 08).unwrap()