Specify helps you unify your brand identity by collecting, storing and distributing design tokens and assets—automatically.
Parsers are functions allowing you to transform design tokens and assets you get from Specify's API.
Parsers are ordered and takes specific input to generate specific output. This way, we can easily test the input coming from the previous parser to check if the whole parsers process will work.
By using parsers, you dictate the way you receive the data from Specify to fit your own needs.
Let's say you want to create a parser named my-parser
.
- Fork the current repository
- Git clone the forked repository
- In the directory
parsers
, create a directory namedmy-parser
- Create your valid parser
- Make a PR
To be valid, your parser needs:
- A
README.md
file containing:- A description
- A typed interface with its params (See the camelcasify one)
- A usage example (See the camelcasify one)
- The typing of its inputs and outputs (See the camelcasify one)
- A
my-parser.spec.ts
file containing your parser's unit tests - A
my-parser.parser.ts
file
For now, our parsers only use the following libraries:
If you need another library to develop your parser:
- Install it using
yarn
ornpm
- Import and export it in the
parsers/global-libs.ts
file
To easily create and test your parsers, we advise you to use them on design tokens provided in the seeds.json
file.
It will allow you to use our fake tokens to test your parsers.
To use our design tokens seed:
- Import it in your [parser].spec.ts using
import * as seeds from '../../seeds.json';
- Use the
seeds.tokens
variable according to your needs. - Launch
yarn test
to tests your parsers