Pipeline orchestrator for parsing DTCG config maps into flat token lists.
Coordinates the parsing pipeline:
Jetons.DTCG.apply_extends/1— resolve$extendsinheritanceJetons.DTCG.flatten/2— flatten nested maps to{path, value}tuplesJetons.Ref.expand/1— expand{ref.path}referencesJetons.Transforms— apply type-based value transforms
Summary
Functions
Extracts unique sorted category prefixes from a token list.
Parses a DTCG config map into a flat list of {path, value} tuples.
Non-raising variant of from_config/1.
Non-raising variant of from_config/2. See from_config_safe/1.
Parses multiple groups of JSON files, resolving references across all groups, and returns tokens grouped by label.
Functions
Extracts unique sorted category prefixes from a token list.
Examples
iex> Jetons.Parser.extract_categories([{"colors.red", "#f00"}, {"spacing.sm", "4px"}, {"colors.blue", "#00f"}])
["colors", "spacing"]
Parses a DTCG config map into a flat list of {path, value} tuples.
Examples
iex> Jetons.Parser.from_config(%{"colors" => %{"red" => %{"$value" => "#f00"}}})
[{"colors.red", "#f00"}]
Non-raising variant of from_config/1.
Wraps from_config/1 and returns {:ok, tokens} on success, or
{:error, message} when parsing raises an ArgumentError (e.g. invalid
token names, circular $extends, or unresolvable references).
Examples
iex> Jetons.Parser.from_config_safe(%{"colors" => %{"red" => %{"$value" => "#f00"}}})
{:ok, [{"colors.red", "#f00"}]}
iex> {:error, msg} = Jetons.Parser.from_config_safe(%{"a" => %{"$extends" => "missing", "$value" => "x"}})
iex> is_binary(msg)
true
Non-raising variant of from_config/2. See from_config_safe/1.
Parses multiple groups of JSON files, resolving references across all groups, and returns tokens grouped by label.
Each group is a {label, files} tuple where files is a list of file paths.
References are resolved globally (e.g. tier 2 can reference tier 1 tokens),
but the returned map preserves which group each token originated from.
Options
:transforms- list of{type, fun}tuples to apply after resolution
Example
Jetons.from_files([
{"tier1", Path.wildcard("tokens/01-definitions/**/*.json")},
{"tier2", Path.wildcard("tokens/02-semantics/**/*.json")},
{"tier3", Path.wildcard("tokens/03-components/**/*.json")}
])
#=> %{"tier1" => [{"color.palette.blue", "#308CE8"}, ...], ...}