From c9091c6df12e597823e4780e8c25ad11d7f39921 Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Sat, 7 Sep 2024 00:39:47 -0600 Subject: [PATCH] Fix cargo docs warnings and fix building on docsrs --- .github/workflows/rust.yml | 5 +++++ Cargo.toml | 1 + anise/build.rs | 2 +- anise/src/almanac/embed.rs | 2 +- anise/src/almanac/mod.rs | 2 +- anise/src/almanac/transform.rs | 2 +- anise/src/constants.rs | 2 +- anise/src/structure/lookuptable.rs | 2 +- anise/src/structure/planetocentric/mod.rs | 2 +- anise/tests/ephemerides/transform.rs | 2 +- data/.cargokeep | 1 + 11 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 data/.cargokeep diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 75e90022..ad7b925c 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -75,6 +75,11 @@ jobs: cd anise # Build only the Rust library cargo build --features embed_ephem cargo build --features embed_ephem --release + # Clean up the data folder as if we were on docsrs + cp data/.cargokeep . + rm -rf data/ + mkdir data && mv .cargokeep data/.cargokeep + cargo doc --features embed_ephem lints: name: Lints diff --git a/Cargo.toml b/Cargo.toml index 091f59f3..8dd5110f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ exclude = [ ".vscode", "*.sh", ] +include = ["data/.cargokeep"] [workspace.dependencies] hifitime = "4.0.0-alpha" diff --git a/anise/build.rs b/anise/build.rs index 0d9f7134..6c563285 100644 --- a/anise/build.rs +++ b/anise/build.rs @@ -28,7 +28,7 @@ fn main() { // Create the directory if it doesn't exist if !data_path.exists() { - if let Err(e) = fs::create_dir_all(&data_path) { + if fs::create_dir_all(&data_path).is_err() { eprintln!("EMBEDDED EPHEM UNAVAILABLE: failed to create directory {data_path:?}"); // Try nothing else. return; diff --git a/anise/src/almanac/embed.rs b/anise/src/almanac/embed.rs index c2061168..b2b1a1f4 100644 --- a/anise/src/almanac/embed.rs +++ b/anise/src/almanac/embed.rs @@ -16,7 +16,7 @@ struct AstroData; impl Almanac { /// Provides planetary ephemerides from 2024-01-01 until 2035-01-01. Also provides planetary constants data (from the PCK11 kernel). /// - /// Until https://github.com/nyx-space/anise/issues/269, this will provide 100 years of data + /// Until , this will provide 100 years of data pub fn until_2035() -> AlmanacResult { // Regularly refer to https://github.com/nyx-space/anise/blob/master/data/ci_config.dhall for the latest CRC, although it should not change between minor versions! let pck11 = AstroData::get("pck11.pca").ok_or(AlmanacError::GenericError { diff --git a/anise/src/almanac/mod.rs b/anise/src/almanac/mod.rs index a494a8e3..63282cd3 100644 --- a/anise/src/almanac/mod.rs +++ b/anise/src/almanac/mod.rs @@ -49,7 +49,7 @@ pub mod metaload; mod python; #[cfg(feature = "embed_ephem")] -#[cfg_attr(docrs, doc(cfg(feature = "embed_ephem")))] +#[cfg_attr(docsrs, doc(cfg(feature = "embed_ephem")))] mod embed; #[cfg(feature = "python")] diff --git a/anise/src/almanac/transform.rs b/anise/src/almanac/transform.rs index ee6d6642..592021b2 100644 --- a/anise/src/almanac/transform.rs +++ b/anise/src/almanac/transform.rs @@ -111,7 +111,7 @@ impl Almanac { /// Alias fo SPICE's `spkezr` where the inputs must be the NAIF IDs of the objects and frames with the caveat that the aberration is moved to the last positional argument. /// - pub fn spkezr( + pub fn spk_ezr( &self, target: NaifId, epoch: Epoch, diff --git a/anise/src/constants.rs b/anise/src/constants.rs index de40900e..8df960ad 100644 --- a/anise/src/constants.rs +++ b/anise/src/constants.rs @@ -236,7 +236,7 @@ pub mod orientations { pub const J2000_TO_ECLIPJ2000_ANGLE_RAD: f64 = 0.40909280422232897; /// Given the frame ID, try to return a human name - /// Source: // https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/frames.html#Appendix.%20%60%60Built%20in''%20Inertial%20Reference%20Frames + /// Source: pub const fn orientation_name_from_id(id: NaifId) -> Option<&'static str> { match id { J2000 => Some("J2000"), diff --git a/anise/src/structure/lookuptable.rs b/anise/src/structure/lookuptable.rs index 12c5e876..14dd8389 100644 --- a/anise/src/structure/lookuptable.rs +++ b/anise/src/structure/lookuptable.rs @@ -41,7 +41,7 @@ pub enum LutError { InvalidIndex { index: u32 }, } -/// A LookUpTable allows finding the [Entry] associated with either an ID or a name. +/// A LookUpTable allows finding the [u32] ("NaifId") associated with either an ID or a name. /// /// # Note /// _Both_ the IDs and the name MUST be unique in the look up table. diff --git a/anise/src/structure/planetocentric/mod.rs b/anise/src/structure/planetocentric/mod.rs index 2f3d8cdd..3cf96eb1 100644 --- a/anise/src/structure/planetocentric/mod.rs +++ b/anise/src/structure/planetocentric/mod.rs @@ -34,7 +34,7 @@ pub const MAX_NUT_PREC_ANGLES: usize = 32; /// ANISE supports two different kinds of orientation data. High precision, with spline based interpolations, and constants right ascension, declination, and prime meridian, typically used for planetary constant data. /// /// # Documentation of rotation angles -/// Source: https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/pck.html#Models%20for%20the%20Sun,%20Planets,%20and%20some%20Minor%20Bodies%20in%20Text%20PCK%20Kernels +/// Source: /// The angles RA, DEC, and W are defined as follows: /// /// ```text diff --git a/anise/tests/ephemerides/transform.rs b/anise/tests/ephemerides/transform.rs index 36a3cd13..88f7c9a0 100644 --- a/anise/tests/ephemerides/transform.rs +++ b/anise/tests/ephemerides/transform.rs @@ -174,7 +174,7 @@ fn de440s_transform_verif_venus2emb() { spice::unload(spk_path); // Finally, check that ANISE's SPKEZR works as expected. - let state_ezr = almanac.spkezr(EARTH, epoch, ITRF93, VENUS, None).unwrap(); + let state_ezr = almanac.spk_ezr(EARTH, epoch, ITRF93, VENUS, None).unwrap(); assert_eq!(state_ezr, state_rtn); } diff --git a/data/.cargokeep b/data/.cargokeep new file mode 100644 index 00000000..eea5b5c1 --- /dev/null +++ b/data/.cargokeep @@ -0,0 +1 @@ +Required in cargo for documenting the embed_ephem feature \ No newline at end of file