makeover-webview 0.116.0

The webview renderer for makeover-layout. Emits CSS, and is the one renderer that needs no palette: var() is the late binding, so resolution stays with the browser. With the build feature, writes a consumer's generated frontend files and checks the hand-written ones against them.
Documentation
//! Assertions the module tests share, so a missing rule fails one way.

/// The declarations of the first rule written `{selector} {`.
///
/// # Panics
/// When the sheet has no such rule, naming the selector.
pub(crate) fn rule_body<'a>(css: &'a str, selector: &str) -> &'a str {
    let open = format!("{selector} {{");
    let at = css
        .find(&open)
        .unwrap_or_else(|| panic!("no rule for {selector}"));
    let rest = &css[at + open.len()..];
    &rest[..rest
        .find('}')
        .unwrap_or_else(|| panic!("the rule for {selector} does not close"))]
}

/// Every class a module's markup can carry is selected by its sheet.
pub(crate) fn assert_every_class_has_rule(css: &str, names: &[&str]) {
    for name in names {
        assert!(css.contains(&format!(".{name}")), "{name} has no rule");
    }
}

/// An empty directory for one test, keyed by process id so a parallel run
/// does not collide.
#[cfg(feature = "build")]
pub(crate) fn scratch(name: &str) -> std::path::PathBuf {
    let dir = std::env::temp_dir().join(format!("makeover-webview-{}-{name}", std::process::id()));
    let _ = std::fs::remove_dir_all(&dir);
    std::fs::create_dir_all(&dir).expect("create scratch");
    dir
}