Documentation
¶
Overview ¶
Package parser provides DTCG token file parsing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSONParser ¶
type JSONParser struct{}
JSONParser parses DTCG-compliant JSON token files.
func NewJSONParser ¶
func NewJSONParser() *JSONParser
NewJSONParser creates a new JSON token parser.
func (*JSONParser) ParseFile ¶
func (p *JSONParser) ParseFile(filesystem fs.FileSystem, path string, opts Options) ([]*token.Token, error)
ParseFile parses a JSON token file and returns tokens.
type Options ¶
type Options struct {
// Prefix is the CSS variable prefix.
Prefix string
// SchemaVersion overrides auto-detection.
SchemaVersion schema.Version
// GroupMarkers are token names that can be both tokens and groups (draft only).
GroupMarkers []string
// SkipSort disables alphabetical sorting of tokens for better performance.
// When false (default), tokens are sorted for deterministic output order.
SkipSort bool
// SkipPositions disables position tracking for better performance.
// When true, Line and Character fields will be zero on all tokens.
// Use this when LSP features (go-to-definition) aren't needed.
SkipPositions bool
}
Options configures token parsing.
type Parser ¶
type Parser interface {
// Parse parses token data and returns tokens.
Parse(data []byte, opts Options) ([]*token.Token, error)
// ParseFile parses a token file and returns tokens.
ParseFile(filesystem fs.FileSystem, path string, opts Options) ([]*token.Token, error)
}
Parser parses design token files.
Click to show internal directories.
Click to hide internal directories.