1pub mod config;
2pub mod engine;
3pub mod error;
4pub mod ir;
5pub mod parse;
6pub mod transform;
7
8use thiserror::Error;
9
10#[derive(Debug, Clone)]
12pub struct GeneratedFile {
13 pub path: String,
14 pub content: String,
15}
16
17#[derive(Debug, Clone)]
20pub struct GenerateOutput {
21 pub source_files: Vec<GeneratedFile>,
23 pub scaffold_files: Vec<GeneratedFile>,
26}
27
28pub fn normalize_generated(content: &str) -> String {
32 let mut result = String::with_capacity(content.len());
33 let mut newline_count = 0;
34 for ch in content.chars() {
35 if ch == '\n' {
36 newline_count += 1;
37 if newline_count <= 2 {
38 result.push(ch);
39 }
40 } else {
41 newline_count = 0;
42 result.push(ch);
43 }
44 }
45 if !result.ends_with('\n') {
46 result.push('\n');
47 }
48 result
49}
50
51#[derive(Debug, Error)]
53pub enum GeneratorError {
54 #[error("template render failed: {0}")]
55 Render(String),
56
57 #[error("generation failed: {0}")]
58 Other(String),
59}