Skip to content

rune-langium / codegen/src / generate

Function: generate()

ts
function generate(documents, options?): GeneratorOutput[];

Defined in: packages/codegen/src/index.ts:45

Generate code from one or more parsed Langium documents.

This is the primary entry point for the code generator. It accepts a single document or an array of documents and normalizes them before passing to the internal generator pipeline.

Parameters

ParameterTypeDescription
documentsLangiumDocument<AstNode> | LangiumDocument<AstNode>[]One or more parsed Langium documents with resolved ASTs.
options?GeneratorOptionsOptional generator options (target, strict, headerComment).

Returns

GeneratorOutput[]

Array of GeneratorOutput sorted by relativePath ascending.

Throws

GeneratorError when strict mode is enabled and any error diagnostic is produced.

Example

ts
import { generate } from '@rune-langium/codegen';
const outputs = generate(doc, { target: 'zod' });

Core packages released under MIT. Studio app released under FSL-1.1-ALv2.