From 186176b499dd7d1db6089bf8f666e3770162d782 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 5 Aug 2022 22:53:02 +0300 Subject: feat: placeholder for brokenlinks directive Sponsored-by: author --- src/directive/brokenlinks.rs | 27 +++++++++++++++++++++++++++ src/directive/mod.rs | 26 +++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 src/directive/brokenlinks.rs diff --git a/src/directive/brokenlinks.rs b/src/directive/brokenlinks.rs new file mode 100644 index 0000000..c6364a4 --- /dev/null +++ b/src/directive/brokenlinks.rs @@ -0,0 +1,27 @@ +use crate::error::SiteError; +use crate::page::PageMeta; +use crate::site::Site; +use crate::wikitext::ParsedDirective; + +#[derive(Debug, Default, Eq, PartialEq)] +pub struct BrokenLinks {} + +impl BrokenLinks { + pub const REQUIRED: &'static [&'static str] = &["pages"]; + pub const ALLOWED: &'static [&'static str] = &[]; + pub const ALLOW_ANY_UNNAMED: bool = false; + + pub fn new() -> Self { + Self::default() + } + + pub fn process(&self, _site: &Site, _meta: &mut PageMeta) -> Result { + Ok("FIXME:inline".into()) + } +} + +impl From for BrokenLinks { + fn from(_p: ParsedDirective) -> Self { + Self::new() + } +} diff --git a/src/directive/mod.rs b/src/directive/mod.rs index 0767c9d..16d55c1 100644 --- a/src/directive/mod.rs +++ b/src/directive/mod.rs @@ -12,9 +12,10 @@ pub enum Directive { QuotedArg, MultilineArg, - Meta(Meta), + BrokenLinks(BrokenLinks), Img(Img), Inline(Inline), + Meta(Meta), PageStats(PageStats), Tag(Tag), Toc(Toc), @@ -45,12 +46,22 @@ impl TryFrom for Directive { Self::check_args(&p, &["yo"], &["then", "else"], false)?; Directive::MultilineArg } + + "brokenlinks" => { + Self::check_args(&p, BrokenLinks::REQUIRED, BrokenLinks::ALLOWED, BrokenLinks::ALLOW_ANY_UNNAMED)?; + Directive::BrokenLinks(BrokenLinks::from(p)) + } "img" => { Self::check_args(&p, Img::REQUIRED, Img::ALLOWED, Img::ALLOW_ANY_UNNAMED)?; Directive::Img(Img::from(p)) } "inline" => { - Self::check_args(&p, Inline::REQUIRED, Inline::ALLOWED, Inline::ALLOW_ANY_UNNAMED)?; + Self::check_args( + &p, + Inline::REQUIRED, + Inline::ALLOWED, + Inline::ALLOW_ANY_UNNAMED, + )?; Directive::Inline(Inline::from(p)) } "meta" => { @@ -58,7 +69,12 @@ impl TryFrom for Directive { Directive::Meta(Meta::from(p)) } "pagestats" => { - Self::check_args(&p, PageStats::REQUIRED, PageStats::ALLOWED, PageStats::ALLOW_ANY_UNNAMED)?; + Self::check_args( + &p, + PageStats::REQUIRED, + PageStats::ALLOWED, + PageStats::ALLOW_ANY_UNNAMED, + )?; Directive::PageStats(PageStats::from(p)) } "tag" => { @@ -115,6 +131,7 @@ impl Directive { | Self::MultilineArg => { panic!("directive {:?} may only be used in parsing tests", self) } + Self::BrokenLinks(x) => x.process(site, meta), Self::Img(x) => x.process(site, meta), Self::Inline(x) => x.process(site, meta), Self::Meta(x) => x.process(site, meta), @@ -125,6 +142,9 @@ impl Directive { } } +mod brokenlinks; +use brokenlinks::BrokenLinks; + mod meta; use meta::Meta; -- cgit v1.2.1