mdbook_plotly/
preprocessor.rs1pub mod bookdata;
2pub mod config;
3pub mod handlers;
4
5use crate::fatal;
6
7pub fn preprocess_book() {
8 let mut book_data = bookdata::get_book_data();
9
10 book_data.emit_compatibility_warning();
11
12 let config = book_data.get_config();
13 let book_path = book_data.get_book_path();
14 #[cfg(feature = "sync")]
15 {
16 use rayon::prelude::*;
17 book_data
18 .chapter_par_iter()
19 .for_each(|chapter| handlers::handle(chapter, &config, &book_path));
20 }
21 #[cfg(not(feature = "sync"))]
22 {
23 book_data
24 .chapter_iter_mut()
25 .for_each(|chapter| handlers::handle(chapter, &config, &book_path));
26 }
27
28 let preprocessed_book = book_data.into_book();
29
30 if let Err(e) = serde_json::to_writer(std::io::stdout(), &preprocessed_book) {
31 fatal!("Write bookdata failed.\nInterError: {:#?}", e);
32 }
33}