From 60a74ba1166ca1166c20b7f82f4a2e818f06f72d Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 6 Aug 2022 07:32:33 +0300 Subject: feat: add placeholder for directive shortcut Sponsored-by: author --- src/directive/mod.rs | 9 +++++++++ src/directive/shortcut.rs | 27 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/directive/shortcut.rs diff --git a/src/directive/mod.rs b/src/directive/mod.rs index 16d55c1..ee96bfc 100644 --- a/src/directive/mod.rs +++ b/src/directive/mod.rs @@ -17,6 +17,7 @@ pub enum Directive { Inline(Inline), Meta(Meta), PageStats(PageStats), + Shortcut(Shortcut), Tag(Tag), Toc(Toc), } @@ -77,6 +78,10 @@ impl TryFrom for Directive { )?; Directive::PageStats(PageStats::from(p)) } + "shortcut" => { + Self::check_args(&p, Shortcut::REQUIRED, Shortcut::ALLOWED, Shortcut::ALLOW_ANY_UNNAMED)?; + Directive::Shortcut(Shortcut::from(p)) + } "tag" => { Self::check_args(&p, Tag::REQUIRED, Tag::ALLOWED, Tag::ALLOW_ANY_UNNAMED)?; Directive::Tag(Tag::from(p)) @@ -136,6 +141,7 @@ impl Directive { Self::Inline(x) => x.process(site, meta), Self::Meta(x) => x.process(site, meta), Self::PageStats(x) => x.process(site, meta), + Self::Shortcut(x) => x.process(site, meta), Self::Tag(x) => x.process(site, meta), Self::Toc(x) => x.process(site, meta), } @@ -157,6 +163,9 @@ pub use inline::Inline; mod pagestats; pub use pagestats::PageStats; +mod shortcut; +pub use shortcut::Shortcut; + mod tag; use tag::Tag; diff --git a/src/directive/shortcut.rs b/src/directive/shortcut.rs new file mode 100644 index 0000000..03fd648 --- /dev/null +++ b/src/directive/shortcut.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 Shortcut {} + +impl Shortcut { + pub const REQUIRED: &'static [&'static str] = &["desc", "name", "url"]; + pub const ALLOWED: &'static [&'static str] = &[]; + pub const ALLOW_ANY_UNNAMED: bool = true; + + pub fn new() -> Self { + Self::default() + } + + pub fn process(&self, _site: &Site, _meta: &mut PageMeta) -> Result { + Ok("FIXME:inline".into()) + } +} + +impl From for Shortcut { + fn from(_p: ParsedDirective) -> Self { + Self::new() + } +} -- cgit v1.2.1