Skip to content

Commit 0426a84

Browse files
authored
chore: update links, faster deploy (#191)
* update links, faster deploy * fix lint, clippy * add section about mdbook
1 parent d4bc0d5 commit 0426a84

6 files changed

Lines changed: 54 additions & 12 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,30 @@ jobs:
2929
MDBOOK_KATEX_VERSION: 0.9.2
3030
steps:
3131
- uses: actions/checkout@v4
32-
- name: Install mdBook
32+
33+
- name: Install cargo-binstall
34+
uses: cargo-bins/cargo-binstall@main
35+
36+
- name: Install rust
3337
run: |
3438
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh
3539
rustup update
36-
cargo install --version ${MDBOOK_VERSION} mdbook
37-
cargo install --version ${MDBOOK_KATEX_VERSION} mdbook-katex
40+
41+
- name: Install mdbook
42+
run: |
43+
cargo binstall --no-confirm --version ${MDBOOK_VERSION} mdbook
44+
cargo binstall --no-confirm --version ${MDBOOK_KATEX_VERSION} mdbook-katex
45+
3846
- name: Setup Pages
3947
id: pages
4048
uses: actions/configure-pages@v5
49+
4150
- name: Build with mdBook
4251
run: |
4352
cargo run --bin create_mdbook
4453
cp -r assets book/
4554
mdbook build
55+
4656
- name: Upload artifact
4757
uses: actions/upload-pages-artifact@v3
4858
with:

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,23 @@ To see computations used in the background, go to the `math/` directory.
9494
From there, you can run the `.sage` files in a SageMath environment.
9595
In particular, the `math/field.sage` computes roots of unity in the `PlutoField` which is of size 101. To install sage on your machine, follow the instructions [here](https://doc.sagemath.org/html/en/installation/index.html). If you are on a Mac, you can install it via homebrew with `brew install --cask sage`.
9696

97+
## Building mdBook
98+
99+
To locally build/serve the [mdBook](https://github.com/rust-lang/mdBook) site, install mdBook and [mdbook-katex](https://github.com/lzanini/mdbook-katex):
100+
```
101+
cargo install mdbook
102+
cargo install mdbook-katex
103+
```
104+
105+
To build, run:
106+
```
107+
cargo run --bin create_mdbook
108+
cp -r assets book/
109+
mdbook build
110+
```
111+
112+
If you want to serve locally, run `mdbook serve`.
113+
97114
## License
98115

99116
Licensed under the Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)

book.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ after = ["links"]
1616

1717
[output.html]
1818
default-theme = "dark"
19-
preferred-dark-theme = "coal"
19+
preferred-dark-theme = "ayu"
2020
git-repository-url = "https://github.com/pluto/ronkathon"

src/algebra/group/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- `FiniteCyclicGroup`: a finite group with a generator.
88

99
### `Group`
10-
[`Group`](./group.rs) represents a group with finite elements. It defines a binary operation on the set of elements of the group.
10+
[`Group`](./mod.rs) represents a group with finite elements. It defines a binary operation on the set of elements of the group.
1111
- `IDENTITY`: The identity element of the group.
1212
- `inverse(&self) -> Self`: inverse of the element.
1313
- `operation(a: &Self, b: &Self) -> Self`: the operation of the group.
@@ -27,4 +27,4 @@ It uses compile time assertions to check that $P$ is prime.
2727

2828
## Examples
2929

30-
[PermutationGroup](/examples/permutation_group.rs) example showcases how `Group` trait is implemented for any struct.
30+
[Symmetric Group](../../../examples/symmetric_group.rs) example showcases how `Group` trait is implemented for any struct.

src/bin/create_mdbook.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
/// Read SUMMARY.md and copy `README.md` files given in it to `book` directory.
2-
/// Additionally, change the links to other `README.md` files to `index.md`, so that link
3-
/// points to correct file in the mdbook.
1+
/// 1. Read SUMMARY.md and copy `README.md` files given in it to `book` directory.
2+
/// 2. Change the links to other `README.md` files to `index.md`, so that link points to
3+
/// correct file in the mdbook.
4+
/// 3. Change links that point to a '.rs' file to their github repo link.
45
use std::{
56
fs::{self, File},
67
io::{self, BufRead, BufReader, Write},
@@ -10,6 +11,8 @@ use std::{
1011
use regex::Regex;
1112

1213
const DEST: &str = "book";
14+
const REPO_LINK: &str = "https://github.com/pluto/ronkathon/blob/main/";
15+
const SHOW_CHANGES: bool = false;
1316

1417
fn main() -> io::Result<()> {
1518
let dest_path = Path::new(DEST);
@@ -32,9 +35,14 @@ fn main() -> io::Result<()> {
3235
}
3336

3437
let readme_re = Regex::new(r"README.md").unwrap();
38+
let rs_links = Regex::new(r"(?<t>\[.*\])\([/]?(?<l>.*\.rs)\)").unwrap();
3539

3640
for src in &readmes {
3741
println!("Working on: {}", src.display());
42+
let mut src_parent = src.parent().unwrap().to_str().unwrap().to_owned();
43+
if !src_parent.is_empty() {
44+
src_parent.push('/');
45+
}
3846

3947
let dest = Path::new(DEST).join(src);
4048
let dest_folder = dest.parent().unwrap();
@@ -48,8 +56,15 @@ fn main() -> io::Result<()> {
4856

4957
for line in reader.lines() {
5058
let before = line.unwrap();
51-
let after = readme_re.replace_all(&before, "index.md");
52-
dest_file.write_all(after.as_bytes())?;
59+
let after1 = readme_re.replace_all(&before, "index.md");
60+
if before != after1 && SHOW_CHANGES {
61+
println!("1. {before} -> {after1}");
62+
}
63+
let after2 = rs_links.replace_all(&after1, format!("$t({}{}$l)", REPO_LINK, src_parent));
64+
if after1 != after2 && SHOW_CHANGES {
65+
println!("2. {after1} -> {after2}");
66+
}
67+
dest_file.write_all(after2.as_bytes())?;
5368
dest_file.write_all(b"\n")?;
5469
}
5570
}

src/curve/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Predominantly, we use the extension $F_{p^2}$ since we need this for the [Tate p
1414
We refer to $F_{101}$ as the `PlutoBaseField` and $F_{101^2}$ as the `PlutoBaseFieldExtension` within `ronkathon`.
1515
From which, we also use the terminology of `PlutoCurve` to refer to $E(F_{101})$ and `PlutoExtendedCurve` to refer to $E(F_{101^2})$.
1616

17-
We also define a `CurveGroup`, an extension of [`FiniteGroup`](../field/group.rs) trait representing the group law of the curve.
17+
We also define a `CurveGroup`, an extension of [`FiniteGroup`](../algebra/group/mod.rs) trait representing the group law of the curve.
1818

1919
### Type B curve and type 1 pairing
2020

0 commit comments

Comments
 (0)