From ea1a5a1e9c837816a0c89793e13f032f2cba50e1 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 5 Aug 2022 22:28:58 +0300 Subject: feat: add placeholder for the inline directive Sponsored-by: author --- src/directive/inline.rs | 38 ++++++++++++++++++++++++++++++++++++++ src/directive/mod.rs | 9 +++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/directive/inline.rs diff --git a/src/directive/inline.rs b/src/directive/inline.rs new file mode 100644 index 0000000..efaf7ee --- /dev/null +++ b/src/directive/inline.rs @@ -0,0 +1,38 @@ +use crate::error::SiteError; +use crate::page::PageMeta; +use crate::site::Site; +use crate::wikitext::ParsedDirective; + +#[derive(Debug, Default, Eq, PartialEq)] +pub struct Inline {} + +impl Inline { + pub const REQUIRED: &'static [&'static str] = &["pages"]; + pub const ALLOWED: &'static [&'static str] = &[ + "actions", + "archive", + "description", + "feedlimit", + "feeds", + "feedshow", + "limit", + "sort", + "template", + "trail", + ]; + 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 Inline { + fn from(_p: ParsedDirective) -> Self { + Inline::new() + } +} diff --git a/src/directive/mod.rs b/src/directive/mod.rs index 38fb0d3..a97f3a5 100644 --- a/src/directive/mod.rs +++ b/src/directive/mod.rs @@ -14,6 +14,7 @@ pub enum Directive { Meta(Meta), Img(Img), + Inline(Inline), Tag(Tag), } @@ -46,6 +47,10 @@ impl TryFrom for Directive { 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)?; + Directive::Inline(Inline::from(p)) + } "meta" => { Self::check_args(&p, Meta::REQUIRED, Meta::ALLOWED, Meta::ALLOW_ANY_UNNAMED)?; Directive::Meta(Meta::from(p)) @@ -101,6 +106,7 @@ impl Directive { panic!("directive {:?} may only be used in parsing tests", self) } Self::Img(x) => x.process(site, meta), + Self::Inline(x) => x.process(site, meta), Self::Meta(x) => x.process(site, meta), Self::Tag(x) => x.process(site, meta), } @@ -113,5 +119,8 @@ use meta::Meta; mod img; pub use img::Img; +mod inline; +pub use inline::Inline; + mod tag; use tag::Tag; -- cgit v1.2.1