Malachi.UI.TokenGen (malachi v0.22.7)

View Source

One token file, four generated outputs, and the gates that prove the three interfaces share it.

docs/design/design-tokens.json is the single source of every color, type, spacing, density, motion and easing value the web console, the terminal interface and any server rendered page use (operator-interfaces.md section 4). From it this generates:

OutputFor
assets/src/styles/tokens.cssThe web console (#231)
tui/src/theme/generated.rsThe terminal interface (#233)
lib/malachi/ui/tokens.exMalachi.UI.Tokens, any server rendered page
docs/design/tokens.snapshot.jsonThe cross language contract tests

The pipeline is Malachi.UI.TokenGen.Source (parse and validate the file), then Malachi.UI.TokenGen.Model (compute every value once), then Malachi.UI.TokenGen.Gates (gamut, contrast, color vision, colors kept apart, terminal distinctness), then Malachi.UI.TokenGen.Emit. Nothing is written unless every step passes. check/1 is what CI runs, through mix malachi.tokens --check.

Summary

Functions

Every reason the repository under root does not match its token file: an output that is missing or differs from what the token file generates, a committed output that breaks the cross language contract, and a raw color literal in an interface source. An empty list means the gate passes.

Generates every output from the text of a token file, or returns every error that prevents it.

The raw color literal hits under root.

The generated files, relative to the repository root, in the order they are written.

The token file, relative to the repository root.

Functions

check(root)

@spec check(Path.t()) :: [String.t()]

Every reason the repository under root does not match its token file: an output that is missing or differs from what the token file generates, a committed output that breaks the cross language contract, and a raw color literal in an interface source. An empty list means the gate passes.

generate(text)

@spec generate(String.t()) ::
  {:ok, [{String.t(), String.t()}]} | {:error, [String.t()]}

Generates every output from the text of a token file, or returns every error that prevents it.

lint(root)

@spec lint(Path.t()) :: [Malachi.UI.TokenGen.Lint.hit()]

The raw color literal hits under root.

outputs()

@spec outputs() :: [String.t()]

The generated files, relative to the repository root, in the order they are written.

source()

@spec source() :: String.t()

The token file, relative to the repository root.