mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-05-23 08:30:07 -03:00
Added all the necessary to do GetLanguageByAlias functionality works
This commit is contained in:
parent
6f3ad6d30d
commit
45314b4903
15
alias.go
Normal file
15
alias.go
Normal file
@ -0,0 +1,15 @@
|
||||
package slinguist
|
||||
|
||||
import "strings"
|
||||
|
||||
// GetLanguageByAlias returns the language related to the given alias
|
||||
func GetLanguageByAlias(alias string) (lang string) {
|
||||
a := strings.Split(alias, `,`)[0]
|
||||
a = strings.ToLower(a)
|
||||
lang, ok := languagesByAlias[a]
|
||||
if !ok {
|
||||
lang = OtherLanguage
|
||||
}
|
||||
|
||||
return
|
||||
}
|
26
alias_test.go
Normal file
26
alias_test.go
Normal file
@ -0,0 +1,26 @@
|
||||
package slinguist
|
||||
|
||||
import . "gopkg.in/check.v1"
|
||||
|
||||
func (s *TSuite) TestGetLanguageByAlias(c *C) {
|
||||
tests := []struct {
|
||||
alias string
|
||||
expectedLang string
|
||||
}{
|
||||
{alias: "BestLanguageEver", expectedLang: OtherLanguage},
|
||||
{alias: "aspx-vb", expectedLang: "ASP"},
|
||||
{alias: "C++", expectedLang: "C++"},
|
||||
{alias: "c++", expectedLang: "C++"},
|
||||
{alias: "objc", expectedLang: "Objective-C"},
|
||||
{alias: "golang", expectedLang: "Go"},
|
||||
{alias: "GOLANG", expectedLang: "Go"},
|
||||
{alias: "bsdmake", expectedLang: "Makefile"},
|
||||
{alias: "xhTmL", expectedLang: "HTML"},
|
||||
{alias: "python", expectedLang: "Python"},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
lang := GetLanguageByAlias(test.alias)
|
||||
c.Assert(lang, Equals, test.expectedLang)
|
||||
}
|
||||
}
|
637
aliases_map.go
Normal file
637
aliases_map.go
Normal file
@ -0,0 +1,637 @@
|
||||
package slinguist
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Extracted from github/linguist commit: dae33dc2b20cddc85d1300435c3be7118a7115a9
|
||||
|
||||
// languagesByAlias keeps alias for different languages and use the name of the languages as a 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{
|
||||
"1c_enterprise": "1C Enterprise",
|
||||
"abap": "ABAP",
|
||||
"abl": "OpenEdge ABL",
|
||||
"abnf": "ABNF",
|
||||
"abuild": "Alpine Abuild",
|
||||
"aconf": "ApacheConf",
|
||||
"actionscript": "ActionScript",
|
||||
"actionscript3": "ActionScript",
|
||||
"actionscript_3": "ActionScript",
|
||||
"ada": "Ada",
|
||||
"ada2005": "Ada",
|
||||
"ada95": "Ada",
|
||||
"advpl": "xBase",
|
||||
"afdko": "OpenType Feature File",
|
||||
"agda": "Agda",
|
||||
"ags": "AGS Script",
|
||||
"ags_script": "AGS Script",
|
||||
"ahk": "AutoHotkey",
|
||||
"alloy": "Alloy",
|
||||
"alpine_abuild": "Alpine Abuild",
|
||||
"ampl": "AMPL",
|
||||
"ant_build_system": "Ant Build System",
|
||||
"antlr": "ANTLR",
|
||||
"apache": "ApacheConf",
|
||||
"apacheconf": "ApacheConf",
|
||||
"apex": "Apex",
|
||||
"api_blueprint": "API Blueprint",
|
||||
"apkbuild": "Alpine Abuild",
|
||||
"apl": "APL",
|
||||
"apollo_guidance_computer": "Apollo Guidance Computer",
|
||||
"applescript": "AppleScript",
|
||||
"arc": "Arc",
|
||||
"arduino": "Arduino",
|
||||
"arexx": "REXX",
|
||||
"as3": "ActionScript",
|
||||
"asciidoc": "AsciiDoc",
|
||||
"asn.1": "ASN.1",
|
||||
"asp": "ASP",
|
||||
"aspectj": "AspectJ",
|
||||
"aspx": "ASP",
|
||||
"aspx-vb": "ASP",
|
||||
"assembly": "Assembly",
|
||||
"ats": "ATS",
|
||||
"ats2": "ATS",
|
||||
"au3": "AutoIt",
|
||||
"augeas": "Augeas",
|
||||
"autoconf": "M4Sugar",
|
||||
"autohotkey": "AutoHotkey",
|
||||
"autoit": "AutoIt",
|
||||
"autoit3": "AutoIt",
|
||||
"autoitscript": "AutoIt",
|
||||
"awk": "Awk",
|
||||
"b3d": "BlitzBasic",
|
||||
"bash": "Shell",
|
||||
"bash_session": "ShellSession",
|
||||
"bat": "Batchfile",
|
||||
"batch": "Batchfile",
|
||||
"batchfile": "Batchfile",
|
||||
"befunge": "Befunge",
|
||||
"bison": "Bison",
|
||||
"bitbake": "BitBake",
|
||||
"blade": "Blade",
|
||||
"blitz3d": "BlitzBasic",
|
||||
"blitzbasic": "BlitzBasic",
|
||||
"blitzmax": "BlitzMax",
|
||||
"blitzplus": "BlitzBasic",
|
||||
"bluespec": "Bluespec",
|
||||
"bmax": "BlitzMax",
|
||||
"boo": "Boo",
|
||||
"bplus": "BlitzBasic",
|
||||
"brainfuck": "Brainfuck",
|
||||
"brightscript": "Brightscript",
|
||||
"bro": "Bro",
|
||||
"bsdmake": "Makefile",
|
||||
"byond": "DM",
|
||||
"c": "C",
|
||||
"c#": "C#",
|
||||
"c++": "C++",
|
||||
"c++-objdump": "Cpp-ObjDump",
|
||||
"c-objdump": "C-ObjDump",
|
||||
"c2hs": "C2hs Haskell",
|
||||
"c2hs_haskell": "C2hs Haskell",
|
||||
"cap'n_proto": "Cap'n Proto",
|
||||
"carto": "CartoCSS",
|
||||
"cartocss": "CartoCSS",
|
||||
"ceylon": "Ceylon",
|
||||
"cfc": "ColdFusion CFC",
|
||||
"cfm": "ColdFusion",
|
||||
"cfml": "ColdFusion",
|
||||
"chapel": "Chapel",
|
||||
"charity": "Charity",
|
||||
"chpl": "Chapel",
|
||||
"chuck": "ChucK",
|
||||
"cirru": "Cirru",
|
||||
"clarion": "Clarion",
|
||||
"clean": "Clean",
|
||||
"click": "Click",
|
||||
"clipper": "xBase",
|
||||
"clips": "CLIPS",
|
||||
"clojure": "Clojure",
|
||||
"cmake": "CMake",
|
||||
"cobol": "COBOL",
|
||||
"coffee": "CoffeeScript",
|
||||
"coffee-script": "CoffeeScript",
|
||||
"coffeescript": "CoffeeScript",
|
||||
"coldfusion": "ColdFusion",
|
||||
"coldfusion_cfc": "ColdFusion CFC",
|
||||
"coldfusion_html": "ColdFusion",
|
||||
"collada": "COLLADA",
|
||||
"common_lisp": "Common Lisp",
|
||||
"component_pascal": "Component Pascal",
|
||||
"console": "ShellSession",
|
||||
"cool": "Cool",
|
||||
"coq": "Coq",
|
||||
"cpp": "C++",
|
||||
"cpp-objdump": "Cpp-ObjDump",
|
||||
"creole": "Creole",
|
||||
"crystal": "Crystal",
|
||||
"csharp": "C#",
|
||||
"cson": "CSON",
|
||||
"csound": "Csound",
|
||||
"csound-csd": "Csound Document",
|
||||
"csound-orc": "Csound",
|
||||
"csound-sco": "Csound Score",
|
||||
"csound_document": "Csound Document",
|
||||
"csound_score": "Csound Score",
|
||||
"css": "CSS",
|
||||
"csv": "CSV",
|
||||
"cucumber": "Gherkin",
|
||||
"cuda": "Cuda",
|
||||
"cycript": "Cycript",
|
||||
"cython": "Cython",
|
||||
"d": "D",
|
||||
"d-objdump": "D-ObjDump",
|
||||
"darcs_patch": "Darcs Patch",
|
||||
"dart": "Dart",
|
||||
"dcl": "DIGITAL Command Language",
|
||||
"delphi": "Component Pascal",
|
||||
"desktop": "desktop",
|
||||
"diff": "Diff",
|
||||
"digital_command_language": "DIGITAL Command Language",
|
||||
"django": "HTML+Django",
|
||||
"dm": "DM",
|
||||
"dns_zone": "DNS Zone",
|
||||
"dockerfile": "Dockerfile",
|
||||
"dogescript": "Dogescript",
|
||||
"dosbatch": "Batchfile",
|
||||
"dosini": "INI",
|
||||
"dpatch": "Darcs Patch",
|
||||
"dtrace": "DTrace",
|
||||
"dtrace-script": "DTrace",
|
||||
"dylan": "Dylan",
|
||||
"e": "E",
|
||||
"eagle": "Eagle",
|
||||
"ebnf": "EBNF",
|
||||
"ec": "eC",
|
||||
"ecere_projects": "Ecere Projects",
|
||||
"ecl": "ECL",
|
||||
"eclipse": "ECLiPSe",
|
||||
"ecr": "HTML+ECR",
|
||||
"edn": "edn",
|
||||
"eex": "HTML+EEX",
|
||||
"eiffel": "Eiffel",
|
||||
"ejs": "EJS",
|
||||
"elisp": "Emacs Lisp",
|
||||
"elixir": "Elixir",
|
||||
"elm": "Elm",
|
||||
"emacs": "Emacs Lisp",
|
||||
"emacs_lisp": "Emacs Lisp",
|
||||
"emberscript": "EmberScript",
|
||||
"eq": "EQ",
|
||||
"erb": "HTML+ERB",
|
||||
"erlang": "Erlang",
|
||||
"f#": "F#",
|
||||
"factor": "Factor",
|
||||
"fancy": "Fancy",
|
||||
"fantom": "Fantom",
|
||||
"filebench_wml": "Filebench WML",
|
||||
"filterscript": "Filterscript",
|
||||
"fish": "fish",
|
||||
"flex": "Lex",
|
||||
"flux": "FLUX",
|
||||
"formatted": "Formatted",
|
||||
"forth": "Forth",
|
||||
"fortran": "Fortran",
|
||||
"foxpro": "xBase",
|
||||
"freemarker": "FreeMarker",
|
||||
"frege": "Frege",
|
||||
"fsharp": "F#",
|
||||
"ftl": "FreeMarker",
|
||||
"fundamental": "Text",
|
||||
"g-code": "G-code",
|
||||
"game_maker_language": "Game Maker Language",
|
||||
"gams": "GAMS",
|
||||
"gap": "GAP",
|
||||
"gcc_machine_description": "GCC Machine Description",
|
||||
"gdb": "GDB",
|
||||
"gdscript": "GDScript",
|
||||
"genie": "Genie",
|
||||
"genshi": "Genshi",
|
||||
"gentoo_ebuild": "Gentoo Ebuild",
|
||||
"gentoo_eclass": "Gentoo Eclass",
|
||||
"gettext_catalog": "Gettext Catalog",
|
||||
"gf": "Grammatical Framework",
|
||||
"gherkin": "Gherkin",
|
||||
"glsl": "GLSL",
|
||||
"glyph": "Glyph",
|
||||
"gn": "GN",
|
||||
"gnuplot": "Gnuplot",
|
||||
"go": "Go",
|
||||
"golang": "Go",
|
||||
"golo": "Golo",
|
||||
"gosu": "Gosu",
|
||||
"grace": "Grace",
|
||||
"gradle": "Gradle",
|
||||
"grammatical_framework": "Grammatical Framework",
|
||||
"graph_modeling_language": "Graph Modeling Language",
|
||||
"graphql": "GraphQL",
|
||||
"graphviz_(dot)": "Graphviz (DOT)",
|
||||
"groovy": "Groovy",
|
||||
"groovy_server_pages": "Groovy Server Pages",
|
||||
"gsp": "Groovy Server Pages",
|
||||
"hack": "Hack",
|
||||
"haml": "Haml",
|
||||
"handlebars": "Handlebars",
|
||||
"harbour": "Harbour",
|
||||
"haskell": "Haskell",
|
||||
"haxe": "Haxe",
|
||||
"hbs": "Handlebars",
|
||||
"hcl": "HCL",
|
||||
"hlsl": "HLSL",
|
||||
"html": "HTML",
|
||||
"html+django": "HTML+Django",
|
||||
"html+django/jinja": "HTML+Django",
|
||||
"html+ecr": "HTML+ECR",
|
||||
"html+eex": "HTML+EEX",
|
||||
"html+erb": "HTML+ERB",
|
||||
"html+jinja": "HTML+Django",
|
||||
"html+php": "HTML+PHP",
|
||||
"html+ruby": "RHTML",
|
||||
"htmlbars": "Handlebars",
|
||||
"htmldjango": "HTML+Django",
|
||||
"http": "HTTP",
|
||||
"hy": "Hy",
|
||||
"hylang": "Hy",
|
||||
"hyphy": "HyPhy",
|
||||
"i7": "Inform 7",
|
||||
"idl": "IDL",
|
||||
"idris": "Idris",
|
||||
"igor": "IGOR Pro",
|
||||
"igor_pro": "IGOR Pro",
|
||||
"igorpro": "IGOR Pro",
|
||||
"inc": "PHP",
|
||||
"inform7": "Inform 7",
|
||||
"inform_7": "Inform 7",
|
||||
"ini": "INI",
|
||||
"inno_setup": "Inno Setup",
|
||||
"io": "Io",
|
||||
"ioke": "Ioke",
|
||||
"ipython_notebook": "Jupyter Notebook",
|
||||
"irc": "IRC log",
|
||||
"irc_log": "IRC log",
|
||||
"irc_logs": "IRC log",
|
||||
"isabelle": "Isabelle",
|
||||
"isabelle_root": "Isabelle ROOT",
|
||||
"j": "J",
|
||||
"jasmin": "Jasmin",
|
||||
"java": "Java",
|
||||
"java_server_page": "Groovy Server Pages",
|
||||
"java_server_pages": "Java Server Pages",
|
||||
"javascript": "JavaScript",
|
||||
"jflex": "JFlex",
|
||||
"jison": "Jison",
|
||||
"jison_lex": "Jison Lex",
|
||||
"jruby": "Ruby",
|
||||
"js": "JavaScript",
|
||||
"json": "JSON",
|
||||
"json5": "JSON5",
|
||||
"jsoniq": "JSONiq",
|
||||
"jsonld": "JSONLD",
|
||||
"jsp": "Java Server Pages",
|
||||
"jsx": "JSX",
|
||||
"julia": "Julia",
|
||||
"jupyter_notebook": "Jupyter Notebook",
|
||||
"kicad": "KiCad",
|
||||
"kit": "Kit",
|
||||
"kotlin": "Kotlin",
|
||||
"krl": "KRL",
|
||||
"labview": "LabVIEW",
|
||||
"lasso": "Lasso",
|
||||
"lassoscript": "Lasso",
|
||||
"latex": "TeX",
|
||||
"latte": "Latte",
|
||||
"lean": "Lean",
|
||||
"less": "Less",
|
||||
"lex": "Lex",
|
||||
"lfe": "LFE",
|
||||
"lhaskell": "Literate Haskell",
|
||||
"lhs": "Literate Haskell",
|
||||
"lilypond": "LilyPond",
|
||||
"limbo": "Limbo",
|
||||
"linker_script": "Linker Script",
|
||||
"linux_kernel_module": "Linux Kernel Module",
|
||||
"liquid": "Liquid",
|
||||
"lisp": "Common Lisp",
|
||||
"litcoffee": "Literate CoffeeScript",
|
||||
"literate_agda": "Literate Agda",
|
||||
"literate_coffeescript": "Literate CoffeeScript",
|
||||
"literate_haskell": "Literate Haskell",
|
||||
"live-script": "LiveScript",
|
||||
"livescript": "LiveScript",
|
||||
"llvm": "LLVM",
|
||||
"logos": "Logos",
|
||||
"logtalk": "Logtalk",
|
||||
"lolcode": "LOLCODE",
|
||||
"lookml": "LookML",
|
||||
"loomscript": "LoomScript",
|
||||
"ls": "LiveScript",
|
||||
"lsl": "LSL",
|
||||
"lua": "Lua",
|
||||
"m": "M",
|
||||
"m4": "M4",
|
||||
"m4sugar": "M4Sugar",
|
||||
"macruby": "Ruby",
|
||||
"make": "Makefile",
|
||||
"makefile": "Makefile",
|
||||
"mako": "Mako",
|
||||
"markdown": "Markdown",
|
||||
"marko": "Marko",
|
||||
"markojs": "Marko",
|
||||
"mask": "Mask",
|
||||
"mathematica": "Mathematica",
|
||||
"matlab": "Matlab",
|
||||
"maven_pom": "Maven POM",
|
||||
"max": "Max",
|
||||
"max/msp": "Max",
|
||||
"maxmsp": "Max",
|
||||
"maxscript": "MAXScript",
|
||||
"mediawiki": "MediaWiki",
|
||||
"mercury": "Mercury",
|
||||
"meson": "Meson",
|
||||
"metal": "Metal",
|
||||
"mf": "Makefile",
|
||||
"minid": "MiniD",
|
||||
"mirah": "Mirah",
|
||||
"mma": "Mathematica",
|
||||
"modelica": "Modelica",
|
||||
"modula-2": "Modula-2",
|
||||
"module_management_system": "Module Management System",
|
||||
"monkey": "Monkey",
|
||||
"moocode": "Moocode",
|
||||
"moonscript": "MoonScript",
|
||||
"mql4": "MQL4",
|
||||
"mql5": "MQL5",
|
||||
"mtml": "MTML",
|
||||
"muf": "MUF",
|
||||
"mumps": "M",
|
||||
"mupad": "mupad",
|
||||
"myghty": "Myghty",
|
||||
"nasm": "Assembly",
|
||||
"ncl": "NCL",
|
||||
"nemerle": "Nemerle",
|
||||
"nesc": "nesC",
|
||||
"netlinx": "NetLinx",
|
||||
"netlinx+erb": "NetLinx+ERB",
|
||||
"netlogo": "NetLogo",
|
||||
"newlisp": "NewLisp",
|
||||
"nginx": "Nginx",
|
||||
"nginx_configuration_file": "Nginx",
|
||||
"nim": "Nim",
|
||||
"ninja": "Ninja",
|
||||
"nit": "Nit",
|
||||
"nix": "Nix",
|
||||
"nixos": "Nix",
|
||||
"njk": "HTML+Django",
|
||||
"nl": "NL",
|
||||
"node": "JavaScript",
|
||||
"nroff": "Roff",
|
||||
"nsis": "NSIS",
|
||||
"nu": "Nu",
|
||||
"numpy": "NumPy",
|
||||
"nunjucks": "HTML+Django",
|
||||
"nush": "Nu",
|
||||
"nvim": "Vim script",
|
||||
"obj-c": "Objective-C",
|
||||
"obj-c++": "Objective-C++",
|
||||
"obj-j": "Objective-J",
|
||||
"objc": "Objective-C",
|
||||
"objc++": "Objective-C++",
|
||||
"objdump": "ObjDump",
|
||||
"objective-c": "Objective-C",
|
||||
"objective-c++": "Objective-C++",
|
||||
"objective-j": "Objective-J",
|
||||
"objectivec": "Objective-C",
|
||||
"objectivec++": "Objective-C++",
|
||||
"objectivej": "Objective-J",
|
||||
"objectpascal": "Component Pascal",
|
||||
"objj": "Objective-J",
|
||||
"ocaml": "OCaml",
|
||||
"octave": "Matlab",
|
||||
"omgrofl": "Omgrofl",
|
||||
"ooc": "ooc",
|
||||
"opa": "Opa",
|
||||
"opal": "Opal",
|
||||
"opencl": "OpenCL",
|
||||
"openedge": "OpenEdge ABL",
|
||||
"openedge_abl": "OpenEdge ABL",
|
||||
"openrc": "OpenRC runscript",
|
||||
"openrc_runscript": "OpenRC runscript",
|
||||
"openscad": "OpenSCAD",
|
||||
"opentype_feature_file": "OpenType Feature File",
|
||||
"org": "Org",
|
||||
"osascript": "AppleScript",
|
||||
"ox": "Ox",
|
||||
"oxygene": "Oxygene",
|
||||
"oz": "Oz",
|
||||
"p4": "P4",
|
||||
"pan": "Pan",
|
||||
"pandoc": "Markdown",
|
||||
"papyrus": "Papyrus",
|
||||
"parrot": "Parrot",
|
||||
"parrot_assembly": "Parrot Assembly",
|
||||
"parrot_internal_representation": "Parrot Internal Representation",
|
||||
"pascal": "Pascal",
|
||||
"pasm": "Parrot Assembly",
|
||||
"pawn": "PAWN",
|
||||
"perl": "Perl",
|
||||
"perl6": "Perl6",
|
||||
"php": "PHP",
|
||||
"pic": "Pic",
|
||||
"pickle": "Pickle",
|
||||
"picolisp": "PicoLisp",
|
||||
"piglatin": "PigLatin",
|
||||
"pike": "Pike",
|
||||
"pir": "Parrot Internal Representation",
|
||||
"plpgsql": "PLpgSQL",
|
||||
"plsql": "PLSQL",
|
||||
"pod": "Pod",
|
||||
"pogoscript": "PogoScript",
|
||||
"pony": "Pony",
|
||||
"posh": "PowerShell",
|
||||
"postscr": "PostScript",
|
||||
"postscript": "PostScript",
|
||||
"pot": "Gettext Catalog",
|
||||
"pov-ray": "POV-Ray SDL",
|
||||
"pov-ray_sdl": "POV-Ray SDL",
|
||||
"povray": "POV-Ray SDL",
|
||||
"powerbuilder": "PowerBuilder",
|
||||
"powershell": "PowerShell",
|
||||
"processing": "Processing",
|
||||
"progress": "OpenEdge ABL",
|
||||
"prolog": "Prolog",
|
||||
"propeller_spin": "Propeller Spin",
|
||||
"protobuf": "Protocol Buffer",
|
||||
"protocol_buffer": "Protocol Buffer",
|
||||
"protocol_buffers": "Protocol Buffer",
|
||||
"public_key": "Public Key",
|
||||
"pug": "Pug",
|
||||
"puppet": "Puppet",
|
||||
"pure_data": "Pure Data",
|
||||
"purebasic": "PureBasic",
|
||||
"purescript": "PureScript",
|
||||
"pycon": "Python console",
|
||||
"pyrex": "Cython",
|
||||
"python": "Python",
|
||||
"python_console": "Python console",
|
||||
"python_traceback": "Python traceback",
|
||||
"qmake": "QMake",
|
||||
"qml": "QML",
|
||||
"r": "R",
|
||||
"racket": "Racket",
|
||||
"ragel": "Ragel",
|
||||
"ragel-rb": "Ragel",
|
||||
"ragel-ruby": "Ragel",
|
||||
"rake": "Ruby",
|
||||
"raml": "RAML",
|
||||
"rascal": "Rascal",
|
||||
"raw": "Raw token data",
|
||||
"raw_token_data": "Raw token data",
|
||||
"rb": "Ruby",
|
||||
"rbx": "Ruby",
|
||||
"rdoc": "RDoc",
|
||||
"realbasic": "REALbasic",
|
||||
"reason": "Reason",
|
||||
"rebol": "Rebol",
|
||||
"red": "Red",
|
||||
"red/system": "Red",
|
||||
"redcode": "Redcode",
|
||||
"regex": "Regular Expression",
|
||||
"regexp": "Regular Expression",
|
||||
"regular_expression": "Regular Expression",
|
||||
"ren'py": "Ren'Py",
|
||||
"renderscript": "RenderScript",
|
||||
"renpy": "Ren'Py",
|
||||
"restructuredtext": "reStructuredText",
|
||||
"rexx": "REXX",
|
||||
"rhtml": "RHTML",
|
||||
"rmarkdown": "RMarkdown",
|
||||
"robotframework": "RobotFramework",
|
||||
"roff": "Roff",
|
||||
"rouge": "Rouge",
|
||||
"rpm_spec": "RPM Spec",
|
||||
"rscript": "R",
|
||||
"rss": "XML",
|
||||
"rst": "reStructuredText",
|
||||
"ruby": "Ruby",
|
||||
"runoff": "RUNOFF",
|
||||
"rust": "Rust",
|
||||
"rusthon": "Python",
|
||||
"sage": "Sage",
|
||||
"salt": "SaltStack",
|
||||
"saltstack": "SaltStack",
|
||||
"saltstate": "SaltStack",
|
||||
"sas": "SAS",
|
||||
"sass": "Sass",
|
||||
"scala": "Scala",
|
||||
"scaml": "Scaml",
|
||||
"scheme": "Scheme",
|
||||
"scilab": "Scilab",
|
||||
"scss": "SCSS",
|
||||
"self": "Self",
|
||||
"sh": "Shell",
|
||||
"shell": "Shell",
|
||||
"shell-script": "Shell",
|
||||
"shellsession": "ShellSession",
|
||||
"shen": "Shen",
|
||||
"slash": "Slash",
|
||||
"slim": "Slim",
|
||||
"smali": "Smali",
|
||||
"smalltalk": "Smalltalk",
|
||||
"smarty": "Smarty",
|
||||
"sml": "Standard ML",
|
||||
"smt": "SMT",
|
||||
"sourcemod": "SourcePawn",
|
||||
"sourcepawn": "SourcePawn",
|
||||
"sparql": "SPARQL",
|
||||
"specfile": "RPM Spec",
|
||||
"spline_font_database": "Spline Font Database",
|
||||
"splus": "R",
|
||||
"sqf": "SQF",
|
||||
"sql": "SQL",
|
||||
"sqlpl": "SQLPL",
|
||||
"squeak": "Smalltalk",
|
||||
"squirrel": "Squirrel",
|
||||
"srecode_template": "SRecode Template",
|
||||
"stan": "Stan",
|
||||
"standard_ml": "Standard ML",
|
||||
"stata": "Stata",
|
||||
"ston": "STON",
|
||||
"stylus": "Stylus",
|
||||
"sublime_text_config": "Sublime Text Config",
|
||||
"subrip_text": "SubRip Text",
|
||||
"supercollider": "SuperCollider",
|
||||
"svg": "SVG",
|
||||
"swift": "Swift",
|
||||
"systemverilog": "SystemVerilog",
|
||||
"tcl": "Tcl",
|
||||
"tcsh": "Tcsh",
|
||||
"tea": "Tea",
|
||||
"terra": "Terra",
|
||||
"tex": "TeX",
|
||||
"text": "Text",
|
||||
"textile": "Textile",
|
||||
"thrift": "Thrift",
|
||||
"ti_program": "TI Program",
|
||||
"tla": "TLA",
|
||||
"toml": "TOML",
|
||||
"ts": "TypeScript",
|
||||
"turing": "Turing",
|
||||
"turtle": "Turtle",
|
||||
"twig": "Twig",
|
||||
"txl": "TXL",
|
||||
"typescript": "TypeScript",
|
||||
"udiff": "Diff",
|
||||
"unified_parallel_c": "Unified Parallel C",
|
||||
"unity3d_asset": "Unity3D Asset",
|
||||
"unix_assembly": "Unix Assembly",
|
||||
"uno": "Uno",
|
||||
"unrealscript": "UnrealScript",
|
||||
"ur": "UrWeb",
|
||||
"ur/web": "UrWeb",
|
||||
"urweb": "UrWeb",
|
||||
"vala": "Vala",
|
||||
"vb.net": "Visual Basic",
|
||||
"vbnet": "Visual Basic",
|
||||
"vcl": "VCL",
|
||||
"verilog": "Verilog",
|
||||
"vhdl": "VHDL",
|
||||
"vim": "Vim script",
|
||||
"vim_script": "Vim script",
|
||||
"viml": "Vim script",
|
||||
"visual_basic": "Visual Basic",
|
||||
"volt": "Volt",
|
||||
"vue": "Vue",
|
||||
"wavefront_material": "Wavefront Material",
|
||||
"wavefront_object": "Wavefront Object",
|
||||
"web_ontology_language": "Web Ontology Language",
|
||||
"webidl": "WebIDL",
|
||||
"winbatch": "Batchfile",
|
||||
"wisp": "wisp",
|
||||
"world_of_warcraft_addon_data": "World of Warcraft Addon Data",
|
||||
"wsdl": "XML",
|
||||
"x10": "X10",
|
||||
"xbase": "xBase",
|
||||
"xc": "XC",
|
||||
"xcompose": "XCompose",
|
||||
"xhtml": "HTML",
|
||||
"xml": "XML",
|
||||
"xml+genshi": "Genshi",
|
||||
"xml+kid": "Genshi",
|
||||
"xojo": "Xojo",
|
||||
"xpages": "XPages",
|
||||
"xproc": "XProc",
|
||||
"xquery": "XQuery",
|
||||
"xs": "XS",
|
||||
"xsd": "XML",
|
||||
"xsl": "XSLT",
|
||||
"xslt": "XSLT",
|
||||
"xten": "X10",
|
||||
"xtend": "Xtend",
|
||||
"yacc": "Yacc",
|
||||
"yaml": "YAML",
|
||||
"yang": "YANG",
|
||||
"yml": "YAML",
|
||||
"zephir": "Zephir",
|
||||
"zimpl": "Zimpl",
|
||||
"zsh": "Shell",
|
||||
}
|
@ -7,7 +7,6 @@ import (
|
||||
|
||||
func GetLanguageByExtension(filename string) (lang string, safe bool) {
|
||||
ext := strings.ToLower(filepath.Ext(filename))
|
||||
|
||||
lang = OtherLanguage
|
||||
langs, ok := languagesByExtension[ext]
|
||||
if !ok {
|
||||
@ -15,9 +14,6 @@ func GetLanguageByExtension(filename string) (lang string, safe bool) {
|
||||
}
|
||||
|
||||
lang = langs[0]
|
||||
if len(langs) == 1 {
|
||||
safe = true
|
||||
}
|
||||
|
||||
safe = len(langs) == 1
|
||||
return
|
||||
}
|
||||
|
13
internal/code-generator/assets/aliases.go.tmpl
Normal file
13
internal/code-generator/assets/aliases.go.tmpl
Normal file
@ -0,0 +1,13 @@
|
||||
package slinguist
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.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 a 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{
|
||||
{{range $alias, $language := . -}}
|
||||
"{{ $alias }}": {{ printf "%q" $language -}},
|
||||
{{end -}}
|
||||
}
|
63
internal/code-generator/generator/aliases.go
Normal file
63
internal/code-generator/generator/aliases.go
Normal file
@ -0,0 +1,63 @@
|
||||
package generator
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"text/template"
|
||||
|
||||
"strings"
|
||||
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// Aliases reads from buf and builds aliases_map.go file from aliasesTmplPath.
|
||||
func Aliases(data []byte, aliasesTmplPath, aliasesTmplName, commit string) ([]byte, error) {
|
||||
languages := make(map[string]*languageInfo)
|
||||
if err := yaml.Unmarshal(data, &languages); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
orderedLangList := getAlphabeticalOrderedKeys(languages)
|
||||
languagesByAlias := buildAliasLanguageMap(languages, orderedLangList)
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
if err := executeAliasesTemplate(buf, languagesByAlias, aliasesTmplPath, aliasesTmplName, commit); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
func buildAliasLanguageMap(languages map[string]*languageInfo, orderedLangList []string) map[string]string {
|
||||
aliasLangsMap := make(map[string]string)
|
||||
for _, lang := range orderedLangList {
|
||||
langInfo := languages[lang]
|
||||
key := convertToAliasKey(lang)
|
||||
aliasLangsMap[key] = lang
|
||||
for _, alias := range langInfo.Aliases {
|
||||
key := convertToAliasKey(alias)
|
||||
aliasLangsMap[key] = lang
|
||||
}
|
||||
}
|
||||
|
||||
return aliasLangsMap
|
||||
}
|
||||
|
||||
func convertToAliasKey(s string) (key string) {
|
||||
key = strings.Replace(s, ` `, `_`, -1)
|
||||
key = strings.ToLower(key)
|
||||
return
|
||||
}
|
||||
|
||||
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
|
||||
}
|
@ -53,6 +53,12 @@ const (
|
||||
filenamesGold = "test_files/filenames.gold"
|
||||
filenamesTestTmplPath = "../assets/filenames.go.tmpl"
|
||||
filenamesTestTmplName = "filenames.go.tmpl"
|
||||
|
||||
// Aliases test
|
||||
aliasesTestFile = "test_files/aliases.test.yml"
|
||||
aliasesGold = "test_files/aliases.gold"
|
||||
aliasesTestTmplPath = "../assets/aliases.go.tmpl"
|
||||
aliasesTestTmplName = "aliases.go.tmpl"
|
||||
)
|
||||
|
||||
func TestFromFile(t *testing.T) {
|
||||
@ -128,6 +134,15 @@ func TestFromFile(t *testing.T) {
|
||||
generate: Filenames,
|
||||
wantOut: filenamesGold,
|
||||
},
|
||||
{
|
||||
name: "TestFromFile_Aliases",
|
||||
fileToParse: aliasesTestFile,
|
||||
tmplPath: aliasesTestTmplPath,
|
||||
tmplName: aliasesTestTmplName,
|
||||
commit: commitTest,
|
||||
generate: Aliases,
|
||||
wantOut: aliasesGold,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
@ -4,6 +4,7 @@ import "sort"
|
||||
|
||||
type languageInfo struct {
|
||||
Type string `yaml:"type,omitempty"`
|
||||
Aliases []string `yaml:"aliases,omitempty"`
|
||||
Extensions []string `yaml:"extensions,omitempty,flow"`
|
||||
Interpreters []string `yaml:"interpreters,omitempty,flow"`
|
||||
Filenames []string `yaml:"filenames,omitempty,flow"`
|
||||
|
42
internal/code-generator/generator/test_files/aliases.gold
Normal file
42
internal/code-generator/generator/test_files/aliases.gold
Normal file
@ -0,0 +1,42 @@
|
||||
package slinguist
|
||||
|
||||
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/simple-linguist.v1/internal/code-generator
|
||||
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||
// Extracted from github/linguist commit: fe8b44ab8a225b1ffa75b983b916ea22fee5b6f7
|
||||
|
||||
// languagesByAlias keeps alias for different languages and use the name of the languages as a 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{
|
||||
"asp": "ASP",
|
||||
"aspx": "ASP",
|
||||
"aspx-vb": "ASP",
|
||||
"au3": "AutoIt",
|
||||
"autoit": "AutoIt",
|
||||
"autoit3": "AutoIt",
|
||||
"autoitscript": "AutoIt",
|
||||
"bat": "Batchfile",
|
||||
"batch": "Batchfile",
|
||||
"batchfile": "Batchfile",
|
||||
"bsdmake": "Makefile",
|
||||
"c++": "C++",
|
||||
"cpp": "C++",
|
||||
"django": "HTML+Django",
|
||||
"dosbatch": "Batchfile",
|
||||
"go": "Go",
|
||||
"golang": "Go",
|
||||
"gradle": "Gradle",
|
||||
"html+django": "HTML+Django",
|
||||
"html+django/jinja": "HTML+Django",
|
||||
"html+jinja": "HTML+Django",
|
||||
"htmldjango": "HTML+Django",
|
||||
"make": "Makefile",
|
||||
"makefile": "Makefile",
|
||||
"mf": "Makefile",
|
||||
"njk": "HTML+Django",
|
||||
"nunjucks": "HTML+Django",
|
||||
"obj-c": "Objective-C",
|
||||
"objc": "Objective-C",
|
||||
"objective-c": "Objective-C",
|
||||
"objectivec": "Objective-C",
|
||||
"winbatch": "Batchfile",
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
---
|
||||
ASP:
|
||||
aliases:
|
||||
- aspx
|
||||
- aspx-vb
|
||||
AutoIt:
|
||||
aliases:
|
||||
- au3
|
||||
- AutoIt3
|
||||
- AutoItScript
|
||||
Batchfile:
|
||||
aliases:
|
||||
- bat
|
||||
- batch
|
||||
- dosbatch
|
||||
- winbatch
|
||||
C++:
|
||||
aliases:
|
||||
- cpp
|
||||
Go:
|
||||
aliases:
|
||||
- golang
|
||||
Gradle:
|
||||
type: data
|
||||
HTML+Django:
|
||||
aliases:
|
||||
- django
|
||||
- html+django/jinja
|
||||
- html+jinja
|
||||
- htmldjango
|
||||
- njk
|
||||
- nunjucks
|
||||
Makefile:
|
||||
aliases:
|
||||
- bsdmake
|
||||
- make
|
||||
- mf
|
||||
Objective-C:
|
||||
aliases:
|
||||
- obj-c
|
||||
- objc
|
||||
- objectivec
|
@ -35,9 +35,9 @@ const (
|
||||
documentationTmpl = "documentation.go.tmpl"
|
||||
|
||||
// type.go generation
|
||||
typeFile = "type.go"
|
||||
typeTmplPath = "internal/code-generator/assets/type.go.tmpl"
|
||||
typeTmpl = "type.go.tmpl"
|
||||
typeFile = "types_map.go"
|
||||
typeTmplPath = "internal/code-generator/assets/types.go.tmpl"
|
||||
typeTmpl = "types.go.tmpl"
|
||||
|
||||
// interpreters_map.go generation
|
||||
interpretersFile = "interpreters_map.go"
|
||||
@ -49,6 +49,11 @@ const (
|
||||
filenamesTmplPath = "internal/code-generator/assets/filenames.go.tmpl"
|
||||
filenamesTmpl = "filenames.go.tmpl"
|
||||
|
||||
// aliases_map.go generation
|
||||
aliasesFile = "aliases_map.go"
|
||||
aliasesTmplPath = "internal/code-generator/assets/aliases.go.tmpl"
|
||||
aliasesTmpl = "aliases.go.tmpl"
|
||||
|
||||
commitPath = ".git/refs/heads/master"
|
||||
)
|
||||
|
||||
@ -75,6 +80,7 @@ func main() {
|
||||
&generatorArgs{languagesYAML, typeFile, typeTmplPath, typeTmpl, commit, generator.Types},
|
||||
&generatorArgs{languagesYAML, interpretersFile, interpretersTmplPath, interpretersTmpl, commit, generator.Interpreters},
|
||||
&generatorArgs{languagesYAML, filenamesFile, filenamesTmplPath, filenamesTmpl, commit, generator.Filenames},
|
||||
&generatorArgs{languagesYAML, aliasesFile, aliasesTmplPath, aliasesTmpl, commit, generator.Aliases},
|
||||
}
|
||||
|
||||
for _, args := range argsList {
|
||||
|
Loading…
x
Reference in New Issue
Block a user