#![deny(missing_docs)]
extern crate clap;
extern crate toml;
extern crate serde;
extern crate mdbook;
extern crate walkdir;
extern crate failure;
extern crate tinytemplate;
#[macro_use]
extern crate shells;
use mdbook::book::Book;
use mdbook::errors::Error;
use mdbook::preprocess::{Preprocessor, PreprocessorContext};
pub mod error;
pub mod models;
pub mod render;
pub mod cat_context;
use cat_context::CatContext;
pub struct Cat;
impl Cat {
pub fn new() -> Cat {
Cat
}
}
impl Preprocessor for Cat {
fn name(&self) -> &str {
"cat-preprocessor"
}
fn run(&self, _: &PreprocessorContext, mut book: Book) -> Result<Book, Error> {
let context = match CatContext::with_book(&mut book) {
Ok(c) => c,
Err(e) => {
eprintln!("[cat prep] failed to create cat context: {}", e);
return Err(Error::msg(e.to_string()));
}
};
let renders = match render::create_renders(&context, &mut book) {
Ok(rs) => rs,
Err(e) => {
eprintln!("[cat prep] failed to prepare renders of cat content: {}", e);
return Err(Error::msg(e.to_string()));
}
};
if let Err(e) = render::execute_renders(renders, &mut book) {
eprintln!("[cat prep] failed to prepare renders of cat content: {}", e);
return Err(Error::msg(e.to_string()));
}
dbg!("{:#?}", context);
Ok(book)
}
fn supports_renderer(&self, renderer: &str) -> bool {
renderer != "not-supported"
}
}