generator

package
v1.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Aliases

func Aliases(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error

Aliases reads from fileToParse and builds source file from tmplPath. It complies with type File signature.

func Commit added in v1.3.0

func Commit(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error

Commit takes a commit and builds the source file from tmplPath. It complies with type File signature.

func Documentation

func Documentation(fileToParse, _, outFile, tmplPath, tmplName, commit string) error

Documentation generates regex matchers in Go for documentation files/dirs. It is of generator.File type.

func Extensions

func Extensions(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error

Extensions reads from fileToParse and builds source file from tmplPath. It complies with type File signature.

func Filenames

func Filenames(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error

Filenames reads from fileToParse and builds source file from tmplPath. It complies with type File signature.

func Frequencies added in v1.2.1

func Frequencies(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error

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

func GenHeuristics(fileToParse, _, outPath, tmplPath, tmplName, commit string) error

GenHeuristics generates language identification heuristics in Go. It is of generator.File type.

func Interpreters

func Interpreters(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error

Interpreters reads from fileToParse and builds source file from tmplPath. It complies with type File signature.

func MimeType added in v1.3.3

func MimeType(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error

MimeType generates a map in Go with language name -> MIME string. It is of generator.File type.

func Types

func Types(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error

Types reads from fileToParse and builds source file from tmplPath. It complies with type File signature.

func Vendor

func Vendor(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error

Vendor generates regex matchers in Go for vendoring files/dirs. It is of generator.File type.

Types

type Disambiguation added in v1.7.0

type Disambiguation struct {
	Extensions []string `yaml:"extensions,flow"`
	Rules      []*Rule  `yaml:"rules"`
}

type File added in v1.2.1

type File func(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL