Skip to main content

Builder

Struct Builder 

Source
pub struct Builder { /* private fields */ }
Expand description

Configures and runs a Markdown → HTML build.

All directories are explicit — there are no ambient globals. templates_dir and output_dir must be set via Builder::templates and Builder::output before Builder::build is called.

Implementations§

Source§

impl Builder

Source

pub fn new(input_dir: impl Into<PathBuf>) -> Self

Starts a builder rooted at input_dir, the directory of .md source files.

Source

pub fn templates(self, dir: impl Into<PathBuf>) -> Self

Sets the directory of Tera templates.

Source

pub fn output(self, dir: impl Into<PathBuf>) -> Self

Sets the output directory that mirrors input_dir, one .html file per .md file.

Source

pub fn default_template(self, name: impl Into<String>) -> Self

Sets the template used for pages that have no template: frontmatter key.

Sets the base path used to rewrite [x](x.md)-style links to clean URLs.

Source

pub fn data_json(self, name: impl Into<String>) -> Self

Opts into writing a data.json index of every non-draft page to name (relative to output_dir) on every Builder::build — for a search index, table of contents, or “recent items” list to consume.

Each entry has id, title, date, updated, version, url, summary, tags, and pinned — the frontmatter-sourced fields default to "" ([] for tags, false for pinned) when absent. A page with draft: true in its frontmatter is excluded from both this index and the HTML build output.

Off by default; explicit over implicit, like the rest of Builder’s optional features. Regenerated by both build() and crate::Watcher::tick (whenever a .md file was added, removed, or modified — a template-only change never alters index content, so it’s skipped then).

Source

pub fn watch(&self) -> Result<Watcher<'_>, DocError>

Starts a watch session: an initial full Builder::build, then incremental rebuilds via crate::Watcher::tick whenever a .md or template file’s mtime changes. See Builder::build for the same required-configuration panics.

Source

pub fn build(&self) -> Result<(), DocError>

Walks input_dir and (re-)renders each non-draft .md file whose output isn’t already up to date, writing the result under output_dir. If Builder::data_json is set, also (re-)writes the page index.

A page’s HTML is skipped when output_path already exists and is at least as new as both the .md file and every template file (the render cache — cache::is_up_to_date internally). This makes repeat build() calls incremental for free: no in-memory state, no cache to invalidate — the filesystem’s own mtimes decide.

§Panics

Panics if .templates() or .output() were not called first — this is a programmer error (missing required configuration), not a runtime data failure.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.