mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-19 06:33:06 -03:00
write a canonical header for machine-generated files
Signed-off-by: Denys Smirnov <denys@sourced.tech>
This commit is contained in:
committed by
Denys Smirnov
parent
40a21f8e0b
commit
7eafe024af
@ -1,9 +1,5 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Extracted from github/linguist commit: {{ getCommit }}
|
||||
|
||||
// LanguagesByAlias keeps alias for different languages and use the name of the languages as an alias too.
|
||||
// All the keys (alias or not) are written in lower case and the whitespaces has been replaced by underscores.
|
||||
var LanguagesByAlias = map[string]string{
|
||||
|
@ -1,8 +1,4 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Extracted from github/linguist commit: {{ . }}
|
||||
|
||||
// linguist's commit from which files were generated.
|
||||
var LinguistCommit = "{{- . -}}"
|
||||
var LinguistCommit = "{{- getCommit -}}"
|
||||
|
@ -1,9 +1,5 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Extracted from github/linguist commit: {{ getCommit }}
|
||||
|
||||
import "gopkg.in/toqueteos/substring.v1"
|
||||
|
||||
type languageMatcher func ([]byte) []string
|
||||
|
@ -1,9 +1,5 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Extracted from github/linguist commit: {{ getCommit }}
|
||||
|
||||
import "gopkg.in/toqueteos/substring.v1"
|
||||
|
||||
var DocumentationMatchers = substring.Or(
|
||||
|
@ -1,9 +1,5 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Extracted from github/linguist commit: {{ getCommit }}
|
||||
|
||||
var LanguagesByExtension = map[string][]string{
|
||||
{{range $extension, $languages := .LanguagesByExtension -}}
|
||||
"{{ $extension }}": { {{- $languages | formatStringSlice -}} },
|
||||
|
@ -1,9 +1,5 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Extracted from github/linguist commit: {{ getCommit }}
|
||||
|
||||
var LanguagesByFilename = map[string][]string{
|
||||
{{range $filename, $languages := . -}}
|
||||
"{{ $filename }}": { {{- formatStringSlice $languages -}} },
|
||||
|
@ -1,9 +1,5 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Extracted from github/linguist commit: {{ getCommit }}
|
||||
|
||||
var LanguagesLogProbabilities = map[string]float64{
|
||||
{{ $freqs := . -}}
|
||||
{{range $index, $language := orderKeys .Languages -}}
|
||||
|
3
internal/code-generator/assets/header.go.tmpl
Normal file
3
internal/code-generator/assets/header.go.tmpl
Normal file
@ -0,0 +1,3 @@
|
||||
// Code generated by gopkg.in/src-d/enry.v1/internal/code-generator DO NOT EDIT.
|
||||
// Extracted from github/linguist commit: {{ getCommit }}
|
||||
|
@ -1,9 +1,5 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Extracted from github/linguist commit: {{ getCommit }}
|
||||
|
||||
var LanguagesByInterpreter = map[string][]string{
|
||||
{{range $interpreter, $languages := . -}}
|
||||
"{{ $interpreter }}": { {{- $languages | formatStringSlice -}} },
|
||||
|
@ -1,9 +1,5 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Extracted from github/linguist commit: {{ getCommit }}
|
||||
|
||||
var LanguagesMime = map[string]string{
|
||||
{{range $language, $mime := . -}}
|
||||
"{{$language}}": "{{$mime -}}",
|
||||
|
@ -1,9 +1,5 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Extracted from github/linguist commit: {{ getCommit }}
|
||||
|
||||
var LanguagesType = map[string]int{
|
||||
{{range $language, $type := . -}}
|
||||
"{{ $language }}": {{ $type -}},
|
||||
|
@ -1,9 +1,5 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Extracted from github/linguist commit: {{ getCommit }}
|
||||
|
||||
import "gopkg.in/toqueteos/substring.v1"
|
||||
|
||||
var VendorMatchers = substring.Or(
|
||||
|
@ -2,12 +2,10 @@ package generator
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"gopkg.in/yaml.v2"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// Aliases reads from fileToParse and builds source file from tmplPath. It complies with type File signature.
|
||||
@ -55,14 +53,5 @@ func convertToAliasKey(s string) (key string) {
|
||||
}
|
||||
|
||||
func executeAliasesTemplate(out io.Writer, languagesByAlias map[string]string, aliasesTmplPath, aliasesTmpl, commit string) error {
|
||||
fmap := template.FuncMap{
|
||||
"getCommit": func() string { return commit },
|
||||
}
|
||||
|
||||
t := template.Must(template.New(aliasesTmpl).Funcs(fmap).ParseFiles(aliasesTmplPath))
|
||||
if err := t.Execute(out, languagesByAlias); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return executeTemplate(out, aliasesTmpl, aliasesTmplPath, commit, nil, languagesByAlias)
|
||||
}
|
||||
|
@ -2,11 +2,9 @@ package generator
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"gopkg.in/yaml.v2"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"text/template"
|
||||
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// Documentation reads from fileToParse and builds source file from tmplPath. It complies with type File signature.
|
||||
@ -30,14 +28,5 @@ func Documentation(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit
|
||||
}
|
||||
|
||||
func executeDocumentationTemplate(out io.Writer, regexpList []string, tmplPath, tmplName, commit string) error {
|
||||
fmap := template.FuncMap{
|
||||
"getCommit": func() string { return commit },
|
||||
}
|
||||
|
||||
t := template.Must(template.New(tmplName).Funcs(fmap).ParseFiles(tmplPath))
|
||||
if err := t.Execute(out, regexpList); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return executeTemplate(out, tmplName, tmplPath, commit, nil, regexpList)
|
||||
}
|
||||
|
@ -81,14 +81,7 @@ func buildLanguageExtensionsMap(languages map[string]*languageInfo) map[string][
|
||||
|
||||
func executeExtensionsTemplate(out io.Writer, extInfo *extensionsInfo, tmplPath, tmplName, commit string) error {
|
||||
fmap := template.FuncMap{
|
||||
"getCommit": func() string { return commit },
|
||||
"formatStringSlice": func(slice []string) string { return `"` + strings.Join(slice, `","`) + `"` },
|
||||
}
|
||||
|
||||
t := template.Must(template.New(tmplName).Funcs(fmap).ParseFiles(tmplPath))
|
||||
if err := t.Execute(out, extInfo); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return executeTemplate(out, tmplName, tmplPath, commit, fmap, extInfo)
|
||||
}
|
||||
|
@ -91,14 +91,7 @@ func buildFilenameLanguageMap(languages map[string]*languageInfo) map[string][]s
|
||||
|
||||
func executeFilenamesTemplate(out io.Writer, languagesByFilename map[string][]string, tmplPath, tmplName, commit string) error {
|
||||
fmap := template.FuncMap{
|
||||
"getCommit": func() string { return commit },
|
||||
"formatStringSlice": func(slice []string) string { return `"` + strings.Join(slice, `","`) + `"` },
|
||||
}
|
||||
|
||||
t := template.Must(template.New(tmplName).Funcs(fmap).ParseFiles(tmplPath))
|
||||
if err := t.Execute(out, languagesByFilename); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return executeTemplate(out, tmplName, tmplPath, commit, fmap, languagesByFilename)
|
||||
}
|
||||
|
@ -1,8 +1,12 @@
|
||||
package generator
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"go/format"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
// File is the function's type that generate source file from a file to be parsed, linguist's samples dir and a template.
|
||||
@ -13,10 +17,45 @@ func formatedWrite(outPath string, source []byte) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(outPath, formatedSource, 0666); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func executeTemplate(w io.Writer, name, path, commit string, fmap template.FuncMap, data interface{}) error {
|
||||
getCommit := func() string {
|
||||
return commit
|
||||
}
|
||||
|
||||
buf := bytes.NewBuffer(nil)
|
||||
|
||||
const headerTmpl = "header.go.tmpl"
|
||||
|
||||
headerPath := filepath.Join(filepath.Dir(path), headerTmpl)
|
||||
|
||||
h := template.Must(template.New(headerTmpl).Funcs(template.FuncMap{
|
||||
"getCommit": getCommit,
|
||||
}).ParseFiles(headerPath))
|
||||
|
||||
if err := h.Execute(buf, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if fmap == nil {
|
||||
fmap = make(template.FuncMap)
|
||||
}
|
||||
fmap["getCommit"] = getCommit
|
||||
|
||||
t := template.Must(template.New(name).Funcs(fmap).ParseFiles(path))
|
||||
if err := t.Execute(buf, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
src, err := format.Source(buf.Bytes())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = w.Write(src)
|
||||
return err
|
||||
}
|
||||
|
@ -13,68 +13,71 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
linguistURL = "https://github.com/github/linguist.git"
|
||||
linguistURL = "https://github.com/github/linguist.git"
|
||||
linguistClonedEnvVar = "ENRY_TEST_REPO"
|
||||
commit = "d5c8db3fb91963c4b2762ca2ea2ff7cfac109f68"
|
||||
samplesDir = "samples"
|
||||
languagesFile = "lib/linguist/languages.yml"
|
||||
commit = "d5c8db3fb91963c4b2762ca2ea2ff7cfac109f68"
|
||||
samplesDir = "samples"
|
||||
languagesFile = "lib/linguist/languages.yml"
|
||||
|
||||
testDir = "test_files"
|
||||
assetsDir = "../assets"
|
||||
|
||||
// Extensions test
|
||||
extensionGold = "test_files/extension.gold"
|
||||
extensionTestTmplPath = "../assets/extension.go.tmpl"
|
||||
extensionGold = testDir + "/extension.gold"
|
||||
extensionTestTmplPath = assetsDir + "/extension.go.tmpl"
|
||||
extensionTestTmplName = "extension.go.tmpl"
|
||||
|
||||
// Heuristics test
|
||||
heuristicsTestFile = "lib/linguist/heuristics.rb"
|
||||
contentGold = "test_files/content.gold"
|
||||
contentTestTmplPath = "../assets/content.go.tmpl"
|
||||
contentGold = testDir + "/content.gold"
|
||||
contentTestTmplPath = assetsDir + "/content.go.tmpl"
|
||||
contentTestTmplName = "content.go.tmpl"
|
||||
|
||||
// Vendor test
|
||||
vendorTestFile = "lib/linguist/vendor.yml"
|
||||
vendorGold = "test_files/vendor.gold"
|
||||
vendorTestTmplPath = "../assets/vendor.go.tmpl"
|
||||
vendorGold = testDir + "/vendor.gold"
|
||||
vendorTestTmplPath = assetsDir + "/vendor.go.tmpl"
|
||||
vendorTestTmplName = "vendor.go.tmpl"
|
||||
|
||||
// Documentation test
|
||||
documentationTestFile = "lib/linguist/documentation.yml"
|
||||
documentationGold = "test_files/documentation.gold"
|
||||
documentationTestTmplPath = "../assets/documentation.go.tmpl"
|
||||
documentationGold = testDir + "/documentation.gold"
|
||||
documentationTestTmplPath = assetsDir + "/documentation.go.tmpl"
|
||||
documentationTestTmplName = "documentation.go.tmpl"
|
||||
|
||||
// Types test
|
||||
typeGold = "test_files/type.gold"
|
||||
typeTestTmplPath = "../assets/type.go.tmpl"
|
||||
typeGold = testDir + "/type.gold"
|
||||
typeTestTmplPath = assetsDir + "/type.go.tmpl"
|
||||
typeTestTmplName = "type.go.tmpl"
|
||||
|
||||
// Interpreters test
|
||||
interpreterGold = "test_files/interpreter.gold"
|
||||
interpreterTestTmplPath = "../assets/interpreter.go.tmpl"
|
||||
interpreterGold = testDir + "/interpreter.gold"
|
||||
interpreterTestTmplPath = assetsDir + "/interpreter.go.tmpl"
|
||||
interpreterTestTmplName = "interpreter.go.tmpl"
|
||||
|
||||
// Filenames test
|
||||
filenameGold = "test_files/filename.gold"
|
||||
filenameTestTmplPath = "../assets/filename.go.tmpl"
|
||||
filenameGold = testDir + "/filename.gold"
|
||||
filenameTestTmplPath = assetsDir + "/filename.go.tmpl"
|
||||
filenameTestTmplName = "filename.go.tmpl"
|
||||
|
||||
// Aliases test
|
||||
aliasGold = "test_files/alias.gold"
|
||||
aliasTestTmplPath = "../assets/alias.go.tmpl"
|
||||
aliasGold = testDir + "/alias.gold"
|
||||
aliasTestTmplPath = assetsDir + "/alias.go.tmpl"
|
||||
aliasTestTmplName = "alias.go.tmpl"
|
||||
|
||||
// Frequencies test
|
||||
frequenciesGold = "test_files/frequencies.gold"
|
||||
frequenciesTestTmplPath = "../assets/frequencies.go.tmpl"
|
||||
frequenciesGold = testDir + "/frequencies.gold"
|
||||
frequenciesTestTmplPath = assetsDir + "/frequencies.go.tmpl"
|
||||
frequenciesTestTmplName = "frequencies.go.tmpl"
|
||||
|
||||
// commit test
|
||||
commitGold = "test_files/commit.gold"
|
||||
commitTestTmplPath = "../assets/commit.go.tmpl"
|
||||
commitGold = testDir + "/commit.gold"
|
||||
commitTestTmplPath = assetsDir + "/commit.go.tmpl"
|
||||
commitTestTmplName = "commit.go.tmpl"
|
||||
|
||||
// mime test
|
||||
mimeTypeGold = "test_files/mimeType.gold"
|
||||
mimeTypeTestTmplPath = "../assets/mimeType.go.tmpl"
|
||||
mimeTypeGold = testDir + "/mimeType.gold"
|
||||
mimeTypeTestTmplPath = assetsDir + "/mimeType.go.tmpl"
|
||||
mimeTypeTestTmplName = "mimeType.go.tmpl"
|
||||
)
|
||||
|
||||
|
@ -428,7 +428,6 @@ func buildLanguagesHeuristics(langsList [][]string, heuristicsList [][]*heuristi
|
||||
|
||||
func executeContentTemplate(out io.Writer, disambiguators []*disambiguator, tmplPath, tmplName, commit string) error {
|
||||
fmap := template.FuncMap{
|
||||
"getCommit": func() string { return commit },
|
||||
"getAllHeuristics": getAllHeuristics,
|
||||
"returnStringSlice": func(slice []string) string {
|
||||
if len(slice) == 0 {
|
||||
@ -440,13 +439,7 @@ func executeContentTemplate(out io.Writer, disambiguators []*disambiguator, tmpl
|
||||
"returnLanguages": returnLanguages,
|
||||
"avoidLanguage": avoidLanguage,
|
||||
}
|
||||
|
||||
t := template.Must(template.New(tmplName).Funcs(fmap).ParseFiles(tmplPath))
|
||||
if err := t.Execute(out, disambiguators); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return executeTemplate(out, tmplName, tmplPath, commit, fmap, disambiguators)
|
||||
}
|
||||
|
||||
func getAllHeuristics(disambiguators []*disambiguator) []*heuristic {
|
||||
|
@ -47,14 +47,7 @@ func buildInterpreterLanguagesMap(languages map[string]*languageInfo, orderedKey
|
||||
|
||||
func executeInterpretersTemplate(out io.Writer, languagesByInterpreter map[string][]string, tmplPath, tmplName, commit string) error {
|
||||
fmap := template.FuncMap{
|
||||
"getCommit": func() string { return commit },
|
||||
"formatStringSlice": func(slice []string) string { return `"` + strings.Join(slice, `","`) + `"` },
|
||||
}
|
||||
|
||||
t := template.Must(template.New(tmplName).Funcs(fmap).ParseFiles(tmplPath))
|
||||
if err := t.Execute(out, languagesByInterpreter); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return executeTemplate(out, tmplName, tmplPath, commit, fmap, languagesByInterpreter)
|
||||
}
|
||||
|
@ -2,16 +2,13 @@ package generator
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
// Commit takes a commit and builds the source file from tmplPath. It complies with type File signature.
|
||||
func Commit(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error {
|
||||
buf := &bytes.Buffer{}
|
||||
t := template.Must(template.New(tmplName).ParseFiles(tmplPath))
|
||||
if err := t.Execute(buf, commit); err != nil {
|
||||
if err := executeTemplate(buf, tmplName, tmplPath, commit, nil, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return formatedWrite(outPath, buf.Bytes())
|
||||
}
|
||||
|
@ -2,11 +2,9 @@ package generator
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"gopkg.in/yaml.v2"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"text/template"
|
||||
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
func MimeType(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error {
|
||||
@ -42,14 +40,5 @@ func buildLanguageMimeMap(languages map[string]*languageInfo) map[string]string
|
||||
}
|
||||
|
||||
func executeMimeTemplate(out io.Writer, langMimeMap map[string]string, tmplPath, tmplName, commit string) error {
|
||||
fmap := template.FuncMap{
|
||||
"getCommit": func() string { return commit },
|
||||
}
|
||||
|
||||
t := template.Must(template.New(tmplName).Funcs(fmap).ParseFiles(tmplPath))
|
||||
if err := t.Execute(out, langMimeMap); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return executeTemplate(out, tmplName, tmplPath, commit, nil, langMimeMap)
|
||||
}
|
||||
|
@ -157,7 +157,6 @@ func getTokens(samples []string) ([]string, error) {
|
||||
|
||||
func executeFrequenciesTemplate(out io.Writer, freqs *samplesFrequencies, tmplPath, tmplName, commit string) error {
|
||||
fmap := template.FuncMap{
|
||||
"getCommit": func() string { return commit },
|
||||
"toFloat64": func(num int) string { return fmt.Sprintf("%f", float64(num)) },
|
||||
"orderKeys": func(m map[string]int) []string {
|
||||
keys := make([]string, 0, len(m))
|
||||
@ -187,11 +186,5 @@ func executeFrequenciesTemplate(out io.Writer, freqs *samplesFrequencies, tmplPa
|
||||
},
|
||||
"quote": strconv.Quote,
|
||||
}
|
||||
|
||||
t := template.Must(template.New(tmplName).Funcs(fmap).ParseFiles(tmplPath))
|
||||
if err := t.Execute(out, freqs); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return executeTemplate(out, tmplName, tmplPath, commit, fmap, freqs)
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Code generated by gopkg.in/src-d/enry.v1/internal/code-generator DO NOT EDIT.
|
||||
// Extracted from github/linguist commit: d5c8db3fb91963c4b2762ca2ea2ff7cfac109f68
|
||||
|
||||
package data
|
||||
|
||||
// LanguagesByAlias keeps alias for different languages and use the name of the languages as an alias too.
|
||||
// All the keys (alias or not) are written in lower case and the whitespaces has been replaced by underscores.
|
||||
var LanguagesByAlias = map[string]string{
|
||||
|
@ -1,8 +1,7 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Code generated by gopkg.in/src-d/enry.v1/internal/code-generator DO NOT EDIT.
|
||||
// Extracted from github/linguist commit: d5c8db3fb91963c4b2762ca2ea2ff7cfac109f68
|
||||
|
||||
package data
|
||||
|
||||
// linguist's commit from which files were generated.
|
||||
var LinguistCommit = "d5c8db3fb91963c4b2762ca2ea2ff7cfac109f68"
|
||||
|
@ -1,9 +1,8 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Code generated by gopkg.in/src-d/enry.v1/internal/code-generator DO NOT EDIT.
|
||||
// Extracted from github/linguist commit: d5c8db3fb91963c4b2762ca2ea2ff7cfac109f68
|
||||
|
||||
package data
|
||||
|
||||
import "gopkg.in/toqueteos/substring.v1"
|
||||
|
||||
type languageMatcher func([]byte) []string
|
||||
|
@ -1,9 +1,8 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Code generated by gopkg.in/src-d/enry.v1/internal/code-generator DO NOT EDIT.
|
||||
// Extracted from github/linguist commit: d5c8db3fb91963c4b2762ca2ea2ff7cfac109f68
|
||||
|
||||
package data
|
||||
|
||||
import "gopkg.in/toqueteos/substring.v1"
|
||||
|
||||
var DocumentationMatchers = substring.Or(
|
||||
|
@ -1,9 +1,8 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Code generated by gopkg.in/src-d/enry.v1/internal/code-generator DO NOT EDIT.
|
||||
// Extracted from github/linguist commit: d5c8db3fb91963c4b2762ca2ea2ff7cfac109f68
|
||||
|
||||
package data
|
||||
|
||||
var LanguagesByExtension = map[string][]string{
|
||||
".1": {"Roff"},
|
||||
".1in": {"Roff"},
|
||||
|
@ -1,9 +1,8 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Code generated by gopkg.in/src-d/enry.v1/internal/code-generator DO NOT EDIT.
|
||||
// Extracted from github/linguist commit: d5c8db3fb91963c4b2762ca2ea2ff7cfac109f68
|
||||
|
||||
package data
|
||||
|
||||
var LanguagesByFilename = map[string][]string{
|
||||
".Rprofile": {"R"},
|
||||
".XCompose": {"XCompose"},
|
||||
|
@ -1,9 +1,8 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Code generated by gopkg.in/src-d/enry.v1/internal/code-generator DO NOT EDIT.
|
||||
// Extracted from github/linguist commit: d5c8db3fb91963c4b2762ca2ea2ff7cfac109f68
|
||||
|
||||
package data
|
||||
|
||||
var LanguagesLogProbabilities = map[string]float64{
|
||||
"1C Enterprise": -5.724674,
|
||||
"ABAP": -7.516433,
|
||||
|
@ -1,9 +1,8 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Code generated by gopkg.in/src-d/enry.v1/internal/code-generator DO NOT EDIT.
|
||||
// Extracted from github/linguist commit: d5c8db3fb91963c4b2762ca2ea2ff7cfac109f68
|
||||
|
||||
package data
|
||||
|
||||
var LanguagesByInterpreter = map[string][]string{
|
||||
"Rscript": {"R"},
|
||||
"apl": {"APL"},
|
||||
|
@ -1,9 +1,8 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Code generated by gopkg.in/src-d/enry.v1/internal/code-generator DO NOT EDIT.
|
||||
// Extracted from github/linguist commit: d5c8db3fb91963c4b2762ca2ea2ff7cfac109f68
|
||||
|
||||
package data
|
||||
|
||||
var LanguagesMime = map[string]string{
|
||||
"AGS Script": "text/x-c++src",
|
||||
"APL": "text/apl",
|
||||
|
@ -1,9 +1,8 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Code generated by gopkg.in/src-d/enry.v1/internal/code-generator DO NOT EDIT.
|
||||
// Extracted from github/linguist commit: d5c8db3fb91963c4b2762ca2ea2ff7cfac109f68
|
||||
|
||||
package data
|
||||
|
||||
var LanguagesType = map[string]int{
|
||||
"1C Enterprise": 2,
|
||||
"ABAP": 2,
|
||||
|
@ -1,9 +1,8 @@
|
||||
package data
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Code generated by gopkg.in/src-d/enry.v1/internal/code-generator DO NOT EDIT.
|
||||
// Extracted from github/linguist commit: d5c8db3fb91963c4b2762ca2ea2ff7cfac109f68
|
||||
|
||||
package data
|
||||
|
||||
import "gopkg.in/toqueteos/substring.v1"
|
||||
|
||||
var VendorMatchers = substring.Or(
|
||||
|
@ -2,11 +2,9 @@ package generator
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"gopkg.in/yaml.v2"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"text/template"
|
||||
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
var typeToTypeConst = map[string]int{
|
||||
@ -48,14 +46,5 @@ func buildLanguageTypeMap(languages map[string]*languageInfo) map[string]int {
|
||||
}
|
||||
|
||||
func executeTypesTemplate(out io.Writer, langTypeMap map[string]int, tmplPath, tmplName, commit string) error {
|
||||
fmap := template.FuncMap{
|
||||
"getCommit": func() string { return commit },
|
||||
}
|
||||
|
||||
t := template.Must(template.New(tmplName).Funcs(fmap).ParseFiles(tmplPath))
|
||||
if err := t.Execute(out, langTypeMap); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return executeTemplate(out, tmplName, tmplPath, commit, nil, langTypeMap)
|
||||
}
|
||||
|
@ -2,11 +2,9 @@ package generator
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"gopkg.in/yaml.v2"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"text/template"
|
||||
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// Vendor reads from fileToParse and builds source file from tmplPath. It complies with type File signature.
|
||||
@ -30,14 +28,5 @@ func Vendor(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string)
|
||||
}
|
||||
|
||||
func executeVendorTemplate(out io.Writer, regexpList []string, tmplPath, tmplName, commit string) error {
|
||||
fmap := template.FuncMap{
|
||||
"getCommit": func() string { return commit },
|
||||
}
|
||||
|
||||
t := template.Must(template.New(tmplName).Funcs(fmap).ParseFiles(tmplPath))
|
||||
if err := t.Execute(out, regexpList); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return executeTemplate(out, tmplName, tmplPath, commit, nil, regexpList)
|
||||
}
|
||||
|
@ -92,17 +92,17 @@ func main() {
|
||||
}
|
||||
|
||||
fileList := []*generatorFiles{
|
||||
&generatorFiles{generator.Extensions, languagesYAML, "", extensionsFile, extensionsTmplPath, extensionsTmpl, commit},
|
||||
&generatorFiles{generator.Heuristics, heuristicsRuby, "", contentFile, contentTmplPath, contentTmpl, commit},
|
||||
&generatorFiles{generator.Vendor, vendorYAML, "", vendorFile, vendorTmplPath, vendorTmpl, commit},
|
||||
&generatorFiles{generator.Documentation, documentationYAML, "", documentationFile, documentationTmplPath, documentationTmpl, commit},
|
||||
&generatorFiles{generator.Types, languagesYAML, "", typeFile, typeTmplPath, typeTmpl, commit},
|
||||
&generatorFiles{generator.Interpreters, languagesYAML, "", interpretersFile, interpretersTmplPath, interpretersTmpl, commit},
|
||||
&generatorFiles{generator.Filenames, languagesYAML, samplesDir, filenamesFile, filenamesTmplPath, filenamesTmpl, commit},
|
||||
&generatorFiles{generator.Aliases, languagesYAML, "", aliasesFile, aliasesTmplPath, aliasesTmpl, commit},
|
||||
&generatorFiles{generator.Frequencies, "", samplesDir, frequenciesFile, frequenciesTmplPath, frequenciesTmpl, commit},
|
||||
&generatorFiles{generator.Commit, "", "", commitFile, commitTmplPath, commitTmpl, commit},
|
||||
&generatorFiles{generator.MimeType, languagesYAML, "", mimeTypeFile, mimeTypeTmplPath, mimeTypeTmpl, commit},
|
||||
{generator.Extensions, languagesYAML, "", extensionsFile, extensionsTmplPath, extensionsTmpl, commit},
|
||||
{generator.Heuristics, heuristicsRuby, "", contentFile, contentTmplPath, contentTmpl, commit},
|
||||
{generator.Vendor, vendorYAML, "", vendorFile, vendorTmplPath, vendorTmpl, commit},
|
||||
{generator.Documentation, documentationYAML, "", documentationFile, documentationTmplPath, documentationTmpl, commit},
|
||||
{generator.Types, languagesYAML, "", typeFile, typeTmplPath, typeTmpl, commit},
|
||||
{generator.Interpreters, languagesYAML, "", interpretersFile, interpretersTmplPath, interpretersTmpl, commit},
|
||||
{generator.Filenames, languagesYAML, samplesDir, filenamesFile, filenamesTmplPath, filenamesTmpl, commit},
|
||||
{generator.Aliases, languagesYAML, "", aliasesFile, aliasesTmplPath, aliasesTmpl, commit},
|
||||
{generator.Frequencies, "", samplesDir, frequenciesFile, frequenciesTmplPath, frequenciesTmpl, commit},
|
||||
{generator.Commit, "", "", commitFile, commitTmplPath, commitTmpl, commit},
|
||||
{generator.MimeType, languagesYAML, "", mimeTypeFile, mimeTypeTmplPath, mimeTypeTmpl, commit},
|
||||
}
|
||||
|
||||
for _, file := range fileList {
|
||||
|
Reference in New Issue
Block a user