README.md 1.23 KB
Newer Older
1 2
## Token Defaults Generator

3
Script that generates component theme data defaults based on token data.
4 5 6 7

## Usage
Run this program from the root of the git repository:
```
8
dart dev/tools/gen_defaults/bin/gen_defaults.dart [-v]
9 10
```

11 12
This updates `generated/used_tokens.csv` and the various component theme files.

13 14 15 16 17
## Templates

There is a template file for every component that needs defaults from
the token database. These templates are implemented as subclasses of
`TokenTemplate`. This base class provides some utilities and a structure
18
for adding a new block of generated code to the bottom of a given file.
19 20

Templates need to override the `generate` method to provide the generated
21
code block as a string.
22 23 24

See `lib/fab_template.dart` for an example that generates defaults for the
Floating Action Button.
25 26 27 28 29 30 31 32 33 34 35

## Tokens

Tokens are stored in JSON files in `data/`, and are sourced from
an internal Google database.

`template.dart` should provide nearly all useful token resolvers
(e.g. `color`, `shape`, etc.). For special cases in which one shouldn't
be defined, use `getToken` to get the raw token value. The script, through
the various revolvers and `getToken`, validates tokens, keeps track of
which tokens are used, and generates `generated/used_tokens.csv`.