Documentation
¶
Overview ¶
Package compilers defines the contract between spec compilers and the engine: a Compiler lowers source documents of its formats into an ir.Document plus diagnostics, purely and reentrantly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Compiler ¶
type Compiler interface {
Formats() []SourceFormat
Compile(ctx context.Context, sources []Source, opts Options) (*ir.Document, []ir.Diagnostic, error)
}
Compiler lowers source documents into the IR. Implementations must be pure: no package-level mutable state, no writes to stderr; spec problems are returned as ir.Diagnostic values and the error return is reserved for I/O-level and programmer errors.
type Options ¶
type Options struct {
FormatOptions any
}
Options carries per-compile configuration. FormatOptions is the compiler-specific options value; each compiler documents the concrete type it accepts and treats nil as defaults.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry maps source formats to compilers. It is a plain instance — there is no package-level default and no init()-time self-registration; the engine composes its registry explicitly.
func (*Registry) Formats ¶
func (r *Registry) Formats() []SourceFormat
Formats lists every registered format, sorted for stable display.
type Source ¶
Source is one pre-read input document. Compilers perform no file I/O; the caller loads bytes so compilation stays pure and reentrant.
type SourceFormat ¶
type SourceFormat struct {
Name string // "openapi", "swagger", "typespec", "smithy", ...
Version string // "3.0", "3.1", "2.0", ...
}
SourceFormat identifies one spec dialect a compiler accepts.
func (SourceFormat) String ¶
func (f SourceFormat) String() string
String renders the canonical "name@version" form used in diagnostics and registry errors.