pub mod distill;
pub mod interp;
pub mod model;
pub mod report;
pub mod value;
pub use report::{
INVALID_ENUM, TYPE_MISMATCH, UNKNOWN_KEY, lint_manifest_text, manifest_schema_root,
to_diagnostic, validate_standalone_yaml,
};
use std::sync::OnceLock;
use model::QuartoSchema;
const EMBEDDED_GZ: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/quarto-schema.json.gz"));
pub fn schema() -> &'static QuartoSchema {
use std::io::Read;
static SCHEMA: OnceLock<QuartoSchema> = OnceLock::new();
SCHEMA.get_or_init(|| {
let mut json = String::new();
flate2::read::GzDecoder::new(EMBEDDED_GZ)
.read_to_string(&mut json)
.expect("embedded Quarto schema must gunzip");
serde_json::from_str(&json).expect("embedded distilled Quarto schema must deserialize")
})
}
#[cfg(test)]
mod tests {
use super::*;
const SOURCE: &str = include_str!("../../assets/quarto-schema/.panache-source");
#[test]
fn embedded_schema_deserializes_and_roots_resolve() {
let s = schema();
assert!(
s.defs.contains_key(&s.roots.frontmatter),
"frontmatter root must resolve"
);
assert!(
s.defs.contains_key(&s.roots.project),
"project root must resolve"
);
assert!(s.defs.len() > 100, "expected the full definition set");
}
#[test]
fn version_matches_panache_source() {
let tag = SOURCE
.lines()
.find_map(|l| l.strip_prefix("tag="))
.expect("tag= in .panache-source");
assert_eq!(schema().version, tag, "schema version drifted from pin");
}
}