From f917080c02aed886c81abd33393a33daca3614ec Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Fri, 2 Aug 2024 16:07:23 -0600 Subject: [PATCH] Update docs to include examples, plots, and scrape examples --- ...ebase-hosting-merge.yml => deploy-live-docs.yml} | 11 ++++++++++- ...ing-pull-request.yml => deploy-staging-docs.yml} | 11 ++++++++++- Cargo.toml | 5 +++++ examples/01_orbit_prop/README.md | 6 +++--- examples/01_orbit_prop/main.rs | 1 + .../{ => plots}/cubesat-angles-v-time.png | Bin .../{ => plots}/cubesat-ecc-v-time.png | Bin .../{ => plots}/cubesat-sma-v-time.png | Bin examples/02_jwst_covar_monte_carlo/main.rs | 1 + examples/03_geo_analysis/drift.rs | 1 + examples/03_geo_analysis/raise.rs | 1 + examples/03_geo_analysis/stationkeeping.rs | 1 + src/dynamics/orbital.rs | 6 +++--- 13 files changed, 36 insertions(+), 8 deletions(-) rename .github/workflows/{firebase-hosting-merge.yml => deploy-live-docs.yml} (61%) rename .github/workflows/{firebase-hosting-pull-request.yml => deploy-staging-docs.yml} (62%) rename examples/01_orbit_prop/{ => plots}/cubesat-angles-v-time.png (100%) rename examples/01_orbit_prop/{ => plots}/cubesat-ecc-v-time.png (100%) rename examples/01_orbit_prop/{ => plots}/cubesat-sma-v-time.png (100%) diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/deploy-live-docs.yml similarity index 61% rename from .github/workflows/firebase-hosting-merge.yml rename to .github/workflows/deploy-live-docs.yml index 56954d89..d2724222 100644 --- a/.github/workflows/firebase-hosting-merge.yml +++ b/.github/workflows/deploy-live-docs.yml @@ -15,7 +15,16 @@ jobs: uses: dtolnay/rust-toolchain@master with: toolchain: nightly - - run: cargo doc --no-deps -Zunstable-options -Zrustdoc-scrape-examples + - run: cargo doc --no-deps --examples -Z rustdoc-scrape-examples + - name: Copy plots directories + run: | + for example_dir in examples/*; do + if [ -d "$example_dir/plots" ]; then + example_name=$(basename $example_dir) + mkdir -p target/doc/$example_name/plots + cp -r $example_dir/plots/* target/doc/$example_name/plots/ + fi + done - uses: FirebaseExtended/action-hosting-deploy@v0 with: repoToken: '${{ secrets.GITHUB_TOKEN }}' diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/deploy-staging-docs.yml similarity index 62% rename from .github/workflows/firebase-hosting-pull-request.yml rename to .github/workflows/deploy-staging-docs.yml index 11c9b655..2463cf10 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/deploy-staging-docs.yml @@ -13,7 +13,16 @@ jobs: uses: dtolnay/rust-toolchain@master with: toolchain: nightly - - run: cargo doc --no-deps -Zunstable-options -Zrustdoc-scrape-examples + - run: cargo doc --no-deps --examples -Z rustdoc-scrape-examples + - name: Copy plots directories + run: | + for example_dir in examples/*; do + if [ -d "$example_dir/plots" ]; then + example_name=$(basename $example_dir) + mkdir -p target/doc/$example_name/plots + cp -r $example_dir/plots/* target/doc/$example_name/plots/ + fi + done - uses: FirebaseExtended/action-hosting-deploy@v0 with: repoToken: '${{ secrets.GITHUB_TOKEN }}' diff --git a/Cargo.toml b/Cargo.toml index 341a43a6..7fc9b2b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -104,19 +104,24 @@ cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] [[example]] name = "01_orbit_prop" path = "examples/01_orbit_prop/main.rs" +doc-scrape-examples = true [[example]] name = "02_jwst" path = "examples/02_jwst_covar_monte_carlo/main.rs" +doc-scrape-examples = true [[example]] name = "03_geo_drift" path = "examples/03_geo_analysis/drift.rs" +doc-scrape-examples = true [[example]] name = "03_geo_raise" path = "examples/03_geo_analysis/raise.rs" +doc-scrape-examples = true [[example]] name = "03_geo_sk" path = "examples/03_geo_analysis/stationkeeping.rs" +doc-scrape-examples = true diff --git a/examples/01_orbit_prop/README.md b/examples/01_orbit_prop/README.md index 3ff583e2..4901f067 100644 --- a/examples/01_orbit_prop/README.md +++ b/examples/01_orbit_prop/README.md @@ -28,10 +28,10 @@ The force models used here are akin to STK's "HPOP" propagator. Specifically, th In two body propagation, all orbital elements remain constant apart from the true anomaly. In real life, the oblateness of the Earth causes the right ascension of the ascending node to drift with time (red line below). The other force models also affect the overall orbit. -![RAAN, AOP, INC over time](./cubesat-angles-v-time.png) +![RAAN, AOP, INC over time](./plots/cubesat-angles-v-time.png) -![SMA (km) over time](./cubesat-sma-v-time.png) +![SMA (km) over time](./plots/cubesat-sma-v-time.png) -![ECC over time](./cubesat-ecc-v-time.png) +![ECC over time](./plots/cubesat-ecc-v-time.png) _Note_: These plots were generated with an SRP area of that was ten times larger than the correct value, hence you may notice slightly different Keplerian orbital elements, notably for the change in the shape of the orbit. diff --git a/examples/01_orbit_prop/main.rs b/examples/01_orbit_prop/main.rs index 0667f3e2..c2f46b0b 100644 --- a/examples/01_orbit_prop/main.rs +++ b/examples/01_orbit_prop/main.rs @@ -1,3 +1,4 @@ +#![doc = include_str!("./README.md")] extern crate log; extern crate nyx_space as nyx; extern crate pretty_env_logger as pel; diff --git a/examples/01_orbit_prop/cubesat-angles-v-time.png b/examples/01_orbit_prop/plots/cubesat-angles-v-time.png similarity index 100% rename from examples/01_orbit_prop/cubesat-angles-v-time.png rename to examples/01_orbit_prop/plots/cubesat-angles-v-time.png diff --git a/examples/01_orbit_prop/cubesat-ecc-v-time.png b/examples/01_orbit_prop/plots/cubesat-ecc-v-time.png similarity index 100% rename from examples/01_orbit_prop/cubesat-ecc-v-time.png rename to examples/01_orbit_prop/plots/cubesat-ecc-v-time.png diff --git a/examples/01_orbit_prop/cubesat-sma-v-time.png b/examples/01_orbit_prop/plots/cubesat-sma-v-time.png similarity index 100% rename from examples/01_orbit_prop/cubesat-sma-v-time.png rename to examples/01_orbit_prop/plots/cubesat-sma-v-time.png diff --git a/examples/02_jwst_covar_monte_carlo/main.rs b/examples/02_jwst_covar_monte_carlo/main.rs index 117d2ba3..e6b33a36 100644 --- a/examples/02_jwst_covar_monte_carlo/main.rs +++ b/examples/02_jwst_covar_monte_carlo/main.rs @@ -1,3 +1,4 @@ +#![doc = include_str!("./README.md")] extern crate log; extern crate nyx_space as nyx; extern crate pretty_env_logger as pel; diff --git a/examples/03_geo_analysis/drift.rs b/examples/03_geo_analysis/drift.rs index 41d6503a..ca590a62 100644 --- a/examples/03_geo_analysis/drift.rs +++ b/examples/03_geo_analysis/drift.rs @@ -1,3 +1,4 @@ +#![doc = include_str!("./README.md")] extern crate log; extern crate nyx_space as nyx; extern crate pretty_env_logger as pel; diff --git a/examples/03_geo_analysis/raise.rs b/examples/03_geo_analysis/raise.rs index 063db4a7..6d7750f7 100644 --- a/examples/03_geo_analysis/raise.rs +++ b/examples/03_geo_analysis/raise.rs @@ -1,3 +1,4 @@ +#![doc = include_str!("./README.md")] extern crate log; extern crate nyx_space as nyx; extern crate pretty_env_logger as pel; diff --git a/examples/03_geo_analysis/stationkeeping.rs b/examples/03_geo_analysis/stationkeeping.rs index 442b5667..ed8ecef1 100644 --- a/examples/03_geo_analysis/stationkeeping.rs +++ b/examples/03_geo_analysis/stationkeeping.rs @@ -1,3 +1,4 @@ +#![doc = include_str!("./README.md")] extern crate log; extern crate nyx_space as nyx; extern crate pretty_env_logger as pel; diff --git a/src/dynamics/orbital.rs b/src/dynamics/orbital.rs index 994abd5a..1358f7b0 100644 --- a/src/dynamics/orbital.rs +++ b/src/dynamics/orbital.rs @@ -41,7 +41,7 @@ pub struct OrbitalDynamics { } impl OrbitalDynamics { - /// Initialize point mass dynamics given the EXB IDs and a Cosm + /// Initializes the point masses gravities with the provided list of bodies pub fn point_masses(celestial_objects: Vec) -> Self { // Create the point masses Self::new(vec![PointMasses::new(celestial_objects)]) @@ -176,7 +176,7 @@ pub struct PointMasses { } impl PointMasses { - /// Initializes the multibody point mass dynamics with the provided list of bodies + /// Initializes the point masses gravities with the provided list of bodies pub fn new(celestial_objects: Vec) -> Arc { Arc::new(Self { celestial_objects, @@ -184,7 +184,7 @@ impl PointMasses { }) } - /// Initializes the multibody point mass dynamics with the provided list of bodies, and accounting for some light time correction + /// Initializes the point masses gravities with the provided list of bodies, and accounting for some light time correction pub fn with_correction(celestial_objects: Vec, correction: Aberration) -> Self { Self { celestial_objects,