Documentation ¶
Overview ¶
Package generator provides facilities to generate Go code for the package data in enry from YAML files describing supported languages in Linguist.
Index ¶
- func Aliases(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error
- func Colors(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error
- func Commit(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error
- func Documentation(fileToParse, _, outFile, tmplPath, tmplName, commit string) error
- func Extensions(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error
- func Filenames(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error
- func Frequencies(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error
- func GenHeuristics(fileToParse, _, outPath, tmplPath, tmplName, commit string) error
- func Groups(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error
- func ID(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error
- func Interpreters(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error
- func LanguageInfo(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error
- func MimeType(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error
- func Types(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error
- func Vendor(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error
- type Disambiguation
- type File
- type Heuristics
- type LanguagePattern
- type Patterns
- type Rule
- type StringArray
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Aliases ¶
Aliases reads from fileToParse and builds source file from tmplPath. It complies with type File signature.
func Colors ¶
Colors generates a map in Go with language name -> color string. It is of generator.File type.
func Commit ¶
Commit takes a commit and builds the source file from tmplPath. It complies with type File signature.
func Documentation ¶
Documentation generates regex matchers in Go for documentation files/dirs. It is of generator.File type.
func Extensions ¶
Extensions reads from fileToParse and builds source file from tmplPath. It complies with type File signature.
func Filenames ¶
Filenames reads from fileToParse and builds source file from tmplPath. It complies with type File signature.
func Frequencies ¶
Frequencies reads directories in samplesDir, retrieves information about frequencies of languages and tokens, and write the file outPath using tmplName as a template. It complies with type File signature.
func GenHeuristics ¶
GenHeuristics generates language identification heuristics in Go. It is of generator.File type.
func Groups ¶
Groups generates a map in Go with language name -> group name. It is of generator.File type.
func Interpreters ¶
Interpreters reads from fileToParse and builds source file from tmplPath. It complies with type File signature.
func LanguageInfo ¶
LanguageInfo generates maps in Go with language name -> LanguageInfo and language ID -> LanguageInfo. It is of generator.File type.
func MimeType ¶
MimeType generates a map in Go with language name -> MIME string. It is of generator.File type.
Types ¶
type Disambiguation ¶
type File ¶
File is a common type for all generator functions. It generates Go source code file based on template in tmplPath, by parsing the data in fileToParse and linguist's samplesDir saving results to an outFile.
type Heuristics ¶
type Heuristics struct { Disambiguations []*Disambiguation NamedPatterns map[string]StringArray `yaml:"named_patterns"` }
type LanguagePattern ¶
type LanguagePattern struct { Op string Langs []string Pattern string Rules []*LanguagePattern }
LanguagePattern is an IR of parsed Rule suitable for code generations. Strings are used as this is to be be consumed by text/template.
type Patterns ¶
type Patterns struct { Pattern StringArray `yaml:"pattern,omitempty"` NamedPattern string `yaml:"named_pattern,omitempty"` NegativePattern string `yaml:"negative_pattern,omitempty"` }
type Rule ¶
type Rule struct { Patterns `yaml:",inline"` Languages StringArray `yaml:"language"` And []*Rule }
type StringArray ¶
type StringArray []string
StringArray is workaround for parsing named_pattern, wich is sometimes arry and sometimes not. See https://github.com/go-yaml/yaml/issues/100
func (*StringArray) UnmarshalYAML ¶
func (sa *StringArray) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML allows to parse element always as a []string