pub fn to_scene_json(
src: &str,
project_dir: Option<&Path>,
page: usize,
flags: &CliPolicyFlags,
data: Option<&DataContext>,
) -> Result<SceneArtifact, RenderCmdErr>Expand description
Parse src, validate it with the merged diagnostic policy, compile the
requested page (1-based), and return the scene JSON plus the
compile-stage diagnostics.
project_dir is the .zen file’s parent directory. When Some, font
assets declared in the document are loaded and registered in the font
provider so that font.family tokens referencing them resolve to the
actual face rather than falling back to the bundled Noto fonts. When
None, only the bundled fonts are available.
data is an optional data context for resolving (data)"field" property
references at compile time. When None, data refs produce
data.missing_field / data.no_context advisories (non-fatal).
flags carries the --allow/--warn/--deny CLI overrides; pass
&CliPolicyFlags::default() when no flags are available (e.g. MCP).
Returns Err when:
- A config file cannot be read (exit code 2).
- The source fails to parse (exit code 2).
- The document has validation errors (exit code 1).
- The
pageis out of range (exit code 2). - Scene JSON serialisation fails (exit code 2).