Skip to main content

kotlin_codegen/
lib.rs

1//! Kotlin code generator — a self-contained declaration model + renderer
2//! (KotlinPoet-style "spec model with raw code bodies").
3//!
4//! Declarations (files, classes, functions, properties, parameters, types,
5//! annotations) are typed model values; imports and formatting derive from
6//! the model. Statement **bodies** stay raw Kotlin text structured through
7//! the indentation-aware [`KtCode`] builder.
8//!
9//! This crate is deliberately dependency-free: it receives model values and
10//! strings, and produces source text and file paths. Consumers build the
11//! model; this crate renders it.
12
13mod code;
14mod file;
15mod ident;
16mod model;
17mod render;
18mod slot;
19mod types;
20mod validate;
21
22#[cfg(test)]
23mod tests;
24
25pub use code::KtCode;
26pub use file::{
27    merge_files, merge_files_with, merged_file_path, write_files, write_files_with,
28    WriteKotlinError,
29};
30pub use ident::{
31    escape_kotlin_ident, is_escaped_kotlin_ident, is_kotlin_hard_keyword, is_valid_kotlin_ident,
32    is_valid_kotlin_package, is_writable_kotlin_ident, mangle_kotlin_ident, mangle_kotlin_package,
33    KOTLIN_HARD_KEYWORDS,
34};
35pub use model::{
36    KtBody, KtClass, KtClassKind, KtClassModifier, KtCompanion, KtCtorParam, KtDecl, KtEnumEntry,
37    KtFile, KtFun, KtFunInterface, KtFunSig, KtParam, KtProperty, KtSuperclass, KtSupertypes,
38    KtVis,
39};
40pub use render::KOTLIN_BANNER;
41pub use slot::KtPropertyValue;
42pub use types::{ImportSet, KtType};
43pub use validate::{Check, Diagnostic, Severity, ValidationPolicy};