Created a new Loader module and some stubs

This commit is contained in:
Michael Bryan 2017-06-24 22:47:03 +08:00
parent 4974d2cfa1
commit 1e60d6b53c
2 changed files with 30 additions and 0 deletions

View File

@ -89,6 +89,7 @@ mod parse;
pub mod renderer; pub mod renderer;
pub mod theme; pub mod theme;
pub mod utils; pub mod utils;
pub mod loader;
pub use book::MDBook; pub use book::MDBook;
pub use book::BookItem; pub use book::BookItem;

29
src/loader/mod.rs Normal file
View File

@ -0,0 +1,29 @@
//! Functionality for loading the internal book representation from disk.
#![deny(missing_docs)]
use std::path::{Path, PathBuf};
use std::error::Error;
/// The object in charge of parsing the source directory into a usable
/// `Book` struct.
#[derive(Debug, Clone, PartialEq)]
pub struct Loader {
source_directory: PathBuf,
}
impl Loader {
/// Create a new loader which uses the provided source directory.
pub fn new<P: AsRef<Path>>(source_directory: P) -> Loader {
Loader { source_directory: source_directory.as_ref().to_path_buf() }
}
/// Parse the `SUMMARY.md` file.
pub fn parse_summary(&self) -> Result<Summary, Box<Error>> {
unimplemented!()
}
}
/// The parsed `SUMMARY.md`, specifying how the book should be laid out.
pub struct Summary;