Documentation Language: Swift

Method

generate(mainTemplate:arguments:models:)

Executes the specified main template with the given arguments.

@MainActor func generate(mainTemplate: String, arguments: [(any EcoreValue)?], models: [String : Resource]) async throws

Parameters

mainTemplate

The name of the main template to execute

arguments

The arguments to pass to the template

models

The input models keyed by alias (e.g., “IN”, “LIB”)

Discussion

This is the primary entry point for MTL generation. It:

  1. Resets statistics

  2. Registers input models

  3. Finds the specified main template

  4. Executes the template with arguments

  5. Finalizes the context

  6. Records statistics

Example

var models: [String: Resource] = [:]
models["IN"] = inputModel

try await generator.generate(
    mainTemplate: "main",
    arguments: [modelRoot],
    models: models
)