Module builder

Module builder 

Source
Expand description

Code generation building blocks.

This module provides the core primitives for generating code:

  • CodeBuilder - Fluent API for building indented code
  • CodeFragment - Intermediate representation for code pieces
  • Renderable - Trait for types that can be converted to code fragments
  • FileBuilder - Composition of imports and code
  • Indent - Indentation configuration

§Language-Agnostic Expression Builders

  • Value - Semantic values (bool, int, duration, enum variants, etc.)
  • BuilderSpec - Declarative specification for builder/fluent API patterns
  • Block - Scoped expressions with let bindings
  • Renderer - Trait for language-specific rendering

§Declarative Type Specifications

Structs§

AttributeSpec
An attribute or decorator on a type or member.
Binding
A binding in a block (let/const/var).
Block
A scoped block expression with bindings.
BuilderSpec
A declarative specification for a builder pattern.
CodeBuilder
Fluent API for building code with proper indentation.
EnumSpec
A declarative specification for an enum.
FieldSpec
A field in a struct.
FileBuilder
Composable file builder that combines import collection with code generation.
FunctionSpec
A declarative specification for a function or method.
GenericParam
A generic type parameter.
MatchArm
A match arm (case in switch).
MethodCall
A method call in a builder chain.
ParamSpec
A function parameter.
RenderOptions
Formatting options for rendering.
StructSpec
A declarative specification for a struct or class.
Terminal
Terminal operation for a builder chain.
VariantSpec
A variant in an enum.

Enums§

AttributeArg
An argument to an attribute.
CodeFragment
Represents a fragment of generated code.
Constructor
How to construct the builder’s base expression.
Indent
Indentation style for generated code.
Pattern
A pattern for matching.
PrimitiveType
Primitive types supported across languages.
Receiver
Method receiver type.
Statement
A statement in a function body.
TypeRef
A language-agnostic type reference.
Value
A semantic value that can be rendered to any language.
VariantKind
Kind of enum variant.
Visibility
Visibility/access level for types and members.

Traits§

FunctionRenderer
Trait for rendering function specs to language-specific code.
Renderable
Trait for types that can be rendered to code fragments.
Renderer
Trait for language-specific rendering of expressions.
StructureRenderer
Trait for rendering structure specs to language-specific code.
TypeMapper
Trait for mapping types to language-specific representations.