slice of languages arranged in alphabetical order

This commit is contained in:
Manuel Carmona 2017-04-12 09:10:16 +02:00
parent 9a9968dca0
commit 25e835f5fd
2 changed files with 71 additions and 51 deletions

View File

@ -24,7 +24,12 @@ func Languages(data []byte, languagesTmplPath, languagesTmplName, commit string)
return nil, err
}
languagesByExtension := buildExtensionLanguageMap(languages)
orderedKeyList, err := getAlphabeticalOrderedKeys(data)
if err != nil {
return nil, err
}
languagesByExtension := buildExtensionLanguageMap(languages, orderedKeyList)
buf := &bytes.Buffer{}
if err := executeLanguagesTemplate(buf, languagesByExtension, languagesTmplPath, languagesTmplName, commit); err != nil {
@ -34,10 +39,25 @@ func Languages(data []byte, languagesTmplPath, languagesTmplName, commit string)
return buf.Bytes(), nil
}
func buildExtensionLanguageMap(languages map[string]*languageInfo) map[string][]string {
func getAlphabeticalOrderedKeys(data []byte) ([]string, error) {
var yamlSlice yaml.MapSlice
if err := yaml.Unmarshal(data, &yamlSlice); err != nil {
return nil, err
}
orderedKeyList := make([]string, 0)
for _, lang := range yamlSlice {
orderedKeyList = append(orderedKeyList, lang.Key.(string))
}
return orderedKeyList, nil
}
func buildExtensionLanguageMap(languages map[string]*languageInfo, orderedKeyList []string) map[string][]string {
extensionLangsMap := make(map[string][]string)
for lang, info := range languages {
for _, extension := range info.Extensions {
for _, lang := range orderedKeyList {
langInfo := languages[lang]
for _, extension := range langInfo.Extensions {
extensionLangsMap[extension] = append(extensionLangsMap[extension], lang)
}
}

View File

@ -62,7 +62,7 @@ var languagesByExtension = map[string][]string{
".arpa": {"DNS Zone"},
".as": {"ActionScript"},
".asax": {"ASP"},
".asc": {"AGS Script", "Public Key", "AsciiDoc"},
".asc": {"AGS Script", "AsciiDoc", "Public Key"},
".asciidoc": {"AsciiDoc"},
".ascx": {"ASP"},
".asd": {"Common Lisp"},
@ -92,7 +92,7 @@ var languagesByExtension = map[string][]string{
".bash": {"Shell"},
".bat": {"Batchfile"},
".bats": {"Shell"},
".bb": {"BlitzBasic", "BitBake"},
".bb": {"BitBake", "BlitzBasic"},
".bbx": {"TeX"},
".befunge": {"Befunge"},
".bf": {"Brainfuck", "HyPhy"},
@ -131,7 +131,7 @@ var languagesByExtension = map[string][]string{
".cfg": {"INI"},
".cfm": {"ColdFusion"},
".cfml": {"ColdFusion"},
".cgi": {"Python", "Perl", "Shell"},
".cgi": {"Perl", "Python", "Shell"},
".ch": {"Charity", "xBase"},
".chem": {"Pic"},
".chpl": {"Chapel"},
@ -139,7 +139,7 @@ var languagesByExtension = map[string][]string{
".cirru": {"Cirru"},
".cjsx": {"CoffeeScript"},
".ck": {"ChucK"},
".cl": {"Common Lisp", "OpenCL", "Cool"},
".cl": {"Common Lisp", "Cool", "OpenCL"},
".cl2": {"Clojure"},
".click": {"Click"},
".clixml": {"XML"},
@ -150,7 +150,7 @@ var languagesByExtension = map[string][]string{
".cljscm": {"Clojure"},
".cljx": {"Clojure"},
".clp": {"CLIPS"},
".cls": {"Apex", "TeX", "Visual Basic", "OpenEdge ABL"},
".cls": {"Apex", "OpenEdge ABL", "TeX", "Visual Basic"},
".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": {"Component Pascal", "C++"},
".cp": {"C++", "Component Pascal"},
".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", "D", "DTrace"},
".d": {"D", "DTrace", "Makefile"},
".d-objdump": {"D-ObjDump"},
".dae": {"COLLADA"},
".darcspatch": {"Darcs Patch"},
@ -251,13 +251,13 @@ var languagesByExtension = map[string][]string{
".erb": {"HTML+ERB"},
".erb.deface": {"HTML+ERB"},
".erl": {"Erlang"},
".es": {"JavaScript", "Erlang"},
".es": {"Erlang", "JavaScript"},
".es6": {"JavaScript"},
".escript": {"Erlang"},
".ex": {"Elixir"},
".exs": {"Elixir"},
".eye": {"Ruby"},
".f": {"Fortran", "Forth", "Filebench WML"},
".f": {"Filebench WML", "Forth", "Fortran"},
".f03": {"Fortran"},
".f08": {"Fortran"},
".f77": {"Fortran"},
@ -266,24 +266,24 @@ var languagesByExtension = map[string][]string{
".factor": {"Factor"},
".fan": {"Fantom"},
".fancypack": {"Fancy"},
".fcgi": {"PHP", "Python", "Perl", "Shell", "Ruby", "Lua"},
".fcgi": {"Lua", "PHP", "Perl", "Python", "Ruby", "Shell"},
".fea": {"OpenType Feature File"},
".feature": {"Gherkin"},
".filters": {"XML"},
".fish": {"fish"},
".flex": {"JFlex"},
".flux": {"FLUX"},
".for": {"Fortran", "Formatted", "Forth"},
".for": {"Formatted", "Forth", "Fortran"},
".forth": {"Forth"},
".fp": {"GLSL"},
".fpp": {"Fortran"},
".fr": {"Forth", "Frege", "Text"},
".frag": {"JavaScript", "GLSL"},
".frag": {"GLSL", "JavaScript"},
".frg": {"GLSL"},
".frm": {"Visual Basic"},
".frt": {"Forth"},
".frx": {"Visual Basic"},
".fs": {"F#", "Forth", "Filterscript", "GLSL"},
".fs": {"F#", "Filterscript", "Forth", "GLSL"},
".fsh": {"GLSL"},
".fshader": {"GLSL"},
".fsi": {"F#"},
@ -292,7 +292,7 @@ var languagesByExtension = map[string][]string{
".fth": {"Forth"},
".ftl": {"FreeMarker"},
".fun": {"Standard ML"},
".fx": {"HLSL", "FLUX"},
".fx": {"FLUX", "HLSL"},
".fxh": {"HLSL"},
".fxml": {"XML"},
".fy": {"Fancy"},
@ -315,7 +315,7 @@ var languagesByExtension = map[string][]string{
".glf": {"Glyph"},
".glsl": {"GLSL"},
".glslv": {"GLSL"},
".gml": {"XML", "Graph Modeling Language", "Game Maker Language"},
".gml": {"Game Maker Language", "Graph Modeling Language", "XML"},
".gms": {"GAMS"},
".gn": {"GN"},
".gni": {"GN"},
@ -331,7 +331,7 @@ var languagesByExtension = map[string][]string{
".groovy": {"Groovy"},
".grt": {"Groovy"},
".grxml": {"XML"},
".gs": {"JavaScript", "Genie", "Gosu"},
".gs": {"Genie", "Gosu", "JavaScript"},
".gshader": {"GLSL"},
".gsp": {"Groovy Server Pages"},
".gst": {"Gosu"},
@ -341,7 +341,7 @@ var languagesByExtension = map[string][]string{
".gvy": {"Groovy"},
".gyp": {"Python"},
".gypi": {"Python"},
".h": {"C++", "C", "Objective-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": {"Hack", "C++"},
".hh": {"C++", "Hack"},
".hic": {"Clojure"},
".hlean": {"Lean"},
".hlsl": {"HLSL"},
@ -378,7 +378,7 @@ var languagesByExtension = map[string][]string{
".ik": {"Ioke"},
".ily": {"LilyPond"},
".iml": {"XML"},
".inc": {"PHP", "Assembly", "HTML", "POV-Ray SDL", "SQL", "Pascal", "C++", "SourcePawn", "PAWN"},
".inc": {"Assembly", "C++", "HTML", "PAWN", "PHP", "POV-Ray SDL", "Pascal", "SQL", "SourcePawn"},
".ini": {"INI"},
".inl": {"C++"},
".ino": {"Arduino"},
@ -392,7 +392,7 @@ var languagesByExtension = map[string][]string{
".irclog": {"IRC log"},
".iss": {"Inno Setup"},
".ivy": {"XML"},
".j": {"Objective-J", "Jasmin"},
".j": {"Jasmin", "Objective-J"},
".jade": {"Pug"},
".jake": {"JavaScript"},
".java": {"Java"},
@ -425,7 +425,7 @@ var languagesByExtension = map[string][]string{
".kt": {"Kotlin"},
".ktm": {"Kotlin"},
".kts": {"Kotlin"},
".l": {"Common Lisp", "Roff", "PicoLisp", "Lex"},
".l": {"Common Lisp", "Lex", "PicoLisp", "Roff"},
".lagda": {"Literate Agda"},
".las": {"Lasso"},
".lasso": {"Lasso"},
@ -446,7 +446,7 @@ var languagesByExtension = map[string][]string{
".lid": {"Dylan"},
".lidr": {"Idris"},
".liquid": {"Liquid"},
".lisp": {"NewLisp", "Common Lisp"},
".lisp": {"Common Lisp", "NewLisp"},
".litcoffee": {"Literate CoffeeScript"},
".ll": {"LLVM"},
".lmi": {"Python"},
@ -457,13 +457,13 @@ var languagesByExtension = map[string][]string{
".ls": {"LiveScript", "LoomScript"},
".lsl": {"LSL"},
".lslp": {"LSL"},
".lsp": {"NewLisp", "Common Lisp"},
".lsp": {"Common Lisp", "NewLisp"},
".ltx": {"TeX"},
".lua": {"Lua"},
".lvproj": {"LabVIEW"},
".ly": {"LilyPond"},
".m": {"Matlab", "M", "Limbo", "Objective-C", "Mathematica", "MUF", "Mercury"},
".m4": {"M4Sugar", "M4"},
".m": {"Limbo", "M", "MUF", "Mathematica", "Matlab", "Mercury", "Objective-C"},
".m4": {"M4", "M4Sugar"},
".ma": {"Mathematica"},
".mak": {"Makefile"},
".make": {"Makefile"},
@ -483,7 +483,7 @@ var languagesByExtension = map[string][]string{
".maxpat": {"Max"},
".maxproj": {"Max"},
".mcr": {"MAXScript"},
".md": {"Markdown", "GCC Machine Description"},
".md": {"GCC Machine Description", "Markdown"},
".mdown": {"Markdown"},
".mdpolicy": {"XML"},
".mdwn": {"Markdown"},
@ -507,19 +507,19 @@ var languagesByExtension = map[string][]string{
".mli": {"OCaml"},
".mll": {"OCaml"},
".mly": {"OCaml"},
".mm": {"XML", "Objective-C++"},
".mm": {"Objective-C++", "XML"},
".mmk": {"Module Management System"},
".mms": {"Module Management System"},
".mo": {"Modelica"},
".mod": {"XML", "Modula-2", "AMPL", "Linux Kernel Module"},
".mod": {"AMPL", "Linux Kernel Module", "Modula-2", "XML"},
".model.lkml": {"LookML"},
".monkey": {"Monkey"},
".moo": {"Moocode", "Mercury"},
".moo": {"Mercury", "Moocode"},
".moon": {"MoonScript"},
".mq4": {"MQL4"},
".mq5": {"MQL5"},
".mqh": {"MQL5", "MQL4"},
".ms": {"Unix Assembly", "Roff", "MAXScript"},
".mqh": {"MQL4", "MQL5"},
".ms": {"MAXScript", "Roff", "Unix Assembly"},
".mspec": {"Ruby"},
".mss": {"CartoCSS"},
".mt": {"Mathematica"},
@ -536,7 +536,7 @@ var languagesByExtension = map[string][]string{
".n": {"Nemerle", "Roff"},
".nasm": {"Assembly"},
".nawk": {"Awk"},
".nb": {"Text", "Mathematica"},
".nb": {"Mathematica", "Text"},
".nbp": {"Mathematica"},
".nc": {"nesC"},
".ncl": {"NCL", "Text"},
@ -549,7 +549,7 @@ var languagesByExtension = map[string][]string{
".nix": {"Nix"},
".njk": {"HTML+Django"},
".njs": {"JavaScript"},
".nl": {"NewLisp", "NL"},
".nl": {"NL", "NewLisp"},
".nlogo": {"NetLogo"},
".no": {"Text"},
".nproj": {"XML"},
@ -604,7 +604,7 @@ var languagesByExtension = map[string][]string{
".pde": {"Processing"},
".perl": {"Perl"},
".ph": {"Perl"},
".php": {"PHP", "Hack"},
".php": {"Hack", "PHP"},
".php3": {"PHP"},
".php4": {"PHP"},
".php5": {"PHP"},
@ -627,7 +627,7 @@ var languagesByExtension = map[string][]string{
".pls": {"PLSQL"},
".plsql": {"PLSQL"},
".plt": {"Gnuplot"},
".pluginspec": {"XML", "Ruby"},
".pluginspec": {"Ruby", "XML"},
".plx": {"Perl"},
".pm": {"Perl", "Perl6"},
".pm6": {"Perl6"},
@ -640,14 +640,14 @@ var languagesByExtension = map[string][]string{
".pony": {"Pony"},
".pot": {"Gettext Catalog"},
".pov": {"POV-Ray SDL"},
".pp": {"Puppet", "Pascal"},
".pp": {"Pascal", "Puppet"},
".pprx": {"REXX"},
".prc": {"SQL"},
".prefab": {"Unity3D Asset"},
".prefs": {"INI"},
".prg": {"xBase"},
".pri": {"QMake"},
".pro": {"IDL", "QMake", "INI", "Prolog"},
".pro": {"IDL", "INI", "Prolog", "QMake"},
".prolog": {"Prolog"},
".properties": {"INI"},
".props": {"XML"},
@ -678,7 +678,7 @@ var languagesByExtension = map[string][]string{
".pyx": {"Cython"},
".qbs": {"QML"},
".qml": {"QML"},
".r": {"Rebol", "R"},
".r": {"R", "Rebol"},
".r2": {"Rebol"},
".r3": {"Rebol"},
".rabl": {"Ruby"},
@ -699,7 +699,7 @@ var languagesByExtension = map[string][]string{
".rd": {"R"},
".rdf": {"XML"},
".rdoc": {"RDoc"},
".re": {"Reason", "C++"},
".re": {"C++", "Reason"},
".reb": {"Rebol"},
".rebol": {"Rebol"},
".red": {"Red"},
@ -751,7 +751,7 @@ var languagesByExtension = map[string][]string{
".scaml": {"Scaml"},
".scd": {"SuperCollider"},
".sce": {"Scilab"},
".sch": {"XML", "Eagle", "KiCad"},
".sch": {"Eagle", "KiCad", "XML"},
".sci": {"Scilab"},
".scm": {"Scheme"},
".sco": {"Csound Score"},
@ -782,11 +782,11 @@ var languagesByExtension = map[string][]string{
".smt2": {"SMT"},
".sp": {"SourcePawn"},
".sparql": {"SPARQL"},
".spec": {"Python", "Ruby", "RPM Spec"},
".spec": {"Python", "RPM Spec", "Ruby"},
".spin": {"Propeller Spin"},
".sps": {"Scheme"},
".sqf": {"SQF"},
".sql": {"SQLPL", "SQL", "PLpgSQL", "PLSQL"},
".sql": {"PLSQL", "PLpgSQL", "SQL", "SQLPL"},
".sra": {"PowerBuilder"},
".srdf": {"XML"},
".srt": {"SRecode Template", "SubRip Text"},
@ -794,7 +794,7 @@ var languagesByExtension = map[string][]string{
".srw": {"PowerBuilder"},
".ss": {"Scheme"},
".ssjs": {"JavaScript"},
".st": {"Smalltalk", "HTML"},
".st": {"HTML", "Smalltalk"},
".stTheme": {"XML"},
".stan": {"Stan"},
".sthlp": {"Stata"},
@ -822,7 +822,7 @@ var languagesByExtension = map[string][]string{
".svh": {"SystemVerilog"},
".swift": {"Swift"},
".syntax": {"YAML"},
".t": {"Turing", "Perl", "Perl6", "Terra"},
".t": {"Perl", "Perl6", "Terra", "Turing"},
".tab": {"SQL"},
".tac": {"Python"},
".targets": {"XML"},
@ -846,15 +846,15 @@ var languagesByExtension = map[string][]string{
".tmac": {"Roff"},
".tml": {"XML"},
".tmux": {"Shell"},
".toc": {"World of Warcraft Addon Data", "TeX"},
".toc": {"TeX", "World of Warcraft Addon Data"},
".toml": {"TOML"},
".tool": {"Shell"},
".topojson": {"JSON"},
".tpl": {"Smarty"},
".tpp": {"C++"},
".ts": {"XML", "TypeScript"},
".ts": {"TypeScript", "XML"},
".tst": {"GAP", "Scilab"},
".tsx": {"XML", "TypeScript"},
".tsx": {"TypeScript", "XML"},
".ttl": {"Turtle"},
".tu": {"Turing"},
".twig": {"Twig"},