Struct shtola::Shtola

source ·
pub struct Shtola { /* private fields */ }
Expand description

The main library struct.

Implementations§

source§

impl Shtola

source

pub fn new() -> Shtola

Creates a new empty Shtola struct.

source

pub fn ignores(&mut self, vec: &mut Vec<String>)

Appends glob-matched paths to the ignore list. If a glob path matches, the file is excluded from the IR.

use shtola::Shtola;

let mut m = Shtola::new();
m.ignores(&mut vec!["node_modules".into(), "vendor/bundle/".into()])
source

pub fn source_ignores(&mut self, path: &Path) -> Result<(), Error>

Reads paths to ignore from a file. This file needs to have one single path per line. The most common use for this would be to read your project’s .gitignore.

use std::path::Path;
use shtola::Shtola;

let mut m = Shtola::new();
m.source_ignores(Path::new(".gitignore"));
source

pub fn source<T: Into<PathBuf>>(&mut self, path: T)

Sets the source directory to read from. Should be relative.

source

pub fn destination<T: Into<PathBuf> + Clone>(&mut self, path: T)

Sets the destination path to write to. This directory will be created on calling this function if it doesn’t exist.

source

pub fn clean(&mut self, b: bool)

Sets whether the destination directory should be removed before building. The removal only happens once calling Shtola::build. Default is false.

source

pub fn frontmatter(&mut self, b: bool)

Sets whether frontmatter should be parsed. Default is true.

source

pub fn register(&mut self, func: Box<dyn Fn(RefIR<'_>)>)

Registers a new plugin function in its middleware chain.

use shtola::{Shtola, RefIR};

let mut m = Shtola::new();
let plugin = Box::new(|mut ir: RefIR| ());
m.register(plugin);
source

pub fn build(&mut self) -> Result<IR, Error>

Performs the build process. This does a couple of things:

  • If Shtola::clean is set, removes and recreates the destination directory
  • Reads from the source file and ignores files as it’s been configured
  • Parses front matter for the remaining files
  • Runs the middleware chain, executing all plugins
  • Writes the result back to the destination directory

Auto Trait Implementations§

§

impl !RefUnwindSafe for Shtola

§

impl !Send for Shtola

§

impl !Sync for Shtola

§

impl Unpin for Shtola

§

impl !UnwindSafe for Shtola

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V