diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-08-06 07:32:33 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-08-06 07:32:33 +0300 |
commit | 60a74ba1166ca1166c20b7f82f4a2e818f06f72d (patch) | |
tree | 89d456a77ea5094bfed52325a0709d40e123423b | |
parent | 10c90f514772cc21abf58aa2ea03f2d8f86bdaca (diff) | |
download | riki-60a74ba1166ca1166c20b7f82f4a2e818f06f72d.tar.gz |
feat: add placeholder for directive shortcut
Sponsored-by: author
-rw-r--r-- | src/directive/mod.rs | 9 | ||||
-rw-r--r-- | src/directive/shortcut.rs | 27 |
2 files changed, 36 insertions, 0 deletions
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<ParsedDirective> 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<String, SiteError> { + Ok("FIXME:inline".into()) + } +} + +impl From<ParsedDirective> for Shortcut { + fn from(_p: ParsedDirective) -> Self { + Self::new() + } +} |