mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-11-10 13:32:24 +00:00
commit
9d59e0046c
26
internal/code-generator/assets/type.go.tmpl
Normal file
26
internal/code-generator/assets/type.go.tmpl
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package slinguist
|
||||||
|
|
||||||
|
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
||||||
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
|
// Extracted from github/linguist commit: {{ getCommit }}
|
||||||
|
|
||||||
|
type Type int
|
||||||
|
|
||||||
|
const (
|
||||||
|
TypeUnknown Type = iota
|
||||||
|
TypeData
|
||||||
|
TypeProgramming
|
||||||
|
TypeMarkup
|
||||||
|
TypeProse
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetLanguageType(language string) (langType Type) {
|
||||||
|
langType, _ = languagesType[language]
|
||||||
|
return langType
|
||||||
|
}
|
||||||
|
|
||||||
|
var languagesType = map[string]Type{
|
||||||
|
{{range $language, $type := . -}}
|
||||||
|
"{{ $language }}": {{ $type -}},
|
||||||
|
{{end -}}
|
||||||
|
}
|
@ -17,6 +17,7 @@ const (
|
|||||||
formatedContentGold = "test_files/formated_content.gold"
|
formatedContentGold = "test_files/formated_content.gold"
|
||||||
formatedVendorGold = "test_files/formated_vendor.gold"
|
formatedVendorGold = "test_files/formated_vendor.gold"
|
||||||
formatedDocumentationGold = "test_files/formated_documentation.gold"
|
formatedDocumentationGold = "test_files/formated_documentation.gold"
|
||||||
|
formatedTypesGold = "test_files/formated_type.gold"
|
||||||
|
|
||||||
// Languages test
|
// Languages test
|
||||||
ymlTestFile = "test_files/languages.test.yml"
|
ymlTestFile = "test_files/languages.test.yml"
|
||||||
@ -41,6 +42,12 @@ const (
|
|||||||
documentationGold = "test_files/documentation.gold"
|
documentationGold = "test_files/documentation.gold"
|
||||||
documentationTestTmplPath = "test_files/documentation.test.go.tmpl"
|
documentationTestTmplPath = "test_files/documentation.test.go.tmpl"
|
||||||
documentationTestTmplName = "documentation.test.go.tmpl"
|
documentationTestTmplName = "documentation.test.go.tmpl"
|
||||||
|
|
||||||
|
// Types test
|
||||||
|
typesTestFile = "test_files/type.test.yml"
|
||||||
|
typesGold = "test_files/type.gold"
|
||||||
|
typesTestTmplPath = "test_files/type.test.go.tmpl"
|
||||||
|
typesTestTmplName = "type.test.go.tmpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFromFile(t *testing.T) {
|
func TestFromFile(t *testing.T) {
|
||||||
@ -56,6 +63,9 @@ func TestFromFile(t *testing.T) {
|
|||||||
goldDocumentation, err := ioutil.ReadFile(formatedDocumentationGold)
|
goldDocumentation, err := ioutil.ReadFile(formatedDocumentationGold)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
goldTypes, err := ioutil.ReadFile(formatedTypesGold)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
outPathLang, err := ioutil.TempFile("/tmp", "generator-test-")
|
outPathLang, err := ioutil.TempFile("/tmp", "generator-test-")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
defer os.Remove(outPathLang.Name())
|
defer os.Remove(outPathLang.Name())
|
||||||
@ -72,6 +82,10 @@ func TestFromFile(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
defer os.Remove(outPathDocumentation.Name())
|
defer os.Remove(outPathDocumentation.Name())
|
||||||
|
|
||||||
|
outPathTypes, err := ioutil.TempFile("/tmp", "generator-test-")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
defer os.Remove(outPathTypes.Name())
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
fileToParse string
|
fileToParse string
|
||||||
@ -122,6 +136,16 @@ func TestFromFile(t *testing.T) {
|
|||||||
generate: Documentation,
|
generate: Documentation,
|
||||||
wantOut: goldDocumentation,
|
wantOut: goldDocumentation,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "tyTestFromFile_Types",
|
||||||
|
fileToParse: typesTestFile,
|
||||||
|
outPath: outPathTypes.Name(),
|
||||||
|
tmplPath: typesTestTmplPath,
|
||||||
|
tmplName: typesTestTmplName,
|
||||||
|
commit: commitTest,
|
||||||
|
generate: Types,
|
||||||
|
wantOut: goldTypes,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
@ -270,3 +294,37 @@ func TestDocumentation(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTypes(t *testing.T) {
|
||||||
|
gold, err := ioutil.ReadFile(typesGold)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
input, err := ioutil.ReadFile(typesTestFile)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input []byte
|
||||||
|
tmplPath string
|
||||||
|
tmplName string
|
||||||
|
commit string
|
||||||
|
wantOut []byte
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "TestTypes",
|
||||||
|
input: input,
|
||||||
|
tmplPath: typesTestTmplPath,
|
||||||
|
tmplName: typesTestTmplName,
|
||||||
|
commit: commitTest,
|
||||||
|
wantOut: gold,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
out, err := Types(tt.input, tt.tmplPath, tt.tmplName, tt.commit)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.EqualValues(t, tt.wantOut, out, fmt.Sprintf("Types() = %v, want %v", string(out), string(tt.wantOut)))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2,7 +2,6 @@ package generator
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
@ -10,23 +9,28 @@ import (
|
|||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
type languageInfo struct {
|
||||||
// ErrExtensionsNotFound is the error returned if data parsed doesn't contain extensions.
|
Type string `yaml:"type,omitempty"`
|
||||||
ErrExtensionsNotFound = errors.New("extensions not found")
|
Aliases []string `yaml:"aliases,omitempty,flow"`
|
||||||
)
|
Extensions []string `yaml:"extensions,omitempty,flow"`
|
||||||
|
Interpreters []string `yaml:"interpreters,omitempty,flow"`
|
||||||
|
Group string `yaml:"group,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// Languages reads from buf and builds languages.go file from languagesTmplPath.
|
// Languages reads from buf and builds languages.go file from languagesTmplPath.
|
||||||
func Languages(data []byte, languagesTmplPath, languagesTmplName, commit string) ([]byte, error) {
|
func Languages(data []byte, languagesTmplPath, languagesTmplName, commit string) ([]byte, error) {
|
||||||
var yamlSlice yaml.MapSlice
|
languages := make(map[string]*languageInfo)
|
||||||
if err := yaml.Unmarshal(data, &yamlSlice); err != nil {
|
if err := yaml.Unmarshal(data, &languages); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
languagesByExtension, err := buildExtensionLanguageMap(yamlSlice)
|
orderedKeyList, err := getAlphabeticalOrderedKeys(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
languagesByExtension := buildExtensionLanguageMap(languages, orderedKeyList)
|
||||||
|
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
if err := executeLanguagesTemplate(buf, languagesByExtension, languagesTmplPath, languagesTmplName, commit); err != nil {
|
if err := executeLanguagesTemplate(buf, languagesByExtension, languagesTmplPath, languagesTmplName, commit); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -35,46 +39,30 @@ func Languages(data []byte, languagesTmplPath, languagesTmplName, commit string)
|
|||||||
return buf.Bytes(), nil
|
return buf.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildExtensionLanguageMap(yamlSlice yaml.MapSlice) (map[string][]string, error) {
|
func getAlphabeticalOrderedKeys(data []byte) ([]string, error) {
|
||||||
extensionLangsMap := make(map[string][]string)
|
var yamlSlice yaml.MapSlice
|
||||||
for _, lang := range yamlSlice {
|
if err := yaml.Unmarshal(data, &yamlSlice); err != nil {
|
||||||
extensions, err := findExtensions(lang.Value.(yaml.MapSlice))
|
|
||||||
if err != nil && err != ErrExtensionsNotFound {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
fillMap(extensionLangsMap, lang.Key.(string), extensions)
|
orderedKeyList := make([]string, 0)
|
||||||
|
for _, lang := range yamlSlice {
|
||||||
|
orderedKeyList = append(orderedKeyList, lang.Key.(string))
|
||||||
}
|
}
|
||||||
|
|
||||||
return extensionLangsMap, nil
|
return orderedKeyList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func findExtensions(items yaml.MapSlice) ([]string, error) {
|
func buildExtensionLanguageMap(languages map[string]*languageInfo, orderedKeyList []string) map[string][]string {
|
||||||
const extField = "extensions"
|
extensionLangsMap := make(map[string][]string)
|
||||||
for _, item := range items {
|
for _, lang := range orderedKeyList {
|
||||||
if item.Key == extField {
|
langInfo := languages[lang]
|
||||||
extensions := toStringSlice(item.Value.([]interface{}))
|
for _, extension := range langInfo.Extensions {
|
||||||
return extensions, nil
|
extensionLangsMap[extension] = append(extensionLangsMap[extension], lang)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, ErrExtensionsNotFound
|
return extensionLangsMap
|
||||||
}
|
|
||||||
|
|
||||||
func toStringSlice(slice []interface{}) []string {
|
|
||||||
extensions := make([]string, 0, len(slice))
|
|
||||||
for _, element := range slice {
|
|
||||||
extension := element.(string)
|
|
||||||
extensions = append(extensions, extension)
|
|
||||||
}
|
|
||||||
|
|
||||||
return extensions
|
|
||||||
}
|
|
||||||
|
|
||||||
func fillMap(extensionLangs map[string][]string, lang string, extensions []string) {
|
|
||||||
for _, extension := range extensions {
|
|
||||||
extensionLangs[extension] = append(extensionLangs[extension], lang)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func executeLanguagesTemplate(out io.Writer, languagesByExtension map[string][]string, languagesTmplPath, languagesTmpl, commit string) error {
|
func executeLanguagesTemplate(out io.Writer, languagesByExtension map[string][]string, languagesTmplPath, languagesTmpl, commit string) error {
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package slinguist
|
||||||
|
|
||||||
|
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
||||||
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
|
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7
|
||||||
|
|
||||||
|
type Type int
|
||||||
|
|
||||||
|
const (
|
||||||
|
TypeUnknown Type = iota
|
||||||
|
TypeData
|
||||||
|
TypeProgramming
|
||||||
|
TypeMarkup
|
||||||
|
TypeProse
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetLanguageType(language string) (langType Type) {
|
||||||
|
langType, _ = languagesType[language]
|
||||||
|
return langType
|
||||||
|
}
|
||||||
|
|
||||||
|
var languagesType = map[string]Type{
|
||||||
|
"Scaml": TypeMarkup,
|
||||||
|
"Scheme": TypeProgramming,
|
||||||
|
"Scilab": TypeProgramming,
|
||||||
|
"Self": TypeProgramming,
|
||||||
|
}
|
27
internal/code-generator/generator/test_files/type.gold
Normal file
27
internal/code-generator/generator/test_files/type.gold
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package slinguist
|
||||||
|
|
||||||
|
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
||||||
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
|
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7
|
||||||
|
|
||||||
|
type Type int
|
||||||
|
|
||||||
|
const (
|
||||||
|
TypeUnknown Type = iota
|
||||||
|
TypeData
|
||||||
|
TypeProgramming
|
||||||
|
TypeMarkup
|
||||||
|
TypeProse
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetLanguageType(language string) (langType Type) {
|
||||||
|
langType, _ = languagesType[language]
|
||||||
|
return langType
|
||||||
|
}
|
||||||
|
|
||||||
|
var languagesType = map[string]Type{
|
||||||
|
"Scaml": TypeMarkup,
|
||||||
|
"Scheme": TypeProgramming,
|
||||||
|
"Scilab": TypeProgramming,
|
||||||
|
"Self": TypeProgramming,
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package slinguist
|
||||||
|
|
||||||
|
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
||||||
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
|
// Extracted from github/linguist commit: {{ getCommit }}
|
||||||
|
|
||||||
|
type Type int
|
||||||
|
|
||||||
|
const (
|
||||||
|
TypeUnknown Type = iota
|
||||||
|
TypeData
|
||||||
|
TypeProgramming
|
||||||
|
TypeMarkup
|
||||||
|
TypeProse
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetLanguageType(language string) (langType Type) {
|
||||||
|
langType, _ = languagesType[language]
|
||||||
|
return langType
|
||||||
|
}
|
||||||
|
|
||||||
|
var languagesType = map[string]Type{
|
||||||
|
{{range $language, $type := . -}}
|
||||||
|
"{{ $language }}": {{ $type -}},
|
||||||
|
{{end -}}
|
||||||
|
}
|
46
internal/code-generator/generator/test_files/type.test.yml
Normal file
46
internal/code-generator/generator/test_files/type.test.yml
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
---
|
||||||
|
Scaml:
|
||||||
|
group: HTML
|
||||||
|
type: markup
|
||||||
|
extensions:
|
||||||
|
- ".scaml"
|
||||||
|
tm_scope: source.scaml
|
||||||
|
ace_mode: text
|
||||||
|
language_id: 342
|
||||||
|
Scheme:
|
||||||
|
type: programming
|
||||||
|
color: "#1e4aec"
|
||||||
|
extensions:
|
||||||
|
- ".scm"
|
||||||
|
- ".sld"
|
||||||
|
- ".sls"
|
||||||
|
- ".sps"
|
||||||
|
- ".ss"
|
||||||
|
interpreters:
|
||||||
|
- guile
|
||||||
|
- bigloo
|
||||||
|
- chicken
|
||||||
|
- csi
|
||||||
|
- gosh
|
||||||
|
- r6rs
|
||||||
|
ace_mode: scheme
|
||||||
|
codemirror_mode: scheme
|
||||||
|
codemirror_mime_type: text/x-scheme
|
||||||
|
language_id: 343
|
||||||
|
Scilab:
|
||||||
|
type: programming
|
||||||
|
extensions:
|
||||||
|
- ".sci"
|
||||||
|
- ".sce"
|
||||||
|
- ".tst"
|
||||||
|
ace_mode: text
|
||||||
|
language_id: 344
|
||||||
|
Self:
|
||||||
|
type: programming
|
||||||
|
color: "#0579aa"
|
||||||
|
extensions:
|
||||||
|
- ".self"
|
||||||
|
tm_scope: none
|
||||||
|
ace_mode: text
|
||||||
|
language_id: 345
|
||||||
|
|
55
internal/code-generator/generator/types.go
Normal file
55
internal/code-generator/generator/types.go
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
package generator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"io"
|
||||||
|
"text/template"
|
||||||
|
|
||||||
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
var typeToTypeConst = map[string]string{
|
||||||
|
"data": "TypeData",
|
||||||
|
"programming": "TypeProgramming",
|
||||||
|
"markup": "TypeMarkup",
|
||||||
|
"prose": "TypeProse",
|
||||||
|
}
|
||||||
|
|
||||||
|
// Types reads from buf and builds type.go file from typeTmplPath.
|
||||||
|
func Types(data []byte, typeTmplPath, typeTmplName, commit string) ([]byte, error) {
|
||||||
|
languages := make(map[string]*languageInfo)
|
||||||
|
if err := yaml.Unmarshal(data, &languages); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
langTypeMap := buildLanguageTypeMap(languages)
|
||||||
|
|
||||||
|
buf := &bytes.Buffer{}
|
||||||
|
if err := executeTypesTemplate(buf, langTypeMap, typeTmplPath, typeTmplName, commit); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf.Bytes(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildLanguageTypeMap(languages map[string]*languageInfo) map[string]string {
|
||||||
|
langTypeMap := make(map[string]string)
|
||||||
|
for lang, info := range languages {
|
||||||
|
langTypeMap[lang] = typeToTypeConst[info.Type]
|
||||||
|
}
|
||||||
|
|
||||||
|
return langTypeMap
|
||||||
|
}
|
||||||
|
|
||||||
|
func executeTypesTemplate(out io.Writer, langTypeMap map[string]string, typeTmplPath, typeTmpl, commit string) error {
|
||||||
|
fmap := template.FuncMap{
|
||||||
|
"getCommit": func() string { return commit },
|
||||||
|
}
|
||||||
|
|
||||||
|
t := template.Must(template.New(typeTmpl).Funcs(fmap).ParseFiles(typeTmplPath))
|
||||||
|
if err := t.Execute(out, langTypeMap); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
@ -8,49 +8,65 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// languages.go generation
|
||||||
languagesYAML = ".linguist/lib/linguist/languages.yml"
|
languagesYAML = ".linguist/lib/linguist/languages.yml"
|
||||||
langFile = "languages.go"
|
langFile = "languages.go"
|
||||||
languagesTmplPath = "internal/code-generator/assets/languages.go.tmpl"
|
languagesTmplPath = "internal/code-generator/assets/languages.go.tmpl"
|
||||||
languagesTmpl = "languages.go.tmpl"
|
languagesTmpl = "languages.go.tmpl"
|
||||||
|
|
||||||
|
// content.go generation
|
||||||
heuristicsRuby = ".linguist/lib/linguist/heuristics.rb"
|
heuristicsRuby = ".linguist/lib/linguist/heuristics.rb"
|
||||||
contentFile = "content.go"
|
contentFile = "content.go"
|
||||||
contentTmplPath = "internal/code-generator/assets/content.go.tmpl"
|
contentTmplPath = "internal/code-generator/assets/content.go.tmpl"
|
||||||
contentTmpl = "content.go.tmpl"
|
contentTmpl = "content.go.tmpl"
|
||||||
|
|
||||||
|
// vendor_matchers.go generation
|
||||||
vendorYAML = ".linguist/lib/linguist/vendor.yml"
|
vendorYAML = ".linguist/lib/linguist/vendor.yml"
|
||||||
vendorFile = "vendor_matchers.go"
|
vendorFile = "vendor_matchers.go"
|
||||||
vendorTmplPath = "internal/code-generator/assets/vendor.go.tmpl"
|
vendorTmplPath = "internal/code-generator/assets/vendor.go.tmpl"
|
||||||
vendorTmpl = "vendor.go.tmpl"
|
vendorTmpl = "vendor.go.tmpl"
|
||||||
|
|
||||||
|
// documentation_matchers.go generation
|
||||||
documentationYAML = ".linguist/lib/linguist/documentation.yml"
|
documentationYAML = ".linguist/lib/linguist/documentation.yml"
|
||||||
documentationFile = "documentation_matchers.go"
|
documentationFile = "documentation_matchers.go"
|
||||||
documentationTmplPath = "internal/code-generator/assets/documentation.go.tmpl"
|
documentationTmplPath = "internal/code-generator/assets/documentation.go.tmpl"
|
||||||
documentationTmpl = "documentation.go.tmpl"
|
documentationTmpl = "documentation.go.tmpl"
|
||||||
|
|
||||||
|
// type.go generation
|
||||||
|
typeFile = "type.go"
|
||||||
|
typeTmplPath = "internal/code-generator/assets/type.go.tmpl"
|
||||||
|
typeTmpl = "type.go.tmpl"
|
||||||
|
|
||||||
commitPath = ".git/refs/heads/master"
|
commitPath = ".git/refs/heads/master"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type generatorArgs struct {
|
||||||
|
fileToParse string
|
||||||
|
outPath string
|
||||||
|
tmplPath string
|
||||||
|
tmplName string
|
||||||
|
commit string
|
||||||
|
generate generator.Func
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
commit, err := getCommit(commitPath)
|
commit, err := getCommit(commitPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("couldn't find commit: %v", err)
|
log.Printf("couldn't find commit: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := generator.FromFile(languagesYAML, langFile, languagesTmplPath, languagesTmpl, commit, generator.Languages); err != nil {
|
argsList := []*generatorArgs{
|
||||||
log.Println(err)
|
&generatorArgs{languagesYAML, langFile, languagesTmplPath, languagesTmpl, commit, generator.Languages},
|
||||||
|
&generatorArgs{heuristicsRuby, contentFile, contentTmplPath, contentTmpl, commit, generator.Heuristics},
|
||||||
|
&generatorArgs{vendorYAML, vendorFile, vendorTmplPath, vendorTmpl, commit, generator.Vendor},
|
||||||
|
&generatorArgs{documentationYAML, documentationFile, documentationTmplPath, documentationTmpl, commit, generator.Documentation},
|
||||||
|
&generatorArgs{languagesYAML, typeFile, typeTmplPath, typeTmpl, commit, generator.Types},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := generator.FromFile(heuristicsRuby, contentFile, contentTmplPath, contentTmpl, commit, generator.Heuristics); err != nil {
|
for _, args := range argsList {
|
||||||
|
if err := generator.FromFile(args.fileToParse, args.outPath, args.tmplPath, args.tmplName, args.commit, args.generate); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := generator.FromFile(vendorYAML, vendorFile, vendorTmplPath, vendorTmpl, commit, generator.Vendor); err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := generator.FromFile(documentationYAML, documentationFile, documentationTmplPath, documentationTmpl, commit, generator.Documentation); err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
467
type.go
Normal file
467
type.go
Normal file
@ -0,0 +1,467 @@
|
|||||||
|
package slinguist
|
||||||
|
|
||||||
|
// CODE GENERATED AUTOMATICALLY WITH github.com/src-d/simple-linguist/cli/slinguist-generate
|
||||||
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
|
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9
|
||||||
|
|
||||||
|
type Type int
|
||||||
|
|
||||||
|
const (
|
||||||
|
TypeUnknown Type = iota
|
||||||
|
TypeData
|
||||||
|
TypeProgramming
|
||||||
|
TypeMarkup
|
||||||
|
TypeProse
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetLanguageType(language string) (langType Type) {
|
||||||
|
langType, _ = languagesType[language]
|
||||||
|
return langType
|
||||||
|
}
|
||||||
|
|
||||||
|
var languagesType = map[string]Type{
|
||||||
|
"1C Enterprise": TypeProgramming,
|
||||||
|
"ABAP": TypeProgramming,
|
||||||
|
"ABNF": TypeData,
|
||||||
|
"AGS Script": TypeProgramming,
|
||||||
|
"AMPL": TypeProgramming,
|
||||||
|
"ANTLR": TypeProgramming,
|
||||||
|
"API Blueprint": TypeMarkup,
|
||||||
|
"APL": TypeProgramming,
|
||||||
|
"ASN.1": TypeData,
|
||||||
|
"ASP": TypeProgramming,
|
||||||
|
"ATS": TypeProgramming,
|
||||||
|
"ActionScript": TypeProgramming,
|
||||||
|
"Ada": TypeProgramming,
|
||||||
|
"Agda": TypeProgramming,
|
||||||
|
"Alloy": TypeProgramming,
|
||||||
|
"Alpine Abuild": TypeProgramming,
|
||||||
|
"Ant Build System": TypeData,
|
||||||
|
"ApacheConf": TypeMarkup,
|
||||||
|
"Apex": TypeProgramming,
|
||||||
|
"Apollo Guidance Computer": TypeProgramming,
|
||||||
|
"AppleScript": TypeProgramming,
|
||||||
|
"Arc": TypeProgramming,
|
||||||
|
"Arduino": TypeProgramming,
|
||||||
|
"AsciiDoc": TypeProse,
|
||||||
|
"AspectJ": TypeProgramming,
|
||||||
|
"Assembly": TypeProgramming,
|
||||||
|
"Augeas": TypeProgramming,
|
||||||
|
"AutoHotkey": TypeProgramming,
|
||||||
|
"AutoIt": TypeProgramming,
|
||||||
|
"Awk": TypeProgramming,
|
||||||
|
"Batchfile": TypeProgramming,
|
||||||
|
"Befunge": TypeProgramming,
|
||||||
|
"Bison": TypeProgramming,
|
||||||
|
"BitBake": TypeProgramming,
|
||||||
|
"Blade": TypeMarkup,
|
||||||
|
"BlitzBasic": TypeProgramming,
|
||||||
|
"BlitzMax": TypeProgramming,
|
||||||
|
"Bluespec": TypeProgramming,
|
||||||
|
"Boo": TypeProgramming,
|
||||||
|
"Brainfuck": TypeProgramming,
|
||||||
|
"Brightscript": TypeProgramming,
|
||||||
|
"Bro": TypeProgramming,
|
||||||
|
"C": TypeProgramming,
|
||||||
|
"C#": TypeProgramming,
|
||||||
|
"C++": TypeProgramming,
|
||||||
|
"C-ObjDump": TypeData,
|
||||||
|
"C2hs Haskell": TypeProgramming,
|
||||||
|
"CLIPS": TypeProgramming,
|
||||||
|
"CMake": TypeProgramming,
|
||||||
|
"COBOL": TypeProgramming,
|
||||||
|
"COLLADA": TypeData,
|
||||||
|
"CSON": TypeData,
|
||||||
|
"CSS": TypeMarkup,
|
||||||
|
"CSV": TypeData,
|
||||||
|
"Cap'n Proto": TypeProgramming,
|
||||||
|
"CartoCSS": TypeProgramming,
|
||||||
|
"Ceylon": TypeProgramming,
|
||||||
|
"Chapel": TypeProgramming,
|
||||||
|
"Charity": TypeProgramming,
|
||||||
|
"ChucK": TypeProgramming,
|
||||||
|
"Cirru": TypeProgramming,
|
||||||
|
"Clarion": TypeProgramming,
|
||||||
|
"Clean": TypeProgramming,
|
||||||
|
"Click": TypeProgramming,
|
||||||
|
"Clojure": TypeProgramming,
|
||||||
|
"CoffeeScript": TypeProgramming,
|
||||||
|
"ColdFusion": TypeProgramming,
|
||||||
|
"ColdFusion CFC": TypeProgramming,
|
||||||
|
"Common Lisp": TypeProgramming,
|
||||||
|
"Component Pascal": TypeProgramming,
|
||||||
|
"Cool": TypeProgramming,
|
||||||
|
"Coq": TypeProgramming,
|
||||||
|
"Cpp-ObjDump": TypeData,
|
||||||
|
"Creole": TypeProse,
|
||||||
|
"Crystal": TypeProgramming,
|
||||||
|
"Csound": TypeProgramming,
|
||||||
|
"Csound Document": TypeProgramming,
|
||||||
|
"Csound Score": TypeProgramming,
|
||||||
|
"Cuda": TypeProgramming,
|
||||||
|
"Cycript": TypeProgramming,
|
||||||
|
"Cython": TypeProgramming,
|
||||||
|
"D": TypeProgramming,
|
||||||
|
"D-ObjDump": TypeData,
|
||||||
|
"DIGITAL Command Language": TypeProgramming,
|
||||||
|
"DM": TypeProgramming,
|
||||||
|
"DNS Zone": TypeData,
|
||||||
|
"DTrace": TypeProgramming,
|
||||||
|
"Darcs Patch": TypeData,
|
||||||
|
"Dart": TypeProgramming,
|
||||||
|
"Diff": TypeData,
|
||||||
|
"Dockerfile": TypeData,
|
||||||
|
"Dogescript": TypeProgramming,
|
||||||
|
"Dylan": TypeProgramming,
|
||||||
|
"E": TypeProgramming,
|
||||||
|
"EBNF": TypeData,
|
||||||
|
"ECL": TypeProgramming,
|
||||||
|
"ECLiPSe": TypeProgramming,
|
||||||
|
"EJS": TypeMarkup,
|
||||||
|
"EQ": TypeProgramming,
|
||||||
|
"Eagle": TypeMarkup,
|
||||||
|
"Ecere Projects": TypeData,
|
||||||
|
"Eiffel": TypeProgramming,
|
||||||
|
"Elixir": TypeProgramming,
|
||||||
|
"Elm": TypeProgramming,
|
||||||
|
"Emacs Lisp": TypeProgramming,
|
||||||
|
"EmberScript": TypeProgramming,
|
||||||
|
"Erlang": TypeProgramming,
|
||||||
|
"F#": TypeProgramming,
|
||||||
|
"FLUX": TypeProgramming,
|
||||||
|
"Factor": TypeProgramming,
|
||||||
|
"Fancy": TypeProgramming,
|
||||||
|
"Fantom": TypeProgramming,
|
||||||
|
"Filebench WML": TypeProgramming,
|
||||||
|
"Filterscript": TypeProgramming,
|
||||||
|
"Formatted": TypeData,
|
||||||
|
"Forth": TypeProgramming,
|
||||||
|
"Fortran": TypeProgramming,
|
||||||
|
"FreeMarker": TypeProgramming,
|
||||||
|
"Frege": TypeProgramming,
|
||||||
|
"G-code": TypeData,
|
||||||
|
"GAMS": TypeProgramming,
|
||||||
|
"GAP": TypeProgramming,
|
||||||
|
"GCC Machine Description": TypeProgramming,
|
||||||
|
"GDB": TypeProgramming,
|
||||||
|
"GDScript": TypeProgramming,
|
||||||
|
"GLSL": TypeProgramming,
|
||||||
|
"GN": TypeData,
|
||||||
|
"Game Maker Language": TypeProgramming,
|
||||||
|
"Genie": TypeProgramming,
|
||||||
|
"Genshi": TypeProgramming,
|
||||||
|
"Gentoo Ebuild": TypeProgramming,
|
||||||
|
"Gentoo Eclass": TypeProgramming,
|
||||||
|
"Gettext Catalog": TypeProse,
|
||||||
|
"Gherkin": TypeProgramming,
|
||||||
|
"Glyph": TypeProgramming,
|
||||||
|
"Gnuplot": TypeProgramming,
|
||||||
|
"Go": TypeProgramming,
|
||||||
|
"Golo": TypeProgramming,
|
||||||
|
"Gosu": TypeProgramming,
|
||||||
|
"Grace": TypeProgramming,
|
||||||
|
"Gradle": TypeData,
|
||||||
|
"Grammatical Framework": TypeProgramming,
|
||||||
|
"Graph Modeling Language": TypeData,
|
||||||
|
"GraphQL": TypeData,
|
||||||
|
"Graphviz (DOT)": TypeData,
|
||||||
|
"Groovy": TypeProgramming,
|
||||||
|
"Groovy Server Pages": TypeProgramming,
|
||||||
|
"HCL": TypeProgramming,
|
||||||
|
"HLSL": TypeProgramming,
|
||||||
|
"HTML": TypeMarkup,
|
||||||
|
"HTML+Django": TypeMarkup,
|
||||||
|
"HTML+ECR": TypeMarkup,
|
||||||
|
"HTML+EEX": TypeMarkup,
|
||||||
|
"HTML+ERB": TypeMarkup,
|
||||||
|
"HTML+PHP": TypeMarkup,
|
||||||
|
"HTTP": TypeData,
|
||||||
|
"Hack": TypeProgramming,
|
||||||
|
"Haml": TypeMarkup,
|
||||||
|
"Handlebars": TypeMarkup,
|
||||||
|
"Harbour": TypeProgramming,
|
||||||
|
"Haskell": TypeProgramming,
|
||||||
|
"Haxe": TypeProgramming,
|
||||||
|
"Hy": TypeProgramming,
|
||||||
|
"HyPhy": TypeProgramming,
|
||||||
|
"IDL": TypeProgramming,
|
||||||
|
"IGOR Pro": TypeProgramming,
|
||||||
|
"INI": TypeData,
|
||||||
|
"IRC log": TypeData,
|
||||||
|
"Idris": TypeProgramming,
|
||||||
|
"Inform 7": TypeProgramming,
|
||||||
|
"Inno Setup": TypeProgramming,
|
||||||
|
"Io": TypeProgramming,
|
||||||
|
"Ioke": TypeProgramming,
|
||||||
|
"Isabelle": TypeProgramming,
|
||||||
|
"Isabelle ROOT": TypeProgramming,
|
||||||
|
"J": TypeProgramming,
|
||||||
|
"JFlex": TypeProgramming,
|
||||||
|
"JSON": TypeData,
|
||||||
|
"JSON5": TypeData,
|
||||||
|
"JSONLD": TypeData,
|
||||||
|
"JSONiq": TypeProgramming,
|
||||||
|
"JSX": TypeProgramming,
|
||||||
|
"Jasmin": TypeProgramming,
|
||||||
|
"Java": TypeProgramming,
|
||||||
|
"Java Server Pages": TypeProgramming,
|
||||||
|
"JavaScript": TypeProgramming,
|
||||||
|
"Jison": TypeProgramming,
|
||||||
|
"Jison Lex": TypeProgramming,
|
||||||
|
"Julia": TypeProgramming,
|
||||||
|
"Jupyter Notebook": TypeMarkup,
|
||||||
|
"KRL": TypeProgramming,
|
||||||
|
"KiCad": TypeProgramming,
|
||||||
|
"Kit": TypeMarkup,
|
||||||
|
"Kotlin": TypeProgramming,
|
||||||
|
"LFE": TypeProgramming,
|
||||||
|
"LLVM": TypeProgramming,
|
||||||
|
"LOLCODE": TypeProgramming,
|
||||||
|
"LSL": TypeProgramming,
|
||||||
|
"LabVIEW": TypeProgramming,
|
||||||
|
"Lasso": TypeProgramming,
|
||||||
|
"Latte": TypeMarkup,
|
||||||
|
"Lean": TypeProgramming,
|
||||||
|
"Less": TypeMarkup,
|
||||||
|
"Lex": TypeProgramming,
|
||||||
|
"LilyPond": TypeProgramming,
|
||||||
|
"Limbo": TypeProgramming,
|
||||||
|
"Linker Script": TypeData,
|
||||||
|
"Linux Kernel Module": TypeData,
|
||||||
|
"Liquid": TypeMarkup,
|
||||||
|
"Literate Agda": TypeProgramming,
|
||||||
|
"Literate CoffeeScript": TypeProgramming,
|
||||||
|
"Literate Haskell": TypeProgramming,
|
||||||
|
"LiveScript": TypeProgramming,
|
||||||
|
"Logos": TypeProgramming,
|
||||||
|
"Logtalk": TypeProgramming,
|
||||||
|
"LookML": TypeProgramming,
|
||||||
|
"LoomScript": TypeProgramming,
|
||||||
|
"Lua": TypeProgramming,
|
||||||
|
"M": TypeProgramming,
|
||||||
|
"M4": TypeProgramming,
|
||||||
|
"M4Sugar": TypeProgramming,
|
||||||
|
"MAXScript": TypeProgramming,
|
||||||
|
"MQL4": TypeProgramming,
|
||||||
|
"MQL5": TypeProgramming,
|
||||||
|
"MTML": TypeMarkup,
|
||||||
|
"MUF": TypeProgramming,
|
||||||
|
"Makefile": TypeProgramming,
|
||||||
|
"Mako": TypeProgramming,
|
||||||
|
"Markdown": TypeProse,
|
||||||
|
"Marko": TypeMarkup,
|
||||||
|
"Mask": TypeMarkup,
|
||||||
|
"Mathematica": TypeProgramming,
|
||||||
|
"Matlab": TypeProgramming,
|
||||||
|
"Maven POM": TypeData,
|
||||||
|
"Max": TypeProgramming,
|
||||||
|
"MediaWiki": TypeProse,
|
||||||
|
"Mercury": TypeProgramming,
|
||||||
|
"Meson": TypeProgramming,
|
||||||
|
"Metal": TypeProgramming,
|
||||||
|
"MiniD": TypeProgramming,
|
||||||
|
"Mirah": TypeProgramming,
|
||||||
|
"Modelica": TypeProgramming,
|
||||||
|
"Modula-2": TypeProgramming,
|
||||||
|
"Module Management System": TypeProgramming,
|
||||||
|
"Monkey": TypeProgramming,
|
||||||
|
"Moocode": TypeProgramming,
|
||||||
|
"MoonScript": TypeProgramming,
|
||||||
|
"Myghty": TypeProgramming,
|
||||||
|
"NCL": TypeProgramming,
|
||||||
|
"NL": TypeData,
|
||||||
|
"NSIS": TypeProgramming,
|
||||||
|
"Nemerle": TypeProgramming,
|
||||||
|
"NetLinx": TypeProgramming,
|
||||||
|
"NetLinx+ERB": TypeProgramming,
|
||||||
|
"NetLogo": TypeProgramming,
|
||||||
|
"NewLisp": TypeProgramming,
|
||||||
|
"Nginx": TypeMarkup,
|
||||||
|
"Nim": TypeProgramming,
|
||||||
|
"Ninja": TypeData,
|
||||||
|
"Nit": TypeProgramming,
|
||||||
|
"Nix": TypeProgramming,
|
||||||
|
"Nu": TypeProgramming,
|
||||||
|
"NumPy": TypeProgramming,
|
||||||
|
"OCaml": TypeProgramming,
|
||||||
|
"ObjDump": TypeData,
|
||||||
|
"Objective-C": TypeProgramming,
|
||||||
|
"Objective-C++": TypeProgramming,
|
||||||
|
"Objective-J": TypeProgramming,
|
||||||
|
"Omgrofl": TypeProgramming,
|
||||||
|
"Opa": TypeProgramming,
|
||||||
|
"Opal": TypeProgramming,
|
||||||
|
"OpenCL": TypeProgramming,
|
||||||
|
"OpenEdge ABL": TypeProgramming,
|
||||||
|
"OpenRC runscript": TypeProgramming,
|
||||||
|
"OpenSCAD": TypeProgramming,
|
||||||
|
"OpenType Feature File": TypeData,
|
||||||
|
"Org": TypeProse,
|
||||||
|
"Ox": TypeProgramming,
|
||||||
|
"Oxygene": TypeProgramming,
|
||||||
|
"Oz": TypeProgramming,
|
||||||
|
"P4": TypeProgramming,
|
||||||
|
"PAWN": TypeProgramming,
|
||||||
|
"PHP": TypeProgramming,
|
||||||
|
"PLSQL": TypeProgramming,
|
||||||
|
"PLpgSQL": TypeProgramming,
|
||||||
|
"POV-Ray SDL": TypeProgramming,
|
||||||
|
"Pan": TypeProgramming,
|
||||||
|
"Papyrus": TypeProgramming,
|
||||||
|
"Parrot": TypeProgramming,
|
||||||
|
"Parrot Assembly": TypeProgramming,
|
||||||
|
"Parrot Internal Representation": TypeProgramming,
|
||||||
|
"Pascal": TypeProgramming,
|
||||||
|
"Perl": TypeProgramming,
|
||||||
|
"Perl6": TypeProgramming,
|
||||||
|
"Pic": TypeMarkup,
|
||||||
|
"Pickle": TypeData,
|
||||||
|
"PicoLisp": TypeProgramming,
|
||||||
|
"PigLatin": TypeProgramming,
|
||||||
|
"Pike": TypeProgramming,
|
||||||
|
"Pod": TypeProse,
|
||||||
|
"PogoScript": TypeProgramming,
|
||||||
|
"Pony": TypeProgramming,
|
||||||
|
"PostScript": TypeMarkup,
|
||||||
|
"PowerBuilder": TypeProgramming,
|
||||||
|
"PowerShell": TypeProgramming,
|
||||||
|
"Processing": TypeProgramming,
|
||||||
|
"Prolog": TypeProgramming,
|
||||||
|
"Propeller Spin": TypeProgramming,
|
||||||
|
"Protocol Buffer": TypeMarkup,
|
||||||
|
"Public Key": TypeData,
|
||||||
|
"Pug": TypeMarkup,
|
||||||
|
"Puppet": TypeProgramming,
|
||||||
|
"Pure Data": TypeProgramming,
|
||||||
|
"PureBasic": TypeProgramming,
|
||||||
|
"PureScript": TypeProgramming,
|
||||||
|
"Python": TypeProgramming,
|
||||||
|
"Python console": TypeProgramming,
|
||||||
|
"Python traceback": TypeData,
|
||||||
|
"QML": TypeProgramming,
|
||||||
|
"QMake": TypeProgramming,
|
||||||
|
"R": TypeProgramming,
|
||||||
|
"RAML": TypeMarkup,
|
||||||
|
"RDoc": TypeProse,
|
||||||
|
"REALbasic": TypeProgramming,
|
||||||
|
"REXX": TypeProgramming,
|
||||||
|
"RHTML": TypeMarkup,
|
||||||
|
"RMarkdown": TypeProse,
|
||||||
|
"RPM Spec": TypeData,
|
||||||
|
"RUNOFF": TypeMarkup,
|
||||||
|
"Racket": TypeProgramming,
|
||||||
|
"Ragel": TypeProgramming,
|
||||||
|
"Rascal": TypeProgramming,
|
||||||
|
"Raw token data": TypeData,
|
||||||
|
"Reason": TypeProgramming,
|
||||||
|
"Rebol": TypeProgramming,
|
||||||
|
"Red": TypeProgramming,
|
||||||
|
"Redcode": TypeProgramming,
|
||||||
|
"Regular Expression": TypeData,
|
||||||
|
"Ren'Py": TypeProgramming,
|
||||||
|
"RenderScript": TypeProgramming,
|
||||||
|
"RobotFramework": TypeProgramming,
|
||||||
|
"Roff": TypeMarkup,
|
||||||
|
"Rouge": TypeProgramming,
|
||||||
|
"Ruby": TypeProgramming,
|
||||||
|
"Rust": TypeProgramming,
|
||||||
|
"SAS": TypeProgramming,
|
||||||
|
"SCSS": TypeMarkup,
|
||||||
|
"SMT": TypeProgramming,
|
||||||
|
"SPARQL": TypeData,
|
||||||
|
"SQF": TypeProgramming,
|
||||||
|
"SQL": TypeData,
|
||||||
|
"SQLPL": TypeProgramming,
|
||||||
|
"SRecode Template": TypeMarkup,
|
||||||
|
"STON": TypeData,
|
||||||
|
"SVG": TypeData,
|
||||||
|
"Sage": TypeProgramming,
|
||||||
|
"SaltStack": TypeProgramming,
|
||||||
|
"Sass": TypeMarkup,
|
||||||
|
"Scala": TypeProgramming,
|
||||||
|
"Scaml": TypeMarkup,
|
||||||
|
"Scheme": TypeProgramming,
|
||||||
|
"Scilab": TypeProgramming,
|
||||||
|
"Self": TypeProgramming,
|
||||||
|
"Shell": TypeProgramming,
|
||||||
|
"ShellSession": TypeProgramming,
|
||||||
|
"Shen": TypeProgramming,
|
||||||
|
"Slash": TypeProgramming,
|
||||||
|
"Slim": TypeMarkup,
|
||||||
|
"Smali": TypeProgramming,
|
||||||
|
"Smalltalk": TypeProgramming,
|
||||||
|
"Smarty": TypeProgramming,
|
||||||
|
"SourcePawn": TypeProgramming,
|
||||||
|
"Spline Font Database": TypeData,
|
||||||
|
"Squirrel": TypeProgramming,
|
||||||
|
"Stan": TypeProgramming,
|
||||||
|
"Standard ML": TypeProgramming,
|
||||||
|
"Stata": TypeProgramming,
|
||||||
|
"Stylus": TypeMarkup,
|
||||||
|
"SubRip Text": TypeData,
|
||||||
|
"Sublime Text Config": TypeData,
|
||||||
|
"SuperCollider": TypeProgramming,
|
||||||
|
"Swift": TypeProgramming,
|
||||||
|
"SystemVerilog": TypeProgramming,
|
||||||
|
"TI Program": TypeProgramming,
|
||||||
|
"TLA": TypeProgramming,
|
||||||
|
"TOML": TypeData,
|
||||||
|
"TXL": TypeProgramming,
|
||||||
|
"Tcl": TypeProgramming,
|
||||||
|
"Tcsh": TypeProgramming,
|
||||||
|
"TeX": TypeMarkup,
|
||||||
|
"Tea": TypeMarkup,
|
||||||
|
"Terra": TypeProgramming,
|
||||||
|
"Text": TypeProse,
|
||||||
|
"Textile": TypeProse,
|
||||||
|
"Thrift": TypeProgramming,
|
||||||
|
"Turing": TypeProgramming,
|
||||||
|
"Turtle": TypeData,
|
||||||
|
"Twig": TypeMarkup,
|
||||||
|
"TypeScript": TypeProgramming,
|
||||||
|
"Unified Parallel C": TypeProgramming,
|
||||||
|
"Unity3D Asset": TypeData,
|
||||||
|
"Unix Assembly": TypeProgramming,
|
||||||
|
"Uno": TypeProgramming,
|
||||||
|
"UnrealScript": TypeProgramming,
|
||||||
|
"UrWeb": TypeProgramming,
|
||||||
|
"VCL": TypeProgramming,
|
||||||
|
"VHDL": TypeProgramming,
|
||||||
|
"Vala": TypeProgramming,
|
||||||
|
"Verilog": TypeProgramming,
|
||||||
|
"Vim script": TypeProgramming,
|
||||||
|
"Visual Basic": TypeProgramming,
|
||||||
|
"Volt": TypeProgramming,
|
||||||
|
"Vue": TypeMarkup,
|
||||||
|
"Wavefront Material": TypeData,
|
||||||
|
"Wavefront Object": TypeData,
|
||||||
|
"Web Ontology Language": TypeMarkup,
|
||||||
|
"WebIDL": TypeProgramming,
|
||||||
|
"World of Warcraft Addon Data": TypeData,
|
||||||
|
"X10": TypeProgramming,
|
||||||
|
"XC": TypeProgramming,
|
||||||
|
"XCompose": TypeData,
|
||||||
|
"XML": TypeData,
|
||||||
|
"XPages": TypeProgramming,
|
||||||
|
"XProc": TypeProgramming,
|
||||||
|
"XQuery": TypeProgramming,
|
||||||
|
"XS": TypeProgramming,
|
||||||
|
"XSLT": TypeProgramming,
|
||||||
|
"Xojo": TypeProgramming,
|
||||||
|
"Xtend": TypeProgramming,
|
||||||
|
"YAML": TypeData,
|
||||||
|
"YANG": TypeData,
|
||||||
|
"Yacc": TypeProgramming,
|
||||||
|
"Zephir": TypeProgramming,
|
||||||
|
"Zimpl": TypeProgramming,
|
||||||
|
"desktop": TypeData,
|
||||||
|
"eC": TypeProgramming,
|
||||||
|
"edn": TypeData,
|
||||||
|
"fish": TypeProgramming,
|
||||||
|
"mupad": TypeProgramming,
|
||||||
|
"nesC": TypeProgramming,
|
||||||
|
"ooc": TypeProgramming,
|
||||||
|
"reStructuredText": TypeProse,
|
||||||
|
"wisp": TypeProgramming,
|
||||||
|
"xBase": TypeProgramming,
|
||||||
|
}
|
32
type_test.go
Normal file
32
type_test.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package slinguist
|
||||||
|
|
||||||
|
import . "gopkg.in/check.v1"
|
||||||
|
|
||||||
|
func (s *TSuite) TestGetLanguageType(c *C) {
|
||||||
|
langType := GetLanguageType("BestLanguageEver")
|
||||||
|
c.Assert(langType, Equals, TypeUnknown)
|
||||||
|
|
||||||
|
langType = GetLanguageType("JSON")
|
||||||
|
c.Assert(langType, Equals, TypeData)
|
||||||
|
|
||||||
|
langType = GetLanguageType("COLLADA")
|
||||||
|
c.Assert(langType, Equals, TypeData)
|
||||||
|
|
||||||
|
langType = GetLanguageType("Go")
|
||||||
|
c.Assert(langType, Equals, TypeProgramming)
|
||||||
|
|
||||||
|
langType = GetLanguageType("Brainfuck")
|
||||||
|
c.Assert(langType, Equals, TypeProgramming)
|
||||||
|
|
||||||
|
langType = GetLanguageType("HTML")
|
||||||
|
c.Assert(langType, Equals, TypeMarkup)
|
||||||
|
|
||||||
|
langType = GetLanguageType("Sass")
|
||||||
|
c.Assert(langType, Equals, TypeMarkup)
|
||||||
|
|
||||||
|
langType = GetLanguageType("AsciiDoc")
|
||||||
|
c.Assert(langType, Equals, TypeProse)
|
||||||
|
|
||||||
|
langType = GetLanguageType("Textile")
|
||||||
|
c.Assert(langType, Equals, TypeProse)
|
||||||
|
}
|
@ -21,13 +21,6 @@ func (s *TSuite) TestIsVendor(c *C) {
|
|||||||
func (s *TSuite) TestIsDocumentation(c *C) {
|
func (s *TSuite) TestIsDocumentation(c *C) {
|
||||||
c.Assert(IsDocumentation("foo"), Equals, false)
|
c.Assert(IsDocumentation("foo"), Equals, false)
|
||||||
c.Assert(IsDocumentation("README"), Equals, true)
|
c.Assert(IsDocumentation("README"), Equals, true)
|
||||||
c.Assert(IsDocumentation("samples/something"), Equals, true)
|
|
||||||
c.Assert(IsDocumentation("Docs/whatever"), Equals, true)
|
|
||||||
c.Assert(IsDocumentation("/javadoc/*"), Equals, true)
|
|
||||||
c.Assert(IsDocumentation("License"), Equals, true)
|
|
||||||
c.Assert(IsDocumentation("CONTRIBUTING.bar"), Equals, true)
|
|
||||||
c.Assert(IsDocumentation("/CHANGES"), Equals, true)
|
|
||||||
c.Assert(IsDocumentation("INSTALL"), Equals, true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TSuite) TestIsConfiguration(c *C) {
|
func (s *TSuite) TestIsConfiguration(c *C) {
|
||||||
|
Loading…
Reference in New Issue
Block a user