Initial Preprocessor trait implementation
This commit is contained in:
parent
bf093e2f5f
commit
01df904bb3
|
@ -23,7 +23,7 @@ use toml::Value;
|
|||
|
||||
use utils;
|
||||
use renderer::{CmdRenderer, HtmlHandlebars, RenderContext, Renderer};
|
||||
use preprocess;
|
||||
use preprocess::{self, Preprocessor};
|
||||
use errors::*;
|
||||
|
||||
use config::Config;
|
||||
|
@ -40,6 +40,9 @@ pub struct MDBook {
|
|||
|
||||
/// The URL used for live reloading when serving up the book.
|
||||
pub livereload: Option<String>,
|
||||
|
||||
/// List of pre-processors to be run on the book
|
||||
preprocessors: Vec<Box<Preprocessor>>
|
||||
}
|
||||
|
||||
impl MDBook {
|
||||
|
@ -86,12 +89,15 @@ impl MDBook {
|
|||
|
||||
let renderers = determine_renderers(&config);
|
||||
|
||||
let preprocessors = vec![];
|
||||
|
||||
Ok(MDBook {
|
||||
root,
|
||||
config,
|
||||
book,
|
||||
renderers,
|
||||
livereload,
|
||||
preprocessors,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -192,6 +198,13 @@ impl MDBook {
|
|||
self
|
||||
}
|
||||
|
||||
/// You can add a new preprocessor by using this method.
|
||||
/// The only requirement is for your renderer to implement the Preprocessor trait.
|
||||
pub fn with_preprecessor<P: Preprocessor + 'static>(&mut self, preprocessor: P) -> &mut Self {
|
||||
self.preprocessors.push(Box::new(preprocessor));
|
||||
self
|
||||
}
|
||||
|
||||
/// Run `rustdoc` tests on the book, linking against the provided libraries.
|
||||
pub fn test(&mut self, library_paths: Vec<&str>) -> Result<()> {
|
||||
let library_args: Vec<&str> = (0..library_paths.len())
|
||||
|
|
|
@ -1 +1,5 @@
|
|||
pub mod links;
|
||||
|
||||
pub trait Preprocessor {
|
||||
|
||||
}
|
Loading…
Reference in New Issue