* Added documentation to the `config` module * Added an example to the `config` module * Updated the docs in lib.rs regarding implementing backends * Started writing an alternate backends walkthrough * Mentioned the output.foo.command key * Added example output * Added a config section to the backends tutorial * Finished off the backends tutorial * Made sure travis checks mdbook-wordcount * Fixed the broken link at in the user guide * Changed how travis builds the project * Added a conclusion * Went through and documented a lot of stuff * Added a preprocessors chapter and updated For Developers
38 lines
No EOL
1,007 B
Rust
38 lines
No EOL
1,007 B
Rust
//! Book preprocessing.
|
|
|
|
pub use self::links::LinkPreprocessor;
|
|
|
|
mod links;
|
|
|
|
use book::Book;
|
|
use config::Config;
|
|
use errors::*;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
/// Extra information for a `Preprocessor` to give them more context when
|
|
/// processing a book.
|
|
pub struct PreprocessorContext {
|
|
/// The location of the book directory on disk.
|
|
pub root: PathBuf,
|
|
/// The book configuration (`book.toml`).
|
|
pub config: Config,
|
|
}
|
|
|
|
impl PreprocessorContext {
|
|
/// Create a new `PreprocessorContext`.
|
|
pub(crate) fn new(root: PathBuf, config: Config) -> Self {
|
|
PreprocessorContext { root, config }
|
|
}
|
|
}
|
|
|
|
/// An operation which is run immediately after loading a book into memory and
|
|
/// before it gets rendered.
|
|
pub trait Preprocessor {
|
|
/// Get the `Preprocessor`'s name.
|
|
fn name(&self) -> &str;
|
|
|
|
/// Run this `Preprocessor`, allowing it to update the book before it is
|
|
/// given to a renderer.
|
|
fn run(&self, ctx: &PreprocessorContext, book: &mut Book) -> Result<()>;
|
|
} |