From 8b5f3d4bf4d91aac71e8bb34c3fd5e98761914ee Mon Sep 17 00:00:00 2001 From: Campbell He Date: Sat, 8 Jun 2024 16:13:45 +0800 Subject: [PATCH] docs: pull git submodule before build (#67) * docs: pull git submodule before build * fix: adopt clippy advice --- README.md | 1 + cli/src/project.rs | 6 +++--- cli/src/render/html.rs | 4 ++-- github-pages/docs/guide/installation.typ | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9dc3660..b228365 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ To build from source, run the following commands: ```sh git clone https://github.com/Myriad-Dreamin/typst-book.git +git submodule update --recursive --init cargo run --bin typst-book-build # optional: install it globally cargo install --path ./cli diff --git a/cli/src/project.rs b/cli/src/project.rs index 6020b8f..426f50a 100644 --- a/cli/src/project.rs +++ b/cli/src/project.rs @@ -67,7 +67,7 @@ impl Project { } if args.workspace.is_empty() { - args.workspace = args.dir.clone(); + args.workspace.clone_from(&args.dir); } let tr = TypstRenderer::new(args); @@ -101,11 +101,11 @@ impl Project { } if final_dest_dir.is_empty() { - final_dest_dir = "dist".to_owned(); + "dist".clone_into(&mut final_dest_dir); } proj.tr.fix_dest_dir(Path::new(&final_dest_dir)); - proj.dest_dir = proj.tr.dest_dir.clone(); + proj.dest_dir.clone_from(&proj.tr.dest_dir); Ok(proj) } diff --git a/cli/src/render/html.rs b/cli/src/render/html.rs index 7572599..c47f85d 100644 --- a/cli/src/render/html.rs +++ b/cli/src/render/html.rs @@ -150,7 +150,7 @@ impl HelperDef for RenderToc { for item in chapters { // Spacer - if item.get("spacer").is_some() { + if item.contains_key("spacer") { out.write("
  • ")?; continue; } @@ -189,7 +189,7 @@ impl HelperDef for RenderToc { write_li_open_tag(out, is_expanded, false)?; } Ordering::Equal => { - write_li_open_tag(out, is_expanded, item.get("section").is_none())?; + write_li_open_tag(out, is_expanded, !item.contains_key("section"))?; } } diff --git a/github-pages/docs/guide/installation.typ b/github-pages/docs/guide/installation.typ index b322dae..351c82d 100644 --- a/github-pages/docs/guide/installation.typ +++ b/github-pages/docs/guide/installation.typ @@ -34,6 +34,7 @@ To build from source, run the following commands (note: it depends on `yarn` to ```sh git clone https://github.com/Myriad-Dreamin/typst-book.git +git submodule update --recursive --init cargo run --bin typst-book-build # optional: install it globally cargo install --path ./cli