gen

package
v0.0.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package gen checks a Generator's committed outputs for drift and writes fresh ones.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(
	ctx context.Context,
	write func(path string, data []byte) error,
	a types.Artifacts,
) error

Apply writes every artifact through write, in path order.

func NewFromRow added in v0.0.19

func NewFromRow(row types.GenRow, deps Deps) (interfaces.Generator, error)

NewFromRow returns the generator row describes. An unknown kind, a run row with no tool runner, a template row with no template or an unknown data provider is CodeInvalidInput naming the row.

Types

type DataFunc added in v0.0.19

type DataFunc func(ctx context.Context, cb interfaces.Codebase) (any, error)

DataFunc provides a template row's data from the codebase.

type Deps added in v0.0.19

type Deps struct {
	// Tools runs a GenRun row's tool.
	Tools interfaces.ToolRunner

	// Data are the template data providers, by the name rows use.
	Data map[string]DataFunc
}

Deps carries what row generators run with.

type Drift

type Drift struct {
	// Diff is a unified diff from the committed outputs to the fresh ones.
	Diff string

	// Paths are the outputs that differ or are missing, sorted.
	Paths []string

	// InSync is true when every output matches.
	InSync bool
}

Drift is how a generator's committed outputs differ from a fresh render.

func Check

Check renders g over cb and compares each output with the file cb holds; a missing file is drift from nothing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL