From 676b41da14993277fd5fd4559433f3118ea146a2 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Mon, 5 Jun 2023 19:27:03 -0700 Subject: [PATCH] building with mdbook as a library --- .github/workflows/deploy.yml | 2 ++ Cargo.toml | 2 +- src/build.rs | 17 ----------------- src/main.rs | 13 ++++++++++++- 4 files changed, 15 insertions(+), 19 deletions(-) delete mode 100644 src/build.rs diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ee2462f..9309410 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -43,6 +43,8 @@ jobs: # This assumes your book is in the root of your repository. # Just add a `cd` here if you need to change to another directory. # mdbook build + # the binary of the package builds the book! + docs git worktree add gh-pages git config user.name "Deploy from CI" git config user.email "" diff --git a/Cargo.toml b/Cargo.toml index b69681c..817d5b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[build-dependencies] +[dependencies] mdbook = "0.4.30" mdbook-bib = "0.0.5" mdbook-mermaid = "0.12.6" diff --git a/src/build.rs b/src/build.rs deleted file mode 100644 index 5173e0f..0000000 --- a/src/build.rs +++ /dev/null @@ -1,17 +0,0 @@ -// build.rs -// following https://github.com/tchernobog/rfcs/blob/master/text/0000-cargo-run-deps.md -use std::{env, process::Command}; - -fn main() { - let cargo_path = env::var("CARGO").unwrap(); - let mut mdbook = Command::new(cargo_path).args(&[ - "run", - "--package", - "mdbook", - "--", - "build", - ]); - - println!("Built book!") - -} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index a82ed1c..d0a2e75 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,16 @@ // dummy file +use mdbook::MDBook; + fn main() { - println!("This package does nothing! It's just for gathering deps to build the book!") + let root_dir = "./"; + let mut md = MDBook::load(root_dir) + .expect("Unable to load the book"); + md.build().expect("Building failed"); + + + + // println!("This package does nothing! It's just for gathering deps to build the book!") + + } \ No newline at end of file