summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/directive/mod.rs9
-rw-r--r--src/directive/toc.rs27
2 files changed, 36 insertions, 0 deletions
diff --git a/src/directive/mod.rs b/src/directive/mod.rs
index 59c352c..0767c9d 100644
--- a/src/directive/mod.rs
+++ b/src/directive/mod.rs
@@ -17,6 +17,7 @@ pub enum Directive {
Inline(Inline),
PageStats(PageStats),
Tag(Tag),
+ Toc(Toc),
}
impl TryFrom<ParsedDirective> for Directive {
@@ -64,6 +65,10 @@ impl TryFrom<ParsedDirective> for Directive {
Self::check_args(&p, Tag::REQUIRED, Tag::ALLOWED, Tag::ALLOW_ANY_UNNAMED)?;
Directive::Tag(Tag::from(p))
}
+ "toc" => {
+ Self::check_args(&p, Toc::REQUIRED, Toc::ALLOWED, Toc::ALLOW_ANY_UNNAMED)?;
+ Directive::Toc(Toc::from(p))
+ }
_ => return Err(SiteError::UnknownDirective(p.name().into())),
};
Ok(d)
@@ -115,6 +120,7 @@ impl Directive {
Self::Meta(x) => x.process(site, meta),
Self::PageStats(x) => x.process(site, meta),
Self::Tag(x) => x.process(site, meta),
+ Self::Toc(x) => x.process(site, meta),
}
}
}
@@ -133,3 +139,6 @@ pub use pagestats::PageStats;
mod tag;
use tag::Tag;
+
+mod toc;
+use toc::Toc;
diff --git a/src/directive/toc.rs b/src/directive/toc.rs
new file mode 100644
index 0000000..6db46d2
--- /dev/null
+++ b/src/directive/toc.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 Toc {}
+
+impl Toc {
+ pub const REQUIRED: &'static [&'static str] = &[];
+ pub const ALLOWED: &'static [&'static str] = &["levels"];
+ 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 Toc {
+ fn from(_p: ParsedDirective) -> Self {
+ Self::new()
+ }
+}