Skip to content

Commit cfeafcf

Browse files
Scrape examples for docs and quicken the CI (#345)
1 parent fbf6251 commit cfeafcf

22 files changed

+131
-66
lines changed
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# This file was auto-generated by the Firebase CLI
2+
# https://github.com/firebase/firebase-tools
3+
4+
name: Deploy to Firebase Hosting on merge
5+
'on':
6+
push:
7+
branches:
8+
- master
9+
jobs:
10+
build_and_deploy:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Install Rust toolchain
15+
uses: dtolnay/rust-toolchain@master
16+
with:
17+
toolchain: nightly
18+
- run: cargo doc --no-deps --examples -Z rustdoc-scrape-examples
19+
- name: Copy plots directories
20+
run: |
21+
declare -A example_map
22+
example_map["01_orbit_prop"]="01_orbit_prop"
23+
example_map["02_jwst"]="02_jwst_covar_monte_carlo"
24+
25+
declare -A special_cases
26+
special_cases["03_geo_analysis"]="03_geo_raise 03_geo_drift 03_geo_sk"
27+
28+
for example_dir in examples/*; do
29+
example_name=$(basename $example_dir)
30+
if [ -d "$example_dir/plots" ]; then
31+
if [ -n "${example_map[$example_name]}" ]; then
32+
doc_name=${example_map[$example_name]}
33+
mkdir -p target/doc/$doc_name/plots
34+
cp -r $example_dir/plots/* target/doc/$doc_name/plots/
35+
elif [ -n "${special_cases[$example_name]}" ]; then
36+
for target_folder in ${special_cases[$example_name]}; do
37+
mkdir -p target/doc/$target_folder/plots
38+
cp -r $example_dir/plots/* target/doc/$target_folder/plots/
39+
done
40+
else
41+
echo "No mapping found for $example_name"
42+
fi
43+
fi
44+
done
45+
- uses: FirebaseExtended/action-hosting-deploy@v0
46+
with:
47+
repoToken: '${{ secrets.GITHUB_TOKEN }}'
48+
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_NYX_SPACE }}'
49+
channelId: live
50+
projectId: nyx-space
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This file was auto-generated by the Firebase CLI
2+
# https://github.com/firebase/firebase-tools
3+
4+
name: Deploy to Firebase Hosting on PR
5+
'on': pull_request
6+
jobs:
7+
build_and_preview:
8+
if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- name: Install Rust toolchain
13+
uses: dtolnay/rust-toolchain@master
14+
with:
15+
toolchain: nightly
16+
- run: cargo doc --no-deps --examples -Z rustdoc-scrape-examples
17+
- name: Copy plots directories
18+
run: |
19+
declare -A example_map
20+
example_map["01_orbit_prop"]="01_orbit_prop"
21+
example_map["02_jwst"]="02_jwst_covar_monte_carlo"
22+
23+
declare -A special_cases
24+
special_cases["03_geo_analysis"]="03_geo_raise 03_geo_drift 03_geo_sk"
25+
26+
for example_dir in examples/*; do
27+
example_name=$(basename $example_dir)
28+
if [ -d "$example_dir/plots" ]; then
29+
if [ -n "${example_map[$example_name]}" ]; then
30+
doc_name=${example_map[$example_name]}
31+
mkdir -p target/doc/$doc_name/plots
32+
cp -r $example_dir/plots/* target/doc/$doc_name/plots/
33+
elif [ -n "${special_cases[$example_name]}" ]; then
34+
for target_folder in ${special_cases[$example_name]}; do
35+
mkdir -p target/doc/$target_folder/plots
36+
cp -r $example_dir/plots/* target/doc/$target_folder/plots/
37+
done
38+
else
39+
echo "No mapping found for $example_name"
40+
fi
41+
fi
42+
done
43+
- uses: FirebaseExtended/action-hosting-deploy@v0
44+
with:
45+
repoToken: '${{ secrets.GITHUB_TOKEN }}'
46+
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_NYX_SPACE }}'
47+
projectId: nyx-space

.github/workflows/firebase-hosting-merge.yml

-24
This file was deleted.

.github/workflows/firebase-hosting-pull-request.yml

-21
This file was deleted.

.github/workflows/rust.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ jobs:
8383

8484
- name: Run examples
8585
run: |
86-
cargo run --example 01_orbit_prop --release
87-
cargo run --example 02_jwst --release
88-
cargo run --example 03_geo_drift --release
89-
cargo run --example 03_geo_raise --release
90-
cargo run --example 03_geo_sk --release
86+
cargo build --example 01_orbit_prop --release
87+
cargo build --example 02_jwst --release
88+
cargo build --example 03_geo_drift --release
89+
cargo build --example 03_geo_raise --release
90+
cargo build --example 03_geo_sk --release
9191
9292
lints:
9393
name: Lints

Cargo.toml

+8
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,30 @@ name = "nyx_space"
9898
linker = "/usr/bin/clang"
9999
rustflags = ["-Clink-arg=-fuse-ld=lld", "-Clink-arg=-Wl,--no-rosegment"]
100100

101+
[package.metadata.docs.rs]
102+
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
103+
101104
[[example]]
102105
name = "01_orbit_prop"
103106
path = "examples/01_orbit_prop/main.rs"
107+
doc-scrape-examples = true
104108

105109
[[example]]
106110
name = "02_jwst"
107111
path = "examples/02_jwst_covar_monte_carlo/main.rs"
112+
doc-scrape-examples = true
108113

109114
[[example]]
110115
name = "03_geo_drift"
111116
path = "examples/03_geo_analysis/drift.rs"
117+
doc-scrape-examples = true
112118

113119
[[example]]
114120
name = "03_geo_raise"
115121
path = "examples/03_geo_analysis/raise.rs"
122+
doc-scrape-examples = true
116123

117124
[[example]]
118125
name = "03_geo_sk"
119126
path = "examples/03_geo_analysis/stationkeeping.rs"
127+
doc-scrape-examples = true

examples/01_orbit_prop/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ The force models used here are akin to STK's "HPOP" propagator. Specifically, th
2828

2929
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.
3030

31-
![RAAN, AOP, INC over time](./cubesat-angles-v-time.png)
31+
![RAAN, AOP, INC over time](./plots/cubesat-angles-v-time.png)
3232

33-
![SMA (km) over time](./cubesat-sma-v-time.png)
33+
![SMA (km) over time](./plots/cubesat-sma-v-time.png)
3434

35-
![ECC over time](./cubesat-ecc-v-time.png)
35+
![ECC over time](./plots/cubesat-ecc-v-time.png)
3636

3737
_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.

examples/01_orbit_prop/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![doc = include_str!("./README.md")]
12
extern crate log;
23
extern crate nyx_space as nyx;
34
extern crate pretty_env_logger as pel;

examples/02_jwst_covar_monte_carlo/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![doc = include_str!("./README.md")]
12
extern crate log;
23
extern crate nyx_space as nyx;
34
extern crate pretty_env_logger as pel;

examples/03_geo_analysis/drift.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![doc = include_str!("./README.md")]
12
extern crate log;
23
extern crate nyx_space as nyx;
34
extern crate pretty_env_logger as pel;

examples/03_geo_analysis/raise.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![doc = include_str!("./README.md")]
12
extern crate log;
23
extern crate nyx_space as nyx;
34
extern crate pretty_env_logger as pel;

examples/03_geo_analysis/stationkeeping.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![doc = include_str!("./README.md")]
12
extern crate log;
23
extern crate nyx_space as nyx;
34
extern crate pretty_env_logger as pel;

src/dynamics/orbital.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub struct OrbitalDynamics {
4141
}
4242

4343
impl OrbitalDynamics {
44-
/// Initialize point mass dynamics given the EXB IDs and a Cosm
44+
/// Initializes the point masses gravities with the provided list of bodies
4545
pub fn point_masses(celestial_objects: Vec<i32>) -> Self {
4646
// Create the point masses
4747
Self::new(vec![PointMasses::new(celestial_objects)])
@@ -176,15 +176,15 @@ pub struct PointMasses {
176176
}
177177

178178
impl PointMasses {
179-
/// Initializes the multibody point mass dynamics with the provided list of bodies
179+
/// Initializes the point masses gravities with the provided list of bodies
180180
pub fn new(celestial_objects: Vec<i32>) -> Arc<Self> {
181181
Arc::new(Self {
182182
celestial_objects,
183183
correction: None,
184184
})
185185
}
186186

187-
/// Initializes the multibody point mass dynamics with the provided list of bodies, and accounting for some light time correction
187+
/// Initializes the point masses gravities with the provided list of bodies, and accounting for some light time correction
188188
pub fn with_correction(celestial_objects: Vec<i32>, correction: Aberration) -> Self {
189189
Self {
190190
celestial_objects,

src/mc/results.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ where
358358
let mut utc_epoch = StringBuilder::new();
359359
let mut idx_col = Int32Builder::new();
360360
for (sno, s) in all_states.iter().enumerate() {
361-
utc_epoch.append_value(&s.epoch().to_time_scale(TimeScale::UTC).to_isoformat());
361+
utc_epoch.append_value(s.epoch().to_time_scale(TimeScale::UTC).to_isoformat());
362362

363363
// Copy this a bunch of times because all columns must have the same length
364364
idx_col.append_value(run_indexes[sno]);

src/md/trajectory/traj.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ where
235235
// Epochs
236236
let mut utc_epoch = StringBuilder::new();
237237
for s in &states {
238-
utc_epoch.append_value(&s.epoch().to_time_scale(TimeScale::UTC).to_isoformat());
238+
utc_epoch.append_value(s.epoch().to_time_scale(TimeScale::UTC).to_isoformat());
239239
}
240240
record.push(Arc::new(utc_epoch.finish()));
241241

@@ -459,7 +459,7 @@ where
459459
// Epochs (both match for self and others)
460460
let mut utc_epoch = StringBuilder::new();
461461
for s in &self_states {
462-
utc_epoch.append_value(&s.epoch().to_time_scale(TimeScale::UTC).to_isoformat());
462+
utc_epoch.append_value(s.epoch().to_time_scale(TimeScale::UTC).to_isoformat());
463463
}
464464
record.push(Arc::new(utc_epoch.finish()));
465465

src/od/msr/arc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ where
140140
// Epochs
141141
let mut utc_epoch = StringBuilder::new();
142142
for m in &measurements {
143-
utc_epoch.append_value(&m.1.epoch().to_time_scale(TimeScale::UTC).to_isoformat());
143+
utc_epoch.append_value(m.1.epoch().to_time_scale(TimeScale::UTC).to_isoformat());
144144
}
145145
record.push(Arc::new(utc_epoch.finish()));
146146

src/od/process/export.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ where
287287
// Epochs
288288
let mut utc_epoch = StringBuilder::new();
289289
for s in &estimates {
290-
utc_epoch.append_value(&s.epoch().to_time_scale(TimeScale::UTC).to_isoformat());
290+
utc_epoch.append_value(s.epoch().to_time_scale(TimeScale::UTC).to_isoformat());
291291
}
292292
record.push(Arc::new(utc_epoch.finish()));
293293

src/od/simulator/arc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ impl TrackingArcSim<Spacecraft, RangeDoppler, GroundStation> {
294294
/// 5. Build each of these as "tracking strands" for this tracking device.
295295
/// 6. Organize all of the built tracking strands chronologically.
296296
/// 7. Iterate through all of the strands:
297-
/// 7.a. if that tracker is marked as `Greedy` and it ends after the start of the next strand, change the start date of the next strand.
298-
/// 7.b. if that tracker is marked as `Eager` and it ends after the start of the next strand, change the end date of the current strand.
297+
/// 7.a. if that tracker is marked as `Greedy` and it ends after the start of the next strand, change the start date of the next strand.
298+
/// 7.b. if that tracker is marked as `Eager` and it ends after the start of the next strand, change the end date of the current strand.
299299
pub fn generate_schedule(
300300
&self,
301301
almanac: Arc<Almanac>,

src/propagators/error_ctrl.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ impl ErrorCtrl for RSSStep {
171171
/// > This is a more stringent error control method than [`rss_step`] that is often used as the default in other software such as STK.
172172
/// > If you set [the] accuracy to a very small number, 1e-13 for example, and set the error control to [`rss_step`], integrator
173173
/// > performance will be poor, for little if any improvement in the accuracy of the orbit integration.
174-
/// For more best practices of these integrators (which clone those in GMAT), please refer to the
175-
/// [GMAT reference](https://github.com/ChristopherRabotin/GMAT/blob/37201a6290e7f7b941bc98ee973a527a5857104b/doc/help/src/Resource_NumericalIntegrators.xml#L1292).
176-
/// (Source)[https://github.com/ChristopherRabotin/GMAT/blob/37201a6290e7f7b941bc98ee973a527a5857104b/src/base/forcemodel/ODEModel.cpp#L3004]
174+
/// > For more best practices of these integrators (which clone those in GMAT), please refer to the
175+
/// > [GMAT reference](https://github.com/ChristopherRabotin/GMAT/blob/37201a6290e7f7b941bc98ee973a527a5857104b/doc/help/src/Resource_NumericalIntegrators.xml#L1292).
176+
/// > (Source)[https://github.com/ChristopherRabotin/GMAT/blob/37201a6290e7f7b941bc98ee973a527a5857104b/src/base/forcemodel/ODEModel.cpp#L3004]
177177
#[derive(Clone, Copy)]
178178
#[allow(clippy::upper_case_acronyms)]
179179
pub struct RSSState;

0 commit comments

Comments
 (0)