added a parse_summary() method to the Loader

This commit is contained in:
Michael Bryan 2017-06-24 23:42:28 +08:00
parent 1e60d6b53c
commit c68a29c3c5
2 changed files with 21 additions and 4 deletions

View File

@ -4,6 +4,12 @@
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::error::Error; use std::error::Error;
use std::fs::File;
use std::io::Read;
mod summary;
pub use self::summary::Summary;
/// The object in charge of parsing the source directory into a usable /// The object in charge of parsing the source directory into a usable
@ -21,9 +27,11 @@ impl Loader {
/// Parse the `SUMMARY.md` file. /// Parse the `SUMMARY.md` file.
pub fn parse_summary(&self) -> Result<Summary, Box<Error>> { pub fn parse_summary(&self) -> Result<Summary, Box<Error>> {
unimplemented!() let path = self.source_directory.join("SUMMARY.md");
}
}
/// The parsed `SUMMARY.md`, specifying how the book should be laid out. let mut summary_content = String::new();
pub struct Summary; File::open(&path)?.read_to_string(&mut summary_content)?;
summary::parse_summary(&summary_content)
}
}

9
src/loader/summary.rs Normal file
View File

@ -0,0 +1,9 @@
use std::error::Error;
use pulldown_cmark;
/// The parsed `SUMMARY.md`, specifying how the book should be laid out.
pub struct Summary;
pub fn parse_summary(summary: &str) -> Result<Summary, Box<Error>> {
unimplemented!()
}