1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! `mdbook` book building
use Path;
use Command;
use anyhow;
use Context;
use Result;
/// Invokes `mdbook build`.
///
/// Usage example:
///
/// ```rust,ignore
/// println!("Info: building the book...");
/// let res = build_book(&root_path);
/// if let Err(ref e) = res {
/// println!("cargo:warning=ERROR: {}", e);
/// return res;
/// }
/// ```
pub
// // Tell Cargo to rerun the build.rs script, if the .md files
// change.
// See also: https://crates.io/crates/cargo-emit
// fn build_rs_helper() -> Result<()> {
// let root_path = std::fs::canonicalize("..")
// .context("[build_rs_helper] Failed to locate the root path on disk.
// Does it exist?")?; let original_markdown_dir_path =
// root_path.join("src/"); let original_markdown_paths =
// WalkDir::new(original_markdown_dir_path).into_iter()
// .map(|p| p.unwrap().path().to_string_lossy().into_owned())
// // DirEntry to String .filter(|p| p.ends_with(".md"))
// .collect::<Vec<_>>();
// for path in original_markdown_paths {
// println!("cargo:rerun-if-changed={}", path);
// // println!("cargo:warning=DEBUG:{}", path);
// }
// Ok(())
// }