Crate dazzle_backend_sgml

Crate dazzle_backend_sgml 

Source
Expand description

SGML backend for Dazzle code generation

This crate implements the FotBuilder trait for SGML-style output, which is used for code generation rather than document formatting.

§Purpose

Unlike OpenJade’s document formatting backends (RTF, TeX, MIF, HTML), the SGML backend is designed for code generation:

  • entity: Creates output files (e.g., generated Java classes)
  • formatting-instruction: Appends text to the current output buffer

This maps perfectly to code generation use cases where you want to generate multiple source files from XML input.

§Architecture

SgmlBackend
  ├─ output_dir: PathBuf (where to write files)
  ├─ current_buffer: String (collecting text for current file)
  └─ written_files: HashSet<PathBuf> (track what's been written)

§Usage

use dazzle_backend_sgml::SgmlBackend;
use dazzle_core::fot::FotBuilder;

let mut backend = SgmlBackend::new("output");

// Append text to buffer
backend.formatting_instruction("public class Foo {\n")?;
backend.formatting_instruction("  // generated code\n")?;
backend.formatting_instruction("}\n")?;

// Write buffer to file
backend.entity("src/Foo.java", &backend.current_output())?;

Structs§

SgmlBackend
SGML backend for code generation