From 3e62d7d411d0609802c34697faeb09d9ce3aacd1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 24 Mar 2024 12:22:08 +0100 Subject: [PATCH] introduce doc_auto_cfg --- Cargo.toml | 2 +- release-checklist.md | 2 +- src/cfdp/lv.rs | 1 - src/ecss/tc.rs | 2 -- src/ecss/tm.rs | 2 -- src/lib.rs | 2 +- src/time/ascii.rs | 4 ---- src/time/cds.rs | 11 ----------- src/time/cuc.rs | 3 --- src/time/mod.rs | 13 +------------ src/util.rs | 1 - 11 files changed, 4 insertions(+), 39 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c0d6a8d..c82507f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,4 +62,4 @@ timelib = ["dep:time"] [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "doc_cfg", "--generate-link-to-definition"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] diff --git a/release-checklist.md b/release-checklist.md index 0add16b..57791e3 100644 --- a/release-checklist.md +++ b/release-checklist.md @@ -4,7 +4,7 @@ Checklist for new releases # Pre-Release 1. Make sure any new modules are documented sufficiently enough and check docs with - `cargo +nightly doc --all-features --config 'rustdocflags=["--cfg", "doc_cfg"]' --open`. + `cargo +nightly doc --all-features --config 'build.rustdocflags=["--cfg", "docsrs"]' --open`. 2. Bump version specifier in `Cargo.toml`. 3. Update `CHANGELOG.md`: Convert `unreleased` section into version section with date and add new `unreleased` section. diff --git a/src/cfdp/lv.rs b/src/cfdp/lv.rs index e84e7a4..87d386c 100644 --- a/src/cfdp/lv.rs +++ b/src/cfdp/lv.rs @@ -88,7 +88,6 @@ impl<'data> Lv<'data> { /// Helper function to build a string LV. This is especially useful for the file or directory /// path LVs #[cfg(feature = "std")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] pub fn new_from_string(string: &'data String) -> Result, TlvLvError> { Self::new(string.as_bytes()) } diff --git a/src/ecss/tc.rs b/src/ecss/tc.rs index d923162..0590166 100644 --- a/src/ecss/tc.rs +++ b/src/ecss/tc.rs @@ -374,7 +374,6 @@ pub mod legacy_tc { } #[cfg(feature = "alloc")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] pub fn append_to_vec(&self, vec: &mut Vec) -> Result { let sph_zc = crate::zc::SpHeader::from(self.sp_header); let appended_len = PUS_TC_MIN_LEN_WITHOUT_APP_DATA + self.app_data.len(); @@ -654,7 +653,6 @@ impl<'raw_data> PusTcCreator<'raw_data> { } #[cfg(feature = "alloc")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] pub fn append_to_vec(&self, vec: &mut Vec) -> Result { let sph_zc = crate::zc::SpHeader::from(self.sp_header); let mut appended_len = PUS_TC_MIN_LEN_WITHOUT_APP_DATA; diff --git a/src/ecss/tm.rs b/src/ecss/tm.rs index 837a6dc..5b547a3 100644 --- a/src/ecss/tm.rs +++ b/src/ecss/tm.rs @@ -341,7 +341,6 @@ pub mod legacy_tm { /// Append the raw PUS byte representation to a provided [alloc::vec::Vec] #[cfg(feature = "alloc")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] pub fn append_to_vec(&self, vec: &mut Vec) -> Result { let sph_zc = crate::zc::SpHeader::from(self.sp_header); let mut appended_len = PUS_TM_MIN_LEN_WITHOUT_SOURCE_DATA; @@ -662,7 +661,6 @@ impl<'raw_data> PusTmCreator<'raw_data> { /// Append the raw PUS byte representation to a provided [alloc::vec::Vec] #[cfg(feature = "alloc")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] pub fn append_to_vec(&self, vec: &mut Vec) -> Result { let sph_zc = crate::zc::SpHeader::from(self.sp_header); let mut appended_len = PUS_TM_MIN_LEN_WITHOUT_SOURCE_DATA + self.sec_header.timestamp.len(); diff --git a/src/lib.rs b/src/lib.rs index 9e1ec17..46d39f5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -55,7 +55,7 @@ //! println!("{:x?}", &ccsds_buf[0..6]); //! ``` #![no_std] -#![cfg_attr(doc_cfg, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] #[cfg(feature = "alloc")] extern crate alloc; #[cfg(any(feature = "std", test))] diff --git a/src/time/ascii.rs b/src/time/ascii.rs index c749c49..a123362 100644 --- a/src/time/ascii.rs +++ b/src/time/ascii.rs @@ -40,13 +40,11 @@ pub mod alloc_mod_chrono { }; /// Generates a time code formatter using the [FMT_STR_CODE_A_WITH_SIZE] format. - #[cfg_attr(doc_cfg, doc(cfg(all(feature = "alloc", feature = "chrono"))))] pub fn generate_time_code_a(date: &DateTime) -> DelayedFormat> { date.format(FMT_STR_CODE_A_WITH_SIZE.0) } /// Generates a time code formatter using the [FMT_STR_CODE_A_TERMINATED_WITH_SIZE] format. - #[cfg_attr(doc_cfg, doc(cfg(all(feature = "alloc", feature = "chrono"))))] pub fn generate_time_code_a_terminated( date: &DateTime, ) -> DelayedFormat> { @@ -54,13 +52,11 @@ pub mod alloc_mod_chrono { } /// Generates a time code formatter using the [FMT_STR_CODE_B_WITH_SIZE] format. - #[cfg_attr(doc_cfg, doc(cfg(all(feature = "alloc", feature = "chrono"))))] pub fn generate_time_code_b(date: &DateTime) -> DelayedFormat> { date.format(FMT_STR_CODE_B_WITH_SIZE.0) } /// Generates a time code formatter using the [FMT_STR_CODE_B_TERMINATED_WITH_SIZE] format. - #[cfg_attr(doc_cfg, doc(cfg(all(feature = "alloc", feature = "chrono"))))] pub fn generate_time_code_b_terminated( date: &DateTime, ) -> DelayedFormat> { diff --git a/src/time/cds.rs b/src/time/cds.rs index 120d27a..1f3e5a7 100644 --- a/src/time/cds.rs +++ b/src/time/cds.rs @@ -434,13 +434,10 @@ impl CdsConverter for ConversionFromNow { } #[cfg(feature = "alloc")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] pub trait DynCdsTimeProvider: CcsdsTimeProvider + CdsTimestamp + TimeWriter + Any {} #[cfg(feature = "alloc")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] impl DynCdsTimeProvider for CdsTime {} #[cfg(feature = "alloc")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] impl DynCdsTimeProvider for CdsTime {} /// This function returns the correct [CdsTime] instance from a raw byte array @@ -470,7 +467,6 @@ impl DynCdsTimeProvider for CdsTime {} /// } /// ``` #[cfg(feature = "alloc")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] pub fn get_dyn_time_provider_from_bytes( buf: &[u8], ) -> Result, TimestampError> { @@ -776,7 +772,6 @@ impl CdsTime { } #[cfg(feature = "std")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] pub fn update_from_now(&mut self) -> Result<(), StdTimestampError> { let conversion_from_now = self.generic_conversion_from_now()?; let ccsds_days: ProvidesDaysLen::FieldType = conversion_from_now @@ -812,7 +807,6 @@ impl CdsTime { /// Generate a time stamp from the current time using the system clock. #[cfg(feature = "std")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] pub fn from_now_with_u24_days() -> Result { Self::from_now_generic(LengthOfDaySegment::Long24Bits) } @@ -863,14 +857,12 @@ impl CdsTime { /// Like [Self::from_now_with_u24_days] but with microsecond sub-millisecond precision. #[cfg(feature = "std")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] pub fn from_now_with_u24_days_us_precision() -> Result { Self::from_now_generic_us_prec(LengthOfDaySegment::Long24Bits) } /// Like [Self::from_now_with_u24_days] but with picoseconds sub-millisecond precision. #[cfg(feature = "std")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] pub fn from_now_with_u24_days_ps_precision() -> Result { Self::from_now_generic_us_prec(LengthOfDaySegment::Long24Bits) } @@ -923,7 +915,6 @@ impl CdsTime { /// Generate a time stamp from the current time using the system clock. #[cfg(feature = "std")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] pub fn from_now_with_u16_days() -> Result { Self::from_now_generic(LengthOfDaySegment::Short16Bits) } @@ -960,14 +951,12 @@ impl CdsTime { /// Like [Self::from_now_with_u16_days] but with microsecond sub-millisecond precision. #[cfg(feature = "std")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] pub fn from_now_with_u16_days_us_precision() -> Result { Self::from_now_generic_us_prec(LengthOfDaySegment::Short16Bits) } /// Like [Self::from_now_with_u16_days] but with picosecond sub-millisecond precision. #[cfg(feature = "std")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] pub fn from_now_with_u16_days_ps_precision() -> Result { Self::from_now_generic_ps_prec(LengthOfDaySegment::Short16Bits) } diff --git a/src/time/cuc.rs b/src/time/cuc.rs index 856dfad..77b4384 100644 --- a/src/time/cuc.rs +++ b/src/time/cuc.rs @@ -341,7 +341,6 @@ impl CucTime { /// must be applied on top of the UTC based time retrieved from the system in addition to the /// conversion to the CCSDS epoch. #[cfg(feature = "std")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] pub fn from_now( fraction_resolution: FractionalResolution, leap_seconds: u32, @@ -373,7 +372,6 @@ impl CucTime { /// must be applied on top of the UTC based time retrieved from the system in addition to the /// conversion to the CCSDS epoch. #[cfg(feature = "std")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] pub fn update_from_now(&mut self, leap_seconds: u32) -> Result<(), StdTimestampError> { let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH)?; self.counter.1 = unix_epoch_to_ccsds_epoch(now.as_secs() as i64) as u32; @@ -393,7 +391,6 @@ impl CucTime { } #[cfg(feature = "chrono")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "chrono")))] pub fn from_chrono_date_time( dt: &chrono::DateTime, res: FractionalResolution, diff --git a/src/time/mod.rs b/src/time/mod.rs index 96f6094..297bcb6 100644 --- a/src/time/mod.rs +++ b/src/time/mod.rs @@ -127,7 +127,6 @@ impl From for TimestampError { } #[cfg(feature = "std")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] pub mod std_mod { use crate::time::TimestampError; use std::time::SystemTimeError; @@ -135,7 +134,7 @@ pub mod std_mod { #[derive(Debug, Clone, Error)] pub enum StdTimestampError { - #[error("system time error: {0}")] + #[error("system time error: {0:?}")] SystemTime(#[from] SystemTimeError), #[error("timestamp error: {0}")] Timestamp(#[from] TimestampError), @@ -143,7 +142,6 @@ pub mod std_mod { } #[cfg(feature = "std")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] pub fn seconds_since_epoch() -> f64 { SystemTime::now() .duration_since(SystemTime::UNIX_EPOCH) @@ -178,7 +176,6 @@ pub const fn ccsds_epoch_to_unix_epoch(ccsds_epoch: i64) -> i64 { } #[cfg(feature = "std")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] pub fn ms_of_day_using_sysclock() -> u32 { ms_of_day(seconds_since_epoch()) } @@ -199,7 +196,6 @@ pub trait TimeWriter { fn write_to_bytes(&self, bytes: &mut [u8]) -> Result; #[cfg(feature = "alloc")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] fn to_vec(&self) -> Result, TimestampError> { let mut vec = alloc::vec![0; self.len_written()]; self.write_to_bytes(&mut vec)?; @@ -238,13 +234,11 @@ pub trait CcsdsTimeProvider { } #[cfg(feature = "chrono")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "chrono")))] fn chrono_date_time(&self) -> chrono::LocalResult> { chrono::Utc.timestamp_opt(self.unix_secs(), self.subsec_nanos()) } #[cfg(feature = "timelib")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "timelib")))] fn timelib_date_time(&self) -> Result { Ok(time::OffsetDateTime::from_unix_timestamp(self.unix_secs())? + time::Duration::nanoseconds(self.subsec_nanos().into())) @@ -341,7 +335,6 @@ impl UnixTime { } #[cfg(feature = "std")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] pub fn from_now() -> Result { let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH)?; let epoch = now.as_secs(); @@ -358,13 +351,11 @@ impl UnixTime { } #[cfg(feature = "chrono")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "chrono")))] pub fn chrono_date_time(&self) -> chrono::LocalResult> { Utc.timestamp_opt(self.secs, self.subsec_nanos) } #[cfg(feature = "timelib")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "timelib")))] pub fn timelib_date_time(&self) -> Result { Ok(time::OffsetDateTime::from_unix_timestamp(self.secs())? + time::Duration::nanoseconds(self.subsec_nanos().into())) @@ -385,7 +376,6 @@ impl UnixTime { } #[cfg(feature = "chrono")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "chrono")))] impl From> for UnixTime { fn from(value: chrono::DateTime) -> Self { Self::new(value.timestamp(), value.timestamp_subsec_nanos()) @@ -393,7 +383,6 @@ impl From> for UnixTime { } #[cfg(feature = "timelib")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "timelib")))] impl From for UnixTime { fn from(value: time::OffsetDateTime) -> Self { Self::new(value.unix_timestamp(), value.nanosecond()) diff --git a/src/util.rs b/src/util.rs index ecec1f8..44f15dd 100644 --- a/src/util.rs +++ b/src/util.rs @@ -77,7 +77,6 @@ pub trait UnsignedEnum { fn value(&self) -> u64; #[cfg(feature = "alloc")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] fn to_vec(&self) -> alloc::vec::Vec { let mut buf = alloc::vec![0; self.size()]; self.write_to_be_bytes(&mut buf).unwrap(); -- 2.43.0