From cb53c9f810ef2c3d34664eae6ff3374dd8a6c644 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 23 Oct 2022 11:43:53 +0300 Subject: fix: make unimplemented directives be a runtime error Sponsored-by: author --- src/directive/brokenlinks.rs | 2 +- src/directive/calendar.rs | 2 +- src/directive/format.rs | 2 +- src/directive/graph.rs | 2 +- src/directive/inline.rs | 2 +- src/directive/map.rs | 2 +- src/directive/pagestats.rs | 2 +- src/directive/sidebar.rs | 2 +- src/directive/toc.rs | 2 +- src/directive/traillink.rs | 2 +- src/error.rs | 3 +++ 11 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/directive/brokenlinks.rs b/src/directive/brokenlinks.rs index 3091be9..154ffed 100644 --- a/src/directive/brokenlinks.rs +++ b/src/directive/brokenlinks.rs @@ -16,7 +16,7 @@ impl BrokenLinks { } pub fn process(&self, _site: &Site, _meta: &mut PageMeta) -> Result { - Ok("FIXME:inline".into()) + Err(SiteError::UnimplementedDirective("brokenlinks".into())) } } diff --git a/src/directive/calendar.rs b/src/directive/calendar.rs index b24f39b..a11cc52 100644 --- a/src/directive/calendar.rs +++ b/src/directive/calendar.rs @@ -20,7 +20,7 @@ impl Calendar { pub const ALLOW_ANY_UNNAMED: bool = true; pub fn process(&self, _site: &Site, _meta: &mut PageMeta) -> Result { - Ok("FIXME:graph".into()) + Err(SiteError::UnimplementedDirective("calendar".into())) } } diff --git a/src/directive/format.rs b/src/directive/format.rs index a40c439..ee9c7ec 100644 --- a/src/directive/format.rs +++ b/src/directive/format.rs @@ -12,7 +12,7 @@ impl Format { pub const ALLOW_ANY_UNNAMED: bool = true; pub fn process(&self, _site: &Site, _meta: &mut PageMeta) -> Result { - Ok("FIXME:format".into()) + Err(SiteError::UnimplementedDirective("format".into())) } } diff --git a/src/directive/graph.rs b/src/directive/graph.rs index c8c7480..8234ed2 100644 --- a/src/directive/graph.rs +++ b/src/directive/graph.rs @@ -12,7 +12,7 @@ impl Graph { pub const ALLOW_ANY_UNNAMED: bool = true; pub fn process(&self, _site: &Site, _meta: &mut PageMeta) -> Result { - Ok("FIXME:graph".into()) + Err(SiteError::UnimplementedDirective("graph".into())) } } diff --git a/src/directive/inline.rs b/src/directive/inline.rs index 6bc0d1b..7bef13c 100644 --- a/src/directive/inline.rs +++ b/src/directive/inline.rs @@ -31,7 +31,7 @@ impl Inline { } pub fn process(&self, _site: &Site, _meta: &mut PageMeta) -> Result { - Ok("FIXME:inline".into()) + Err(SiteError::UnimplementedDirective("inline".into())) } } diff --git a/src/directive/map.rs b/src/directive/map.rs index 20bd222..960b339 100644 --- a/src/directive/map.rs +++ b/src/directive/map.rs @@ -12,7 +12,7 @@ impl Map { pub const ALLOW_ANY_UNNAMED: bool = true; pub fn process(&self, _site: &Site, _meta: &mut PageMeta) -> Result { - Ok("FIXME:map".into()) + Err(SiteError::UnimplementedDirective("map".into())) } } diff --git a/src/directive/pagestats.rs b/src/directive/pagestats.rs index 52e6997..89ba57e 100644 --- a/src/directive/pagestats.rs +++ b/src/directive/pagestats.rs @@ -16,7 +16,7 @@ impl PageStats { } pub fn process(&self, _site: &Site, _meta: &mut PageMeta) -> Result { - Ok("FIXME:inline".into()) + Err(SiteError::UnimplementedDirective("pagestat".into())) } } diff --git a/src/directive/sidebar.rs b/src/directive/sidebar.rs index b80bfe9..5148086 100644 --- a/src/directive/sidebar.rs +++ b/src/directive/sidebar.rs @@ -12,7 +12,7 @@ impl Sidebar { pub const ALLOW_ANY_UNNAMED: bool = true; pub fn process(&self, _site: &Site, _meta: &mut PageMeta) -> Result { - Ok("FIXME:sidebar".into()) + Err(SiteError::UnimplementedDirective("sidebar".into())) } } diff --git a/src/directive/toc.rs b/src/directive/toc.rs index cc94be4..af1bba9 100644 --- a/src/directive/toc.rs +++ b/src/directive/toc.rs @@ -16,7 +16,7 @@ impl Toc { } pub fn process(&self, _site: &Site, _meta: &mut PageMeta) -> Result { - Ok("FIXME:inline".into()) + Err(SiteError::UnimplementedDirective("toc".into())) } } diff --git a/src/directive/traillink.rs b/src/directive/traillink.rs index e79ce9e..9acfa6b 100644 --- a/src/directive/traillink.rs +++ b/src/directive/traillink.rs @@ -16,7 +16,7 @@ impl TrailLink { } pub fn process(&self, _site: &Site, _meta: &mut PageMeta) -> Result { - Ok("FIXME:traillink".into()) + Err(SiteError::UnimplementedDirective("traillink".into())) } } diff --git a/src/error.rs b/src/error.rs index 922f735..90046b2 100644 --- a/src/error.rs +++ b/src/error.rs @@ -88,6 +88,9 @@ pub enum SiteError { #[error("failed to parse wikitext, line {0}, column {1}: {2:?}")] WikitextSyntax(usize, usize, Vec), + + #[error("directive isn't implemented yet: {0}")] + UnimplementedDirective(String), } impl SiteError { -- cgit v1.2.1