diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-10-16 11:20:42 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-10-16 11:20:42 +0300 |
commit | 90103712b62feec5788acff3865b1a587d780c21 (patch) | |
tree | e123fe9ee4c41229b6e7a7164503b3242cf48336 | |
parent | ef1a4c9107ccd95e8381097f0edc6d5174afa1c4 (diff) | |
download | riki-90103712b62feec5788acff3865b1a587d780c21.tar.gz |
fix: formatting
Sponsored-by: author
-rw-r--r-- | src/directive/meta.rs | 5 | ||||
-rw-r--r-- | src/directive/mod.rs | 44 | ||||
-rw-r--r-- | src/lib.rs | 10 | ||||
-rw-r--r-- | src/name.rs | 10 | ||||
-rw-r--r-- | src/pagespec.rs | 3 | ||||
-rw-r--r-- | src/time.rs | 12 | ||||
-rw-r--r-- | src/token.rs | 6 |
7 files changed, 65 insertions, 25 deletions
diff --git a/src/directive/meta.rs b/src/directive/meta.rs index ddbdeaa..490ffb1 100644 --- a/src/directive/meta.rs +++ b/src/directive/meta.rs @@ -1,8 +1,8 @@ use crate::error::SiteError; use crate::page::PageMeta; use crate::site::Site; -use crate::wikitext::ParsedDirective; use crate::time::parse_timestamp; +use crate::wikitext::ParsedDirective; #[derive(Default, Debug, Eq, PartialEq)] pub struct Meta { @@ -49,5 +49,4 @@ impl From<&ParsedDirective> for Meta { } #[cfg(test)] -mod test { -} +mod test {} diff --git a/src/directive/mod.rs b/src/directive/mod.rs index 261de36..89b5b8a 100644 --- a/src/directive/mod.rs +++ b/src/directive/mod.rs @@ -36,7 +36,7 @@ impl TryFrom<ParsedDirective> for Directive { fn try_from(p: ParsedDirective) -> Result<Self, Self::Error> { Self::try_from(&p) - } + } } impl TryFrom<&ParsedDirective> for Directive { @@ -66,15 +66,30 @@ impl TryFrom<&ParsedDirective> for Directive { } "brokenlinks" => { - Self::check_args(p, BrokenLinks::REQUIRED, BrokenLinks::ALLOWED, BrokenLinks::ALLOW_ANY_UNNAMED)?; + Self::check_args( + p, + BrokenLinks::REQUIRED, + BrokenLinks::ALLOWED, + BrokenLinks::ALLOW_ANY_UNNAMED, + )?; Directive::BrokenLinks(BrokenLinks::from(p)) } "calendar" => { - Self::check_args(p, Calendar::REQUIRED, Calendar::ALLOWED, Calendar::ALLOW_ANY_UNNAMED)?; + Self::check_args( + p, + Calendar::REQUIRED, + Calendar::ALLOWED, + Calendar::ALLOW_ANY_UNNAMED, + )?; Directive::Calendar(Calendar::from(p)) } "format" => { - Self::check_args(p, Format::REQUIRED, Format::ALLOWED, Format::ALLOW_ANY_UNNAMED)?; + Self::check_args( + p, + Format::REQUIRED, + Format::ALLOWED, + Format::ALLOW_ANY_UNNAMED, + )?; Directive::Format(Format::from(p)) } "graph" => { @@ -112,11 +127,21 @@ impl TryFrom<&ParsedDirective> for Directive { Directive::PageStats(PageStats::from(p)) } "shortcut" => { - Self::check_args(p, Shortcut::REQUIRED, Shortcut::ALLOWED, Shortcut::ALLOW_ANY_UNNAMED)?; + Self::check_args( + p, + Shortcut::REQUIRED, + Shortcut::ALLOWED, + Shortcut::ALLOW_ANY_UNNAMED, + )?; Directive::Shortcut(Shortcut::from(p)) } "sidebar" => { - Self::check_args(p, Sidebar::REQUIRED, Sidebar::ALLOWED, Sidebar::ALLOW_ANY_UNNAMED)?; + Self::check_args( + p, + Sidebar::REQUIRED, + Sidebar::ALLOWED, + Sidebar::ALLOW_ANY_UNNAMED, + )?; Directive::Sidebar(Sidebar::from(p)) } "tag" => { @@ -132,7 +157,12 @@ impl TryFrom<&ParsedDirective> for Directive { Directive::Toc(Toc::from(p)) } "traillink" => { - Self::check_args(p, TrailLink::REQUIRED, TrailLink::ALLOWED, TrailLink::ALLOW_ANY_UNNAMED)?; + Self::check_args( + p, + TrailLink::REQUIRED, + TrailLink::ALLOWED, + TrailLink::ALLOW_ANY_UNNAMED, + )?; Directive::TrailLink(TrailLink::from(p)) } _ => return Err(SiteError::UnknownDirective(p.name().into())), @@ -7,17 +7,17 @@ //! little slow. This care implements a subset of the functionality of //! ikiwiki in Rust, for speed. -pub mod srcdir; -pub mod name; pub mod directive; pub mod error; +pub mod git; pub mod html; +pub mod name; pub mod page; +pub mod pagespec; pub mod parser; pub mod site; +pub mod srcdir; +pub mod time; pub mod token; -pub mod git; pub mod util; -pub mod time; pub mod wikitext; -pub mod pagespec; diff --git a/src/name.rs b/src/name.rs index f4d1a2f..2388e4b 100644 --- a/src/name.rs +++ b/src/name.rs @@ -17,7 +17,13 @@ pub struct Name { } impl Name { - fn new(is_wikitext: bool, src: PathBuf, dest: PathBuf, page: PathBuf, mtime: SystemTime) -> Self { + fn new( + is_wikitext: bool, + src: PathBuf, + dest: PathBuf, + page: PathBuf, + mtime: SystemTime, + ) -> Self { trace!( "Name::new: is_wikitext={} src={} dest={} page={}", is_wikitext, @@ -134,7 +140,7 @@ impl NameBuilder { Name::new(true, src, dest, page, mtime) } - pub fn file(&self, path: &Path, mtime: SystemTime) -> Name { + pub fn file(&self, path: &Path, mtime: SystemTime) -> Name { assert!(path.starts_with(&self.srcdir)); let src = path.into(); let relative = make_path_relative_to(&self.srcdir, path); diff --git a/src/pagespec.rs b/src/pagespec.rs index 07aa5c5..6a4b35d 100644 --- a/src/pagespec.rs +++ b/src/pagespec.rs @@ -34,7 +34,8 @@ impl PageSpec { pub fn matches(&self, page_path: &Path) -> bool { trace!( "PageSpec::matches: container={} page_path={}", - self.container.display(), page_path.display() + self.container.display(), + page_path.display() ); assert!(page_path.is_absolute()); if let Ok(path) = page_path.strip_prefix(&self.container) { diff --git a/src/time.rs b/src/time.rs index 2728701..dce3ecc 100644 --- a/src/time.rs +++ b/src/time.rs @@ -29,18 +29,22 @@ fn parse(timestamp: &str) -> Result<OffsetDateTime, SiteError> { format_description!("[year]-[month]-[day] [hour]:[minute]:[second]"); const SIMPLIFIED_ISO9601_MIN: &[FormatItem<'static>] = format_description!("[year]-[month]-[day] [hour]:[minute]"); - const SIMPLIFIED_ISO9601_TZ: &[FormatItem<'static>] = - format_description!("[year]-[month]-[day] [hour]:[minute]:[second] [offset_hour][offset_minute]"); + const SIMPLIFIED_ISO9601_TZ: &[FormatItem<'static>] = format_description!( + "[year]-[month]-[day] [hour]:[minute]:[second] [offset_hour][offset_minute]" + ); const SIMPLIFIED_ISO9601_MIN_TZ: &[FormatItem<'static>] = format_description!("[year]-[month]-[day] [hour]:[minute] [offset_hour][offset_minute]"); if let Ok(t) = parse_one_time_format(timestamp, "simplified", SIMPLIFIED_ISO9601) { Ok(t) - } else if let Ok(t) = parse_one_time_format(timestamp, "simplified-min", SIMPLIFIED_ISO9601_MIN) { + } else if let Ok(t) = parse_one_time_format(timestamp, "simplified-min", SIMPLIFIED_ISO9601_MIN) + { Ok(t) } else if let Ok(t) = parse_one_time_format(timestamp, "simplified-tz", SIMPLIFIED_ISO9601_TZ) { Ok(t) - } else if let Ok(t) = parse_one_time_format(timestamp, "simplified-tz", SIMPLIFIED_ISO9601_MIN_TZ) { + } else if let Ok(t) = + parse_one_time_format(timestamp, "simplified-tz", SIMPLIFIED_ISO9601_MIN_TZ) + { Ok(t) } else if let Ok(t) = parse_one_time_format(timestamp, "ISO8601", &Iso8601::PARSING) { Ok(t) diff --git a/src/token.rs b/src/token.rs index 0190edc..f6fb92c 100644 --- a/src/token.rs +++ b/src/token.rs @@ -106,10 +106,10 @@ impl<'a> TokenParser<'a> { } fn regex(&mut self, pattern: &Regex) -> Option<String> { -// trace!("matching regex {}", pattern.as_str()); + // trace!("matching regex {}", pattern.as_str()); if let Some(m) = pattern.find(self.input) { if m.start() == 0 { -// trace!("match at beginning"); + // trace!("match at beginning"); let captures = pattern.captures(self.input).unwrap(); let m = if let Some(value) = captures.name("value") { self.input = &self.input[m.end()..]; @@ -121,7 +121,7 @@ impl<'a> TokenParser<'a> { return Some(m.as_str().to_string()); } } -// trace!("no match at beginning"); + // trace!("no match at beginning"); None } } |