@dtcg-formulas/parser
v0.1.0
Published
Parser for .module.scssdef definition files used by dtcg-formulas.
Maintainers
Readme
@dtcg-formulas/parser
Parser for .module.scssdef definition files used by dtcg-formulas — a documentation-first, pluggable formula layer for DTCG design tokens.
Install
npm install @dtcg-formulas/parserUsage
import { parse } from '@dtcg-formulas/parser';
import { readFileSync } from 'node:fs';
const source = readFileSync('tokens/functions/radius.module.scssdef', 'utf-8');
const mod = parse(source);
console.log(mod.frontmatter.module); // "math"
console.log(mod.functions[0].name); // "snap"parse(source) returns a ParsedModule:
interface ParsedModule {
frontmatter: ModuleFrontmatter; // YAML frontmatter (module, title, summary, ...)
functions: FunctionDeclaration[]; // SassDoc + signature parsed for each function
}See the API reference for the full type surface and the .module.scssdef spec for the file format.
What this is
Phase 1 of the dtcg-formulas project. Pairs with @dtcg-formulas/registry. The resolver, CLI, and executable adapters land in 0.2.0+; see the roadmap.
License
MIT
