mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-05-23 08:30:07 -03:00
added type.go generation
This commit is contained in:
parent
5d61ca93d8
commit
ef39403555
@ -12,7 +12,7 @@ func (s *TSuite) TestGetLanguageByExtension(c *C) {
|
||||
c.Assert(safe, Equals, true)
|
||||
|
||||
lang, safe = GetLanguageByExtension("foo.go.php")
|
||||
c.Assert(lang, Equals, "Hack")
|
||||
c.Assert(lang, Equals, "PHP")
|
||||
c.Assert(safe, Equals, false)
|
||||
}
|
||||
|
||||
|
24
internal/code-generator/assets/type.go.tmpl
Normal file
24
internal/code-generator/assets/type.go.tmpl
Normal file
@ -0,0 +1,24 @@
|
||||
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 }}
|
||||
|
||||
const (
|
||||
TypeUnknown = iota
|
||||
TypeData = iota
|
||||
TypeProgramming = iota
|
||||
TypeMarkup = iota
|
||||
TypeProse = iota
|
||||
)
|
||||
|
||||
func GetLanguageType(language string) (langType int) {
|
||||
langType, _ = languagesType[language]
|
||||
return langType
|
||||
}
|
||||
|
||||
var languagesType = map[string]int{
|
||||
{{range $language, $type := . -}}
|
||||
"{{ $language }}": {{ $type -}},
|
||||
{{end -}}
|
||||
}
|
@ -17,6 +17,7 @@ const (
|
||||
formatedContentGold = "test_files/formated_content.gold"
|
||||
formatedVendorGold = "test_files/formated_vendor.gold"
|
||||
formatedDocumentationGold = "test_files/formated_documentation.gold"
|
||||
formatedTypesGold = "test_files/formated_type.gold"
|
||||
|
||||
// Languages test
|
||||
ymlTestFile = "test_files/languages.test.yml"
|
||||
@ -41,6 +42,12 @@ const (
|
||||
documentationGold = "test_files/documentation.gold"
|
||||
documentationTestTmplPath = "test_files/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) {
|
||||
@ -56,6 +63,9 @@ func TestFromFile(t *testing.T) {
|
||||
goldDocumentation, err := ioutil.ReadFile(formatedDocumentationGold)
|
||||
assert.NoError(t, err)
|
||||
|
||||
goldTypes, err := ioutil.ReadFile(formatedTypesGold)
|
||||
assert.NoError(t, err)
|
||||
|
||||
outPathLang, err := ioutil.TempFile("/tmp", "generator-test-")
|
||||
assert.NoError(t, err)
|
||||
defer os.Remove(outPathLang.Name())
|
||||
@ -72,6 +82,10 @@ func TestFromFile(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
defer os.Remove(outPathDocumentation.Name())
|
||||
|
||||
outPathTypes, err := ioutil.TempFile("/tmp", "generator-test-")
|
||||
assert.NoError(t, err)
|
||||
defer os.Remove(outPathTypes.Name())
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
fileToParse string
|
||||
@ -122,6 +136,16 @@ func TestFromFile(t *testing.T) {
|
||||
generate: Documentation,
|
||||
wantOut: goldDocumentation,
|
||||
},
|
||||
{
|
||||
name: "tyTestFromFile_Types",
|
||||
fileToParse: typesTestFile,
|
||||
outPath: outPathTypes.Name(),
|
||||
tmplPath: typesTestTmplPath,
|
||||
tmplName: typesTestTmplName,
|
||||
commit: commitTest,
|
||||
generate: Types,
|
||||
wantOut: goldTypes,
|
||||
},
|
||||
}
|
||||
|
||||
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)))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -10,11 +10,11 @@ import (
|
||||
)
|
||||
|
||||
type languageInfo struct {
|
||||
Type string `yaml:"type,omitempty" json:"type,omitempty"`
|
||||
Aliases []string `yaml:"aliases,omitempty,flow" json:"aliases,omitempty"`
|
||||
Extensions []string `yaml:"extensions,omitempty,flow" json:"extensions,omitempty"`
|
||||
Interpreters []string `yaml:"interpreters,omitempty,flow" json:"interpreters,omitempty"`
|
||||
Group string `yaml:"group,omitempty" json:"group,omitempty"`
|
||||
Type string `yaml:"type,omitempty"`
|
||||
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.
|
||||
@ -24,10 +24,7 @@ func Languages(data []byte, languagesTmplPath, languagesTmplName, commit string)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
languagesByExtension, err := buildExtensionLanguageMap(languages)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
languagesByExtension := buildExtensionLanguageMap(languages)
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
if err := executeLanguagesTemplate(buf, languagesByExtension, languagesTmplPath, languagesTmplName, commit); err != nil {
|
||||
@ -37,7 +34,7 @@ func Languages(data []byte, languagesTmplPath, languagesTmplName, commit string)
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
func buildExtensionLanguageMap(languages map[string]*languageInfo) (map[string][]string, error) {
|
||||
func buildExtensionLanguageMap(languages map[string]*languageInfo) map[string][]string {
|
||||
extensionLangsMap := make(map[string][]string)
|
||||
for lang, info := range languages {
|
||||
for _, extension := range info.Extensions {
|
||||
@ -45,7 +42,7 @@ func buildExtensionLanguageMap(languages map[string]*languageInfo) (map[string][
|
||||
}
|
||||
}
|
||||
|
||||
return extensionLangsMap, nil
|
||||
return extensionLangsMap
|
||||
}
|
||||
|
||||
func executeLanguagesTemplate(out io.Writer, languagesByExtension map[string][]string, languagesTmplPath, languagesTmpl, commit string) error {
|
||||
|
@ -0,0 +1,25 @@
|
||||
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
|
||||
|
||||
const (
|
||||
TypeUnknown = iota
|
||||
TypeData = iota
|
||||
TypeProgramming = iota
|
||||
TypeMarkup = iota
|
||||
TypeProse = iota
|
||||
)
|
||||
|
||||
func GetLanguageType(language string) (langType int) {
|
||||
langType, _ = languagesType[language]
|
||||
return langType
|
||||
}
|
||||
|
||||
var languagesType = map[string]int{
|
||||
"Scaml": TypeMarkup,
|
||||
"Scheme": TypeProgramming,
|
||||
"Scilab": TypeProgramming,
|
||||
"Self": TypeProgramming,
|
||||
}
|
25
internal/code-generator/generator/test_files/type.gold
Normal file
25
internal/code-generator/generator/test_files/type.gold
Normal file
@ -0,0 +1,25 @@
|
||||
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
|
||||
|
||||
const (
|
||||
TypeUnknown = iota
|
||||
TypeData = iota
|
||||
TypeProgramming = iota
|
||||
TypeMarkup = iota
|
||||
TypeProse = iota
|
||||
)
|
||||
|
||||
func GetLanguageType(language string) (langType int) {
|
||||
langType, _ = languagesType[language]
|
||||
return langType
|
||||
}
|
||||
|
||||
var languagesType = map[string]int{
|
||||
"Scaml": TypeMarkup,
|
||||
"Scheme": TypeProgramming,
|
||||
"Scilab": TypeProgramming,
|
||||
"Self": TypeProgramming,
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
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 }}
|
||||
|
||||
const (
|
||||
TypeUnknown = iota
|
||||
TypeData = iota
|
||||
TypeProgramming = iota
|
||||
TypeMarkup = iota
|
||||
TypeProse = iota
|
||||
)
|
||||
|
||||
func GetLanguageType(language string) (langType int) {
|
||||
langType, _ = languagesType[language]
|
||||
return langType
|
||||
}
|
||||
|
||||
var languagesType = map[string]int{
|
||||
{{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
|
||||
}
|
@ -28,29 +28,40 @@ const (
|
||||
documentationTmplPath = "internal/code-generator/assets/documentation.go.tmpl"
|
||||
documentationTmpl = "documentation.go.tmpl"
|
||||
|
||||
typeFile = "type.go"
|
||||
typeTmplPath = "internal/code-generator/assets/type.go.tmpl"
|
||||
typeTmpl = "type.go.tmpl"
|
||||
|
||||
commitPath = ".git/refs/heads/master"
|
||||
)
|
||||
|
||||
type generatorArgs struct {
|
||||
fileToParse string
|
||||
outPath string
|
||||
tmplPath string
|
||||
tmplName string
|
||||
commit string
|
||||
generate generator.Func
|
||||
}
|
||||
|
||||
func main() {
|
||||
commit, err := getCommit(commitPath)
|
||||
if err != nil {
|
||||
log.Printf("couldn't find commit: %v", err)
|
||||
}
|
||||
|
||||
if err := generator.FromFile(languagesYAML, langFile, languagesTmplPath, languagesTmpl, commit, generator.Languages); err != nil {
|
||||
log.Println(err)
|
||||
argsList := []*generatorArgs{
|
||||
&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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
100
languages.go
100
languages.go
@ -62,7 +62,7 @@ var languagesByExtension = map[string][]string{
|
||||
".arpa": {"DNS Zone"},
|
||||
".as": {"ActionScript"},
|
||||
".asax": {"ASP"},
|
||||
".asc": {"AsciiDoc", "AGS Script", "Public Key"},
|
||||
".asc": {"AGS Script", "Public Key", "AsciiDoc"},
|
||||
".asciidoc": {"AsciiDoc"},
|
||||
".ascx": {"ASP"},
|
||||
".asd": {"Common Lisp"},
|
||||
@ -87,7 +87,7 @@ var languagesByExtension = map[string][]string{
|
||||
".axml": {"XML"},
|
||||
".axs": {"NetLinx"},
|
||||
".axs.erb": {"NetLinx+ERB"},
|
||||
".b": {"Limbo", "Brainfuck"},
|
||||
".b": {"Brainfuck", "Limbo"},
|
||||
".bas": {"Visual Basic"},
|
||||
".bash": {"Shell"},
|
||||
".bat": {"Batchfile"},
|
||||
@ -95,7 +95,7 @@ var languagesByExtension = map[string][]string{
|
||||
".bb": {"BlitzBasic", "BitBake"},
|
||||
".bbx": {"TeX"},
|
||||
".befunge": {"Befunge"},
|
||||
".bf": {"HyPhy", "Brainfuck"},
|
||||
".bf": {"Brainfuck", "HyPhy"},
|
||||
".bib": {"TeX"},
|
||||
".bison": {"Bison"},
|
||||
".blade": {"Blade"},
|
||||
@ -104,7 +104,7 @@ var languagesByExtension = map[string][]string{
|
||||
".bones": {"JavaScript"},
|
||||
".boo": {"Boo"},
|
||||
".boot": {"Clojure"},
|
||||
".brd": {"KiCad", "Eagle"},
|
||||
".brd": {"Eagle", "KiCad"},
|
||||
".bro": {"Bro"},
|
||||
".brs": {"Brightscript"},
|
||||
".bsl": {"1C Enterprise"},
|
||||
@ -117,7 +117,7 @@ var languagesByExtension = map[string][]string{
|
||||
".c++-objdump": {"Cpp-ObjDump"},
|
||||
".c++objdump": {"Cpp-ObjDump"},
|
||||
".c-objdump": {"C-ObjDump"},
|
||||
".cake": {"CoffeeScript", "C#"},
|
||||
".cake": {"C#", "CoffeeScript"},
|
||||
".capnp": {"Cap'n Proto"},
|
||||
".cats": {"C"},
|
||||
".cbl": {"COBOL"},
|
||||
@ -131,7 +131,7 @@ var languagesByExtension = map[string][]string{
|
||||
".cfg": {"INI"},
|
||||
".cfm": {"ColdFusion"},
|
||||
".cfml": {"ColdFusion"},
|
||||
".cgi": {"Shell", "Python", "Perl"},
|
||||
".cgi": {"Python", "Perl", "Shell"},
|
||||
".ch": {"Charity", "xBase"},
|
||||
".chem": {"Pic"},
|
||||
".chpl": {"Chapel"},
|
||||
@ -139,7 +139,7 @@ var languagesByExtension = map[string][]string{
|
||||
".cirru": {"Cirru"},
|
||||
".cjsx": {"CoffeeScript"},
|
||||
".ck": {"ChucK"},
|
||||
".cl": {"OpenCL", "Common Lisp", "Cool"},
|
||||
".cl": {"Common Lisp", "OpenCL", "Cool"},
|
||||
".cl2": {"Clojure"},
|
||||
".click": {"Click"},
|
||||
".clixml": {"XML"},
|
||||
@ -150,7 +150,7 @@ var languagesByExtension = map[string][]string{
|
||||
".cljscm": {"Clojure"},
|
||||
".cljx": {"Clojure"},
|
||||
".clp": {"CLIPS"},
|
||||
".cls": {"TeX", "Apex", "OpenEdge ABL", "Visual Basic"},
|
||||
".cls": {"Apex", "TeX", "Visual Basic", "OpenEdge ABL"},
|
||||
".clw": {"Clarion"},
|
||||
".cmake": {"CMake"},
|
||||
".cmake.in": {"CMake"},
|
||||
@ -161,7 +161,7 @@ var languagesByExtension = map[string][]string{
|
||||
".com": {"DIGITAL Command Language"},
|
||||
".command": {"Shell"},
|
||||
".coq": {"Coq"},
|
||||
".cp": {"C++", "Component Pascal"},
|
||||
".cp": {"Component Pascal", "C++"},
|
||||
".cpp": {"C++"},
|
||||
".cpp-objdump": {"Cpp-ObjDump"},
|
||||
".cppobjdump": {"Cpp-ObjDump"},
|
||||
@ -189,7 +189,7 @@ var languagesByExtension = map[string][]string{
|
||||
".cxx": {"C++"},
|
||||
".cxx-objdump": {"Cpp-ObjDump"},
|
||||
".cy": {"Cycript"},
|
||||
".d": {"Makefile", "DTrace", "D"},
|
||||
".d": {"Makefile", "D", "DTrace"},
|
||||
".d-objdump": {"D-ObjDump"},
|
||||
".dae": {"COLLADA"},
|
||||
".darcspatch": {"Darcs Patch"},
|
||||
@ -229,7 +229,7 @@ var languagesByExtension = map[string][]string{
|
||||
".ebnf": {"EBNF"},
|
||||
".ebuild": {"Gentoo Ebuild"},
|
||||
".ec": {"eC"},
|
||||
".ecl": {"ECLiPSe", "ECL"},
|
||||
".ecl": {"ECL", "ECLiPSe"},
|
||||
".eclass": {"Gentoo Eclass"},
|
||||
".eclxml": {"ECL"},
|
||||
".ecr": {"HTML+ECR"},
|
||||
@ -251,13 +251,13 @@ var languagesByExtension = map[string][]string{
|
||||
".erb": {"HTML+ERB"},
|
||||
".erb.deface": {"HTML+ERB"},
|
||||
".erl": {"Erlang"},
|
||||
".es": {"Erlang", "JavaScript"},
|
||||
".es": {"JavaScript", "Erlang"},
|
||||
".es6": {"JavaScript"},
|
||||
".escript": {"Erlang"},
|
||||
".ex": {"Elixir"},
|
||||
".exs": {"Elixir"},
|
||||
".eye": {"Ruby"},
|
||||
".f": {"Fortran", "Filebench WML", "Forth"},
|
||||
".f": {"Fortran", "Forth", "Filebench WML"},
|
||||
".f03": {"Fortran"},
|
||||
".f08": {"Fortran"},
|
||||
".f77": {"Fortran"},
|
||||
@ -266,24 +266,24 @@ var languagesByExtension = map[string][]string{
|
||||
".factor": {"Factor"},
|
||||
".fan": {"Fantom"},
|
||||
".fancypack": {"Fancy"},
|
||||
".fcgi": {"Lua", "Shell", "PHP", "Python", "Perl", "Ruby"},
|
||||
".fcgi": {"PHP", "Python", "Perl", "Shell", "Ruby", "Lua"},
|
||||
".fea": {"OpenType Feature File"},
|
||||
".feature": {"Gherkin"},
|
||||
".filters": {"XML"},
|
||||
".fish": {"fish"},
|
||||
".flex": {"JFlex"},
|
||||
".flux": {"FLUX"},
|
||||
".for": {"Formatted", "Fortran", "Forth"},
|
||||
".for": {"Fortran", "Formatted", "Forth"},
|
||||
".forth": {"Forth"},
|
||||
".fp": {"GLSL"},
|
||||
".fpp": {"Fortran"},
|
||||
".fr": {"Text", "Frege", "Forth"},
|
||||
".fr": {"Forth", "Frege", "Text"},
|
||||
".frag": {"JavaScript", "GLSL"},
|
||||
".frg": {"GLSL"},
|
||||
".frm": {"Visual Basic"},
|
||||
".frt": {"Forth"},
|
||||
".frx": {"Visual Basic"},
|
||||
".fs": {"Filterscript", "GLSL", "F#", "Forth"},
|
||||
".fs": {"F#", "Forth", "Filterscript", "GLSL"},
|
||||
".fsh": {"GLSL"},
|
||||
".fshader": {"GLSL"},
|
||||
".fsi": {"F#"},
|
||||
@ -302,7 +302,7 @@ var languagesByExtension = map[string][]string{
|
||||
".gawk": {"Awk"},
|
||||
".gco": {"G-code"},
|
||||
".gcode": {"G-code"},
|
||||
".gd": {"GDScript", "GAP"},
|
||||
".gd": {"GAP", "GDScript"},
|
||||
".gdb": {"GDB"},
|
||||
".gdbinit": {"GDB"},
|
||||
".gemspec": {"Ruby"},
|
||||
@ -315,7 +315,7 @@ var languagesByExtension = map[string][]string{
|
||||
".glf": {"Glyph"},
|
||||
".glsl": {"GLSL"},
|
||||
".glslv": {"GLSL"},
|
||||
".gml": {"Graph Modeling Language", "Game Maker Language", "XML"},
|
||||
".gml": {"XML", "Graph Modeling Language", "Game Maker Language"},
|
||||
".gms": {"GAMS"},
|
||||
".gn": {"GN"},
|
||||
".gni": {"GN"},
|
||||
@ -341,7 +341,7 @@ var languagesByExtension = map[string][]string{
|
||||
".gvy": {"Groovy"},
|
||||
".gyp": {"Python"},
|
||||
".gypi": {"Python"},
|
||||
".h": {"C", "Objective-C", "C++"},
|
||||
".h": {"C++", "C", "Objective-C"},
|
||||
".h++": {"C++"},
|
||||
".haml": {"Haml"},
|
||||
".haml.deface": {"Haml"},
|
||||
@ -350,7 +350,7 @@ var languagesByExtension = map[string][]string{
|
||||
".hb": {"Harbour"},
|
||||
".hbs": {"Handlebars"},
|
||||
".hcl": {"HCL"},
|
||||
".hh": {"C++", "Hack"},
|
||||
".hh": {"Hack", "C++"},
|
||||
".hic": {"Clojure"},
|
||||
".hlean": {"Lean"},
|
||||
".hlsl": {"HLSL"},
|
||||
@ -378,7 +378,7 @@ var languagesByExtension = map[string][]string{
|
||||
".ik": {"Ioke"},
|
||||
".ily": {"LilyPond"},
|
||||
".iml": {"XML"},
|
||||
".inc": {"Assembly", "POV-Ray SDL", "HTML", "PHP", "PAWN", "Pascal", "C++", "SQL", "SourcePawn"},
|
||||
".inc": {"PHP", "Assembly", "HTML", "POV-Ray SDL", "SQL", "Pascal", "C++", "SourcePawn", "PAWN"},
|
||||
".ini": {"INI"},
|
||||
".inl": {"C++"},
|
||||
".ino": {"Arduino"},
|
||||
@ -392,7 +392,7 @@ var languagesByExtension = map[string][]string{
|
||||
".irclog": {"IRC log"},
|
||||
".iss": {"Inno Setup"},
|
||||
".ivy": {"XML"},
|
||||
".j": {"Jasmin", "Objective-J"},
|
||||
".j": {"Objective-J", "Jasmin"},
|
||||
".jade": {"Pug"},
|
||||
".jake": {"JavaScript"},
|
||||
".java": {"Java"},
|
||||
@ -425,7 +425,7 @@ var languagesByExtension = map[string][]string{
|
||||
".kt": {"Kotlin"},
|
||||
".ktm": {"Kotlin"},
|
||||
".kts": {"Kotlin"},
|
||||
".l": {"Roff", "Common Lisp", "PicoLisp", "Lex"},
|
||||
".l": {"Common Lisp", "Roff", "PicoLisp", "Lex"},
|
||||
".lagda": {"Literate Agda"},
|
||||
".las": {"Lasso"},
|
||||
".lasso": {"Lasso"},
|
||||
@ -454,7 +454,7 @@ var languagesByExtension = map[string][]string{
|
||||
".lol": {"LOLCODE"},
|
||||
".lookml": {"LookML"},
|
||||
".lpr": {"Pascal"},
|
||||
".ls": {"LoomScript", "LiveScript"},
|
||||
".ls": {"LiveScript", "LoomScript"},
|
||||
".lsl": {"LSL"},
|
||||
".lslp": {"LSL"},
|
||||
".lsp": {"NewLisp", "Common Lisp"},
|
||||
@ -462,8 +462,8 @@ var languagesByExtension = map[string][]string{
|
||||
".lua": {"Lua"},
|
||||
".lvproj": {"LabVIEW"},
|
||||
".ly": {"LilyPond"},
|
||||
".m": {"M", "Limbo", "Objective-C", "MUF", "Matlab", "Mercury", "Mathematica"},
|
||||
".m4": {"M4", "M4Sugar"},
|
||||
".m": {"Matlab", "M", "Limbo", "Objective-C", "Mathematica", "MUF", "Mercury"},
|
||||
".m4": {"M4Sugar", "M4"},
|
||||
".ma": {"Mathematica"},
|
||||
".mak": {"Makefile"},
|
||||
".make": {"Makefile"},
|
||||
@ -483,7 +483,7 @@ var languagesByExtension = map[string][]string{
|
||||
".maxpat": {"Max"},
|
||||
".maxproj": {"Max"},
|
||||
".mcr": {"MAXScript"},
|
||||
".md": {"GCC Machine Description", "Markdown"},
|
||||
".md": {"Markdown", "GCC Machine Description"},
|
||||
".mdown": {"Markdown"},
|
||||
".mdpolicy": {"XML"},
|
||||
".mdwn": {"Markdown"},
|
||||
@ -507,19 +507,19 @@ var languagesByExtension = map[string][]string{
|
||||
".mli": {"OCaml"},
|
||||
".mll": {"OCaml"},
|
||||
".mly": {"OCaml"},
|
||||
".mm": {"Objective-C++", "XML"},
|
||||
".mm": {"XML", "Objective-C++"},
|
||||
".mmk": {"Module Management System"},
|
||||
".mms": {"Module Management System"},
|
||||
".mo": {"Modelica"},
|
||||
".mod": {"Linux Kernel Module", "AMPL", "Modula-2", "XML"},
|
||||
".mod": {"XML", "Modula-2", "AMPL", "Linux Kernel Module"},
|
||||
".model.lkml": {"LookML"},
|
||||
".monkey": {"Monkey"},
|
||||
".moo": {"Mercury", "Moocode"},
|
||||
".moo": {"Moocode", "Mercury"},
|
||||
".moon": {"MoonScript"},
|
||||
".mq4": {"MQL4"},
|
||||
".mq5": {"MQL5"},
|
||||
".mqh": {"MQL4", "MQL5"},
|
||||
".ms": {"Roff", "Unix Assembly", "MAXScript"},
|
||||
".mqh": {"MQL5", "MQL4"},
|
||||
".ms": {"Unix Assembly", "Roff", "MAXScript"},
|
||||
".mspec": {"Ruby"},
|
||||
".mss": {"CartoCSS"},
|
||||
".mt": {"Mathematica"},
|
||||
@ -533,7 +533,7 @@ var languagesByExtension = map[string][]string{
|
||||
".mxt": {"Max"},
|
||||
".mysql": {"SQL"},
|
||||
".myt": {"Myghty"},
|
||||
".n": {"Roff", "Nemerle"},
|
||||
".n": {"Nemerle", "Roff"},
|
||||
".nasm": {"Assembly"},
|
||||
".nawk": {"Awk"},
|
||||
".nb": {"Text", "Mathematica"},
|
||||
@ -619,7 +619,7 @@ var languagesByExtension = map[string][]string{
|
||||
".pkgproj": {"XML"},
|
||||
".pkl": {"Pickle"},
|
||||
".pks": {"PLSQL"},
|
||||
".pl": {"Prolog", "Perl", "Perl6"},
|
||||
".pl": {"Perl", "Perl6", "Prolog"},
|
||||
".pl6": {"Perl6"},
|
||||
".plb": {"PLSQL"},
|
||||
".plist": {"XML"},
|
||||
@ -627,13 +627,13 @@ var languagesByExtension = map[string][]string{
|
||||
".pls": {"PLSQL"},
|
||||
".plsql": {"PLSQL"},
|
||||
".plt": {"Gnuplot"},
|
||||
".pluginspec": {"Ruby", "XML"},
|
||||
".pluginspec": {"XML", "Ruby"},
|
||||
".plx": {"Perl"},
|
||||
".pm": {"Perl", "Perl6"},
|
||||
".pm6": {"Perl6"},
|
||||
".pmod": {"Pike"},
|
||||
".po": {"Gettext Catalog"},
|
||||
".pod": {"Pod", "Perl"},
|
||||
".pod": {"Perl", "Pod"},
|
||||
".podsl": {"Common Lisp"},
|
||||
".podspec": {"Ruby"},
|
||||
".pogo": {"PogoScript"},
|
||||
@ -647,7 +647,7 @@ var languagesByExtension = map[string][]string{
|
||||
".prefs": {"INI"},
|
||||
".prg": {"xBase"},
|
||||
".pri": {"QMake"},
|
||||
".pro": {"IDL", "INI", "Prolog", "QMake"},
|
||||
".pro": {"IDL", "QMake", "INI", "Prolog"},
|
||||
".prolog": {"Prolog"},
|
||||
".properties": {"INI"},
|
||||
".props": {"XML"},
|
||||
@ -727,7 +727,7 @@ var languagesByExtension = map[string][]string{
|
||||
".ron": {"Markdown"},
|
||||
".rpy": {"Python", "Ren'Py"},
|
||||
".rq": {"SPARQL"},
|
||||
".rs": {"Rust", "RenderScript"},
|
||||
".rs": {"RenderScript", "Rust"},
|
||||
".rs.in": {"Rust"},
|
||||
".rsc": {"Rascal"},
|
||||
".rsh": {"RenderScript"},
|
||||
@ -751,7 +751,7 @@ var languagesByExtension = map[string][]string{
|
||||
".scaml": {"Scaml"},
|
||||
".scd": {"SuperCollider"},
|
||||
".sce": {"Scilab"},
|
||||
".sch": {"KiCad", "Eagle", "XML"},
|
||||
".sch": {"XML", "Eagle", "KiCad"},
|
||||
".sci": {"Scilab"},
|
||||
".scm": {"Scheme"},
|
||||
".sco": {"Csound Score"},
|
||||
@ -774,7 +774,7 @@ var languagesByExtension = map[string][]string{
|
||||
".sl": {"Slash"},
|
||||
".sld": {"Scheme"},
|
||||
".slim": {"Slim"},
|
||||
".sls": {"Scheme", "SaltStack"},
|
||||
".sls": {"SaltStack", "Scheme"},
|
||||
".sma": {"SourcePawn"},
|
||||
".smali": {"Smali"},
|
||||
".sml": {"Standard ML"},
|
||||
@ -786,15 +786,15 @@ var languagesByExtension = map[string][]string{
|
||||
".spin": {"Propeller Spin"},
|
||||
".sps": {"Scheme"},
|
||||
".sqf": {"SQF"},
|
||||
".sql": {"PLpgSQL", "PLSQL", "SQL", "SQLPL"},
|
||||
".sql": {"SQLPL", "SQL", "PLpgSQL", "PLSQL"},
|
||||
".sra": {"PowerBuilder"},
|
||||
".srdf": {"XML"},
|
||||
".srt": {"SubRip Text", "SRecode Template"},
|
||||
".srt": {"SRecode Template", "SubRip Text"},
|
||||
".sru": {"PowerBuilder"},
|
||||
".srw": {"PowerBuilder"},
|
||||
".ss": {"Scheme"},
|
||||
".ssjs": {"JavaScript"},
|
||||
".st": {"HTML", "Smalltalk"},
|
||||
".st": {"Smalltalk", "HTML"},
|
||||
".stTheme": {"XML"},
|
||||
".stan": {"Stan"},
|
||||
".sthlp": {"Stata"},
|
||||
@ -822,7 +822,7 @@ var languagesByExtension = map[string][]string{
|
||||
".svh": {"SystemVerilog"},
|
||||
".swift": {"Swift"},
|
||||
".syntax": {"YAML"},
|
||||
".t": {"Turing", "Perl", "Terra", "Perl6"},
|
||||
".t": {"Turing", "Perl", "Perl6", "Terra"},
|
||||
".tab": {"SQL"},
|
||||
".tac": {"Python"},
|
||||
".targets": {"XML"},
|
||||
@ -846,15 +846,15 @@ var languagesByExtension = map[string][]string{
|
||||
".tmac": {"Roff"},
|
||||
".tml": {"XML"},
|
||||
".tmux": {"Shell"},
|
||||
".toc": {"TeX", "World of Warcraft Addon Data"},
|
||||
".toc": {"World of Warcraft Addon Data", "TeX"},
|
||||
".toml": {"TOML"},
|
||||
".tool": {"Shell"},
|
||||
".topojson": {"JSON"},
|
||||
".tpl": {"Smarty"},
|
||||
".tpp": {"C++"},
|
||||
".ts": {"TypeScript", "XML"},
|
||||
".tst": {"Scilab", "GAP"},
|
||||
".tsx": {"TypeScript", "XML"},
|
||||
".ts": {"XML", "TypeScript"},
|
||||
".tst": {"GAP", "Scilab"},
|
||||
".tsx": {"XML", "TypeScript"},
|
||||
".ttl": {"Turtle"},
|
||||
".tu": {"Turing"},
|
||||
".twig": {"Twig"},
|
||||
@ -890,7 +890,7 @@ var languagesByExtension = map[string][]string{
|
||||
".vhf": {"VHDL"},
|
||||
".vhi": {"VHDL"},
|
||||
".vho": {"VHDL"},
|
||||
".vhost": {"Nginx", "ApacheConf"},
|
||||
".vhost": {"ApacheConf", "Nginx"},
|
||||
".vhs": {"VHDL"},
|
||||
".vht": {"VHDL"},
|
||||
".vhw": {"VHDL"},
|
||||
|
465
type.go
Normal file
465
type.go
Normal file
@ -0,0 +1,465 @@
|
||||
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
|
||||
|
||||
const (
|
||||
TypeUnknown = iota
|
||||
TypeData = iota
|
||||
TypeProgramming = iota
|
||||
TypeMarkup = iota
|
||||
TypeProse = iota
|
||||
)
|
||||
|
||||
func GetLanguageType(language string) (langType int) {
|
||||
langType, _ = languagesType[language]
|
||||
return langType
|
||||
}
|
||||
|
||||
var languagesType = map[string]int{
|
||||
"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)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user