generator

package
v2.0.0-...-6ef3e87 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: Apache-2.0 Imports: 16 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 Colors

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

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

func Commit

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

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

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

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

func Groups

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

Groups generates a map in Go with language name -> group name. It is of generator.File type.

func ID

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

ID generates a map in Go with language name -> language ID. 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 LanguageInfo

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

LanguageInfo generates maps in Go with language name -> LanguageInfo and language ID -> LanguageInfo. It is of generator.File type.

func MimeType

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

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

type File

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

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

Jump to

Keyboard shortcuts

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