mini-docs 0.3.7

A minimal, secure build-time Markdown to HTML generator for the mini-* family.
Documentation
use std::fs;

use mini_docs::Builder;

/// Two nested `.md` files must produce a mirrored `.html` file at the same relative
/// path in the output directory — existence and path shape, not content (M0.1).
#[test]
fn build_mirrors_nested_input_structure_as_html() {
    let input = tempfile::tempdir().expect("create input tempdir");
    let templates = tempfile::tempdir().expect("create templates tempdir");
    let output = tempfile::tempdir().expect("create output tempdir");

    fs::write(input.path().join("index.md"), "# Home").expect("write index.md");
    fs::create_dir_all(input.path().join("guide")).expect("create guide dir");
    fs::write(input.path().join("guide").join("setup.md"), "# Setup").expect("write setup.md");
    fs::write(
        templates.path().join("page.html"),
        "{{ page.content | safe }}",
    )
    .expect("write page.html");

    Builder::new(input.path())
        .templates(templates.path())
        .output(output.path())
        .default_template("page.html")
        .build()
        .expect("build should succeed");

    assert!(output.path().join("index.html").is_file());
    assert!(output.path().join("guide").join("setup.html").is_file());
}

/// A directory with no `.md` files produces an empty output directory tree, not an error.
#[test]
fn build_with_no_markdown_files_writes_nothing() {
    let input = tempfile::tempdir().expect("create input tempdir");
    let templates = tempfile::tempdir().expect("create templates tempdir");
    let output = tempfile::tempdir().expect("create output tempdir");

    Builder::new(input.path())
        .templates(templates.path())
        .output(output.path())
        .build()
        .expect("build should succeed");

    let entries: Vec<_> = fs::read_dir(output.path())
        .expect("read output dir")
        .collect();
    assert!(entries.is_empty());
}