From 51007c68b894a9adce76bd3016b005f324d57594 Mon Sep 17 00:00:00 2001 From: Trevor Bentley Date: Thu, 12 Jan 2023 21:02:59 +0100 Subject: [PATCH] cargo fmt --- src/generate.rs | 31 ++++++++++++++++--------------- src/settings.rs | 6 ++++-- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/generate.rs b/src/generate.rs index 7a86297..04a1e2b 100644 --- a/src/generate.rs +++ b/src/generate.rs @@ -132,8 +132,9 @@ impl GitsyGenerator { self.settings.outputs.path.display() )); let canonical_path = PathBuf::from(path); - let has_relative_dirs = canonical_path.ancestors().any(|x| x.file_name().is_none() && - x != Path::new("/")); + let has_relative_dirs = canonical_path + .ancestors() + .any(|x| x.file_name().is_none() && x != Path::new("/")); assert!( canonical_path.is_absolute(), "ERROR: write_rendered called with a relative path: {}", @@ -347,13 +348,14 @@ impl GitsyGenerator { if let Some(templ_file) = self.settings.templates.branches.as_deref() { let mut paged_ctx = local_ctx.clone(); paged_ctx.remove("branches"); - let pages = summary - .branches - .chunks(self.settings.paginate_branches()); + let pages = summary.branches.chunks(self.settings.paginate_branches()); let page_count = pages.len(); for (idx, page) in pages.enumerate() { - let pagination = - Pagination::new(idx + 1, page_count, &self.settings.outputs.branches(Some(&summary), None)); + let pagination = Pagination::new( + idx + 1, + page_count, + &self.settings.outputs.branches(Some(&summary), None), + ); paged_ctx.insert("page", &pagination.with_relative_paths()); paged_ctx.insert("branches", &page); match tera.render(templ_file, &paged_ctx) { @@ -389,9 +391,7 @@ impl GitsyGenerator { if let Some(templ_file) = self.settings.templates.tags.as_deref() { let mut paged_ctx = local_ctx.clone(); paged_ctx.remove("tags"); - let pages = summary - .tags - .chunks(self.settings.paginate_tags()); + let pages = summary.tags.chunks(self.settings.paginate_tags()); let page_count = pages.len(); for (idx, page) in pages.enumerate() { let pagination = @@ -437,13 +437,14 @@ impl GitsyGenerator { if let Some(templ_file) = self.settings.templates.history.as_deref() { let mut paged_ctx = local_ctx.clone(); paged_ctx.remove("history"); - let pages = summary - .history - .chunks(self.settings.paginate_history()); + let pages = summary.history.chunks(self.settings.paginate_history()); let page_count = pages.len(); for (idx, page) in pages.enumerate() { - let pagination = - Pagination::new(idx + 1, page_count, &self.settings.outputs.history(Some(&summary), None)); + let pagination = Pagination::new( + idx + 1, + page_count, + &self.settings.outputs.history(Some(&summary), None), + ); paged_ctx.insert("page", &pagination.with_relative_paths()); paged_ctx.insert("history", &page); match tera.render(templ_file, &paged_ctx) { diff --git a/src/settings.rs b/src/settings.rs index 320927b..9c11833 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -126,8 +126,10 @@ macro_rules! output_path_fn { _ => tmpl_str, }; let tmpl = PathBuf::from(tmpl_str); - let mut path = self.path.clone().canonicalize() - .expect(&format!("ERROR: unable to canonicalize output path: {}", self.path.display())); + let mut path = self.path.clone().canonicalize().expect(&format!( + "ERROR: unable to canonicalize output path: {}", + self.path.display() + )); path.push(tmpl); match $is_dir { true => {