From c68a29c3c5565751dfeddd7065bf89043cb6e2ae Mon Sep 17 00:00:00 2001 From: Michael Bryan Date: Sat, 24 Jun 2017 23:42:28 +0800 Subject: [PATCH] added a parse_summary() method to the Loader --- src/loader/mod.rs | 16 ++++++++++++---- src/loader/summary.rs | 9 +++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 src/loader/summary.rs diff --git a/src/loader/mod.rs b/src/loader/mod.rs index eff46441..63d16f86 100644 --- a/src/loader/mod.rs +++ b/src/loader/mod.rs @@ -4,6 +4,12 @@ use std::path::{Path, PathBuf}; 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 @@ -21,9 +27,11 @@ impl Loader { /// Parse the `SUMMARY.md` file. pub fn parse_summary(&self) -> Result> { - unimplemented!() + let path = self.source_directory.join("SUMMARY.md"); + + let mut summary_content = String::new(); + File::open(&path)?.read_to_string(&mut summary_content)?; + + summary::parse_summary(&summary_content) } } - -/// The parsed `SUMMARY.md`, specifying how the book should be laid out. -pub struct Summary; \ No newline at end of file diff --git a/src/loader/summary.rs b/src/loader/summary.rs new file mode 100644 index 00000000..52a1d7d5 --- /dev/null +++ b/src/loader/summary.rs @@ -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> { + unimplemented!() +} \ No newline at end of file