Skip to content

Commit cfeafcf

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

File tree

22 files changed

+131
-66
lines changed

22 files changed

+131
-66
lines changed
Lines changed: 50 additions & 0 deletions
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
Lines changed: 47 additions & 0 deletions
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

Lines changed: 0 additions & 24 deletions
This file was deleted.

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

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/rust.yaml

Lines changed: 5 additions & 5 deletions
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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 0 deletions
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;

0 commit comments

Comments
 (0)