-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Initial Book loader and summary parsing
#360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Is the loader's only purpose to look for and parse the summary? In that case I would make the name more like: Also, I feel like we might want the parsing method to not return immediately on the first syntax error. It might be more interesting to continue parsing to report multiple errors. I'm not sure how that is best handled, but since this exploratory work we can think a little more about this :) |
|
I was thinking the So in very rough pseudo-code: impl Loader {
...
pub fn load(&self) -> Result<Book> {
let summary = self.parse_summary().chain_err(|| "Invalid SUMMARY.md")?;
let mut book = Book::new();
for item in summary {
match item {
SummaryItem::Chapter(ch) => {
let chapter = self.load_chapter()?;
book.add_section(chapter);
}
SummaryItem::Separator => book.add_section(BookItem::Separator),
}
}
}
Ok(book)
}Another idea would be to accumulate errors in some |
…riting out the EBNF grammar
|
Oops... I think I accidentally did Anyways, I think the easiest thing for me to do to parse the summary is take advantage of @budziq, @azerupi, and @steveklabnik, what are your thoughts on taking that approach compared to the current implementation which recursively walks the |
c713166 to
bfc9112
Compare
…pdating the summary ergonomically
…sting section numbers
|
@azerupi, I've finally gotten things to the point where you can correctly parse a This PR is actually a lot smaller than it looks. There are only 362 executable lines of code in the Now I need to clean things up, deal with as many |
|
Nice! |
Book loader and summary parsingBook loader and summary parsing
After @budziq's comment I think I'll closing this PR and will put merge #360 and #371 into a single pull request. |

This is the first step towards #359, creating a
Loadertype which is in charge of reading the source directory, parsing theSUMMARY.md, and then constructing an internal representation of the book.This PR will refactor the existing summary parsing to return some
Summarystruct which indicates how the book is structured so that later steps can locate files and populate the book from disk.