mini-docs 0.3.6

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

use mini_docs::Builder;

/// A child template that walks before its parent, alphabetically, must still load —
/// Tera's `add_raw_template` (singular, one call per file) validates the `{% extends %}`
/// chain after every individual insert, so a child inserted before its parent exists
/// fails with a missing-parent error even though both files are present on disk.
/// `add_raw_templates` (bulk) inserts everything first and validates once, which is
/// what `load_templates` must use.
#[test]
fn child_template_alphabetically_before_parent_still_loads() {
    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("page.md"), "# Page\n").expect("write page.md");

    // "article.html" sorts before "base.html" — exactly the ordering that breaks a
    // one-template-at-a-time load.
    fs::write(
        templates.path().join("article.html"),
        "{% extends \"base.html\" %}{% block content %}{{ page.content | safe }}{% endblock %}",
    )
    .expect("write article.html");
    fs::write(
        templates.path().join("base.html"),
        "<body>{% block content %}{% endblock %}</body>",
    )
    .expect("write base.html");

    let result = Builder::new(input.path())
        .templates(templates.path())
        .output(output.path())
        .default_template("article.html")
        .build();

    assert!(
        result.is_ok(),
        "build should succeed regardless of template file order: {result:?}"
    );
    assert!(output.path().join("page.html").is_file());
}