-
Notifications
You must be signed in to change notification settings - Fork 102
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
Split build() for readability #369
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While there are some things that could improved in this, I think its fine to hold off because we'll need to revisit it as part of #368.
// compile SASS along the way | ||
{ | ||
debug!("Copying remaining assets"); | ||
fn parse_files(page_files: &files::Files, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parse_files
-> parse_pages
let doc_html = doc.render(&globals, &parser, &layouts, &mut layouts_cache) | ||
.chain_err(|| format!("Failed to render for {:?}", doc.file_path))?; | ||
files::write_document_file(doc_html, dest.join(doc.file_path))?; | ||
fn construct_page_files(source: &Path, config: &Config) -> Result<files::Files> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
construct_page_files
-> find_pages
trace!("Generating other documents"); | ||
for mut doc in documents { | ||
trace!("Generating {}", doc.url_path); | ||
fn process_included_drafts(config: &Config, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this would be split into find_draft_files
and parse_drafts
. Not sure how clean that'd be at the moment.
Ok(()) | ||
} | ||
|
||
fn sort_documents_by_date(posts: &mut Vec<Document>, config: &Config) -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this takes in the config, it seems like this could just skip putting the sort policy in the function name because that will eventually be configurable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, what should I call it, as the code is really doing sorting by date ^^'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sort_pages
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! I misread, I though you wanted me to drop the "sort" word. You were talking "sort policy" ^^'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see how that can be missed and be confusing :)
Ok(()) | ||
} | ||
|
||
fn generate_posts(posts: &mut Vec<Document>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice to find ways to refactor this so the code can be shared between "other" and "posts".
|
||
let default_front = config.posts.default.clone().set_draft(true); | ||
fn generate_other_docs(posts: Vec<Document>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confusingly, I'd call this generate_pages
. That is the name (so far) for the default collection.
I'll do the renaming tonight :) |
I've split cobalt.rs build() function to make it easier to read