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 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 Interpreters(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 Commit ¶ added in v1.3.0
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 ¶ added in v1.2.1
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 ¶ added in v1.7.0
GenHeuristics generates language identification heuristics in Go. 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 MimeType ¶ added in v1.3.3
MimeType generates a map in Go with language name -> MIME string. It is of generator.File type.
Types ¶
type Disambiguation ¶ added in v1.7.0
type File ¶ added in v1.2.1
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 ¶ added in v1.7.0
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 ¶ added in v1.7.0
type Patterns struct { Pattern StringArray `yaml:"pattern,omitempty"` NamedPattern string `yaml:"named_pattern,omitempty"` NegativePattern string `yaml:"negative_pattern,omitempty"` }
type Rule ¶ added in v1.7.0
type Rule struct { Patterns `yaml:",inline"` Languages StringArray `yaml:"language"` And []*Rule }
type StringArray ¶ added in v1.7.0
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 ¶ added in v1.7.0
func (sa *StringArray) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML allowes to parse element always as a []string