mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-05-24 08:18:52 -03:00
Merge pull request #233 from lafriks/feat/lang_colors
Implement getting HTML color code for languages
This commit is contained in:
commit
ee9d089406
244
data/colors.go
Normal file
244
data/colors.go
Normal file
@ -0,0 +1,244 @@
|
||||
// Code generated by github.com/src-d/enry/v2/internal/code-generator DO NOT EDIT.
|
||||
// Extracted from github/linguist commit: e4560984058b4726010ca4b8f03ed9d0f8f464db
|
||||
|
||||
package data
|
||||
|
||||
var LanguagesColor = map[string]string{
|
||||
"1C Enterprise": "#814CCC",
|
||||
"ABAP": "#E8274B",
|
||||
"AGS Script": "#B9D9FF",
|
||||
"AMPL": "#E6EFBB",
|
||||
"ANTLR": "#9DC3FF",
|
||||
"API Blueprint": "#2ACCA8",
|
||||
"APL": "#5A8164",
|
||||
"ASP": "#6a40fd",
|
||||
"ATS": "#1ac620",
|
||||
"ActionScript": "#882B0F",
|
||||
"Ada": "#02f88c",
|
||||
"Agda": "#315665",
|
||||
"Alloy": "#64C800",
|
||||
"AngelScript": "#C7D7DC",
|
||||
"AppleScript": "#101F1F",
|
||||
"Arc": "#aa2afe",
|
||||
"AspectJ": "#a957b0",
|
||||
"Assembly": "#6E4C13",
|
||||
"Asymptote": "#4a0c0c",
|
||||
"AutoHotkey": "#6594b9",
|
||||
"AutoIt": "#1C3552",
|
||||
"Ballerina": "#FF5000",
|
||||
"Batchfile": "#C1F12E",
|
||||
"BlitzMax": "#cd6400",
|
||||
"Boo": "#d4bec1",
|
||||
"Brainfuck": "#2F2530",
|
||||
"C": "#555555",
|
||||
"C#": "#178600",
|
||||
"C++": "#f34b7d",
|
||||
"CSS": "#563d7c",
|
||||
"Ceylon": "#dfa535",
|
||||
"Chapel": "#8dc63f",
|
||||
"Cirru": "#ccccff",
|
||||
"Clarion": "#db901e",
|
||||
"Clean": "#3F85AF",
|
||||
"Click": "#E4E6F3",
|
||||
"Clojure": "#db5855",
|
||||
"CoffeeScript": "#244776",
|
||||
"ColdFusion": "#ed2cd6",
|
||||
"Common Lisp": "#3fb68b",
|
||||
"Common Workflow Language": "#B5314C",
|
||||
"Component Pascal": "#B0CE4E",
|
||||
"Crystal": "#000100",
|
||||
"Cuda": "#3A4E3A",
|
||||
"D": "#ba595e",
|
||||
"DM": "#447265",
|
||||
"Dart": "#00B4AB",
|
||||
"DataWeave": "#003a52",
|
||||
"Dockerfile": "#384d54",
|
||||
"Dogescript": "#cca760",
|
||||
"Dylan": "#6c616e",
|
||||
"E": "#ccce35",
|
||||
"ECL": "#8a1267",
|
||||
"EQ": "#a78649",
|
||||
"Eiffel": "#946d57",
|
||||
"Elixir": "#6e4a7e",
|
||||
"Elm": "#60B5CC",
|
||||
"Emacs Lisp": "#c065db",
|
||||
"EmberScript": "#FFF4F3",
|
||||
"Erlang": "#B83998",
|
||||
"F#": "#b845fc",
|
||||
"F*": "#572e30",
|
||||
"FLUX": "#88ccff",
|
||||
"Factor": "#636746",
|
||||
"Fancy": "#7b9db4",
|
||||
"Fantom": "#14253c",
|
||||
"Forth": "#341708",
|
||||
"Fortran": "#4d41b1",
|
||||
"FreeMarker": "#0050b2",
|
||||
"Frege": "#00cafe",
|
||||
"GDScript": "#355570",
|
||||
"Game Maker Language": "#71b417",
|
||||
"Genie": "#fb855d",
|
||||
"Gherkin": "#5B2063",
|
||||
"Glyph": "#c1ac7f",
|
||||
"Gnuplot": "#f0a9f0",
|
||||
"Go": "#00ADD8",
|
||||
"Golo": "#88562A",
|
||||
"Gosu": "#82937f",
|
||||
"Grammatical Framework": "#79aa7a",
|
||||
"Groovy": "#e69f56",
|
||||
"HTML": "#e34c26",
|
||||
"Hack": "#878787",
|
||||
"Harbour": "#0e60e3",
|
||||
"Haskell": "#5e5086",
|
||||
"Haxe": "#df7900",
|
||||
"HiveQL": "#dce200",
|
||||
"Hy": "#7790B2",
|
||||
"IDL": "#a3522f",
|
||||
"Idris": "#b30000",
|
||||
"Io": "#a9188d",
|
||||
"Ioke": "#078193",
|
||||
"Isabelle": "#FEFE00",
|
||||
"J": "#9EEDFF",
|
||||
"JSONiq": "#40d47e",
|
||||
"Java": "#b07219",
|
||||
"JavaScript": "#f1e05a",
|
||||
"Jolie": "#843179",
|
||||
"Julia": "#a270ba",
|
||||
"Jupyter Notebook": "#DA5B0B",
|
||||
"KRL": "#28430A",
|
||||
"Kotlin": "#F18E33",
|
||||
"LFE": "#4C3023",
|
||||
"LLVM": "#185619",
|
||||
"LOLCODE": "#cc9900",
|
||||
"LSL": "#3d9970",
|
||||
"Lasso": "#999999",
|
||||
"Lex": "#DBCA00",
|
||||
"LiveScript": "#499886",
|
||||
"LookML": "#652B81",
|
||||
"Lua": "#000080",
|
||||
"MATLAB": "#e16737",
|
||||
"MAXScript": "#00a6a6",
|
||||
"MQL4": "#62A8D6",
|
||||
"MQL5": "#4A76B8",
|
||||
"MTML": "#b7e1f4",
|
||||
"Makefile": "#427819",
|
||||
"Mask": "#f97732",
|
||||
"Max": "#c4a79c",
|
||||
"Mercury": "#ff2b2b",
|
||||
"Meson": "#007800",
|
||||
"Metal": "#8f14e9",
|
||||
"Mirah": "#c7a938",
|
||||
"Modula-3": "#223388",
|
||||
"NCL": "#28431f",
|
||||
"Nearley": "#990000",
|
||||
"Nemerle": "#3d3c6e",
|
||||
"NetLinx": "#0aa0ff",
|
||||
"NetLinx+ERB": "#747faa",
|
||||
"NetLogo": "#ff6375",
|
||||
"NewLisp": "#87AED7",
|
||||
"Nextflow": "#3ac486",
|
||||
"Nim": "#37775b",
|
||||
"Nit": "#009917",
|
||||
"Nix": "#7e7eff",
|
||||
"Nu": "#c9df40",
|
||||
"OCaml": "#3be133",
|
||||
"Objective-C": "#438eff",
|
||||
"Objective-C++": "#6866fb",
|
||||
"Objective-J": "#ff0c5a",
|
||||
"Omgrofl": "#cabbff",
|
||||
"Opal": "#f7ede0",
|
||||
"Oxygene": "#cdd0e3",
|
||||
"Oz": "#fab738",
|
||||
"P4": "#7055b5",
|
||||
"PHP": "#4F5D95",
|
||||
"PLSQL": "#dad8d8",
|
||||
"Pan": "#cc0000",
|
||||
"Papyrus": "#6600cc",
|
||||
"Parrot": "#f3ca0a",
|
||||
"Pascal": "#E3F171",
|
||||
"Pawn": "#dbb284",
|
||||
"Pep8": "#C76F5B",
|
||||
"Perl": "#0298c3",
|
||||
"Perl 6": "#0000fb",
|
||||
"PigLatin": "#fcd7de",
|
||||
"Pike": "#005390",
|
||||
"PogoScript": "#d80074",
|
||||
"PostScript": "#da291c",
|
||||
"PowerBuilder": "#8f0f8d",
|
||||
"PowerShell": "#012456",
|
||||
"Processing": "#0096D8",
|
||||
"Prolog": "#74283c",
|
||||
"Propeller Spin": "#7fa2a7",
|
||||
"Puppet": "#302B6D",
|
||||
"PureBasic": "#5a6986",
|
||||
"PureScript": "#1D222D",
|
||||
"Python": "#3572A5",
|
||||
"QML": "#44a51c",
|
||||
"Quake": "#882233",
|
||||
"R": "#198CE7",
|
||||
"RAML": "#77d9fb",
|
||||
"RUNOFF": "#665a4e",
|
||||
"Racket": "#22228f",
|
||||
"Ragel": "#9d5200",
|
||||
"Rascal": "#fffaa0",
|
||||
"Rebol": "#358a5b",
|
||||
"Red": "#f50000",
|
||||
"Ren'Py": "#ff7f7f",
|
||||
"Ring": "#2D54CB",
|
||||
"Roff": "#ecdebe",
|
||||
"Rouge": "#cc0088",
|
||||
"Ruby": "#701516",
|
||||
"Rust": "#dea584",
|
||||
"SAS": "#B34936",
|
||||
"SQF": "#3F3F3F",
|
||||
"SRecode Template": "#348a34",
|
||||
"SaltStack": "#646464",
|
||||
"Scala": "#c22d40",
|
||||
"Scheme": "#1e4aec",
|
||||
"Self": "#0579aa",
|
||||
"Shell": "#89e051",
|
||||
"Shen": "#120F14",
|
||||
"Slash": "#007eff",
|
||||
"Slice": "#003fa2",
|
||||
"Smalltalk": "#596706",
|
||||
"Solidity": "#AA6746",
|
||||
"SourcePawn": "#5c7611",
|
||||
"Squirrel": "#800000",
|
||||
"Stan": "#b2011d",
|
||||
"Standard ML": "#dc566d",
|
||||
"SuperCollider": "#46390b",
|
||||
"Swift": "#ffac45",
|
||||
"SystemVerilog": "#DAE1C2",
|
||||
"TI Program": "#A0AA87",
|
||||
"Tcl": "#e4cc98",
|
||||
"TeX": "#3D6117",
|
||||
"Terra": "#00004c",
|
||||
"Turing": "#cf142b",
|
||||
"TypeScript": "#2b7489",
|
||||
"UnrealScript": "#a54c4d",
|
||||
"VCL": "#148AA8",
|
||||
"VHDL": "#adb2cb",
|
||||
"Vala": "#fbe5cd",
|
||||
"Verilog": "#b2b7f8",
|
||||
"Vim script": "#199f4b",
|
||||
"Visual Basic": "#945db7",
|
||||
"Volt": "#1F1F1F",
|
||||
"Vue": "#2c3e50",
|
||||
"WebAssembly": "#04133b",
|
||||
"X10": "#4B6BEF",
|
||||
"XC": "#99DA07",
|
||||
"XQuery": "#5232e7",
|
||||
"XSLT": "#EB8CEB",
|
||||
"YARA": "#220000",
|
||||
"YASnippet": "#32AB90",
|
||||
"Yacc": "#4B6C4B",
|
||||
"Zephir": "#118f9e",
|
||||
"Zig": "#ec915c",
|
||||
"eC": "#913960",
|
||||
"nesC": "#94B0C7",
|
||||
"ooc": "#b0b77e",
|
||||
"q": "#0040cd",
|
||||
"sed": "#64b970",
|
||||
"wdl": "#42f1f4",
|
||||
"wisp": "#7582D1",
|
||||
"xBase": "#403a40",
|
||||
}
|
7
internal/code-generator/assets/colors.go.tmpl
Normal file
7
internal/code-generator/assets/colors.go.tmpl
Normal file
@ -0,0 +1,7 @@
|
||||
package data
|
||||
|
||||
var LanguagesColor = map[string]string{
|
||||
{{range $language, $color := . -}}
|
||||
"{{$language}}": "{{$color -}}",
|
||||
{{end -}}
|
||||
}
|
47
internal/code-generator/generator/colors.go
Normal file
47
internal/code-generator/generator/colors.go
Normal file
@ -0,0 +1,47 @@
|
||||
package generator
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// Colors generates a map in Go with language name -> color string.
|
||||
// It is of generator.File type.
|
||||
func Colors(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error {
|
||||
data, err := ioutil.ReadFile(fileToParse)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
languages := make(map[string]*languageInfo)
|
||||
if err := yaml.Unmarshal(data, &languages); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
langColorMap := buildLanguageColorMap(languages)
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
if err := executeMimeTemplate(buf, langColorMap, tmplPath, tmplName, commit); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return formatedWrite(outPath, buf.Bytes())
|
||||
}
|
||||
|
||||
func buildLanguageColorMap(languages map[string]*languageInfo) map[string]string {
|
||||
langColorMap := make(map[string]string)
|
||||
for lang, info := range languages {
|
||||
if len(info.Color) != 0 {
|
||||
langColorMap[lang] = info.Color
|
||||
}
|
||||
}
|
||||
|
||||
return langColorMap
|
||||
}
|
||||
|
||||
func executeColorTemplate(out io.Writer, langColorMap map[string]string, tmplPath, tmplName, commit string) error {
|
||||
return executeTemplate(out, tmplName, tmplPath, commit, nil, langColorMap)
|
||||
}
|
@ -80,6 +80,11 @@ const (
|
||||
mimeTypeGold = testDir + "/mimeType.gold"
|
||||
mimeTypeTestTmplPath = assetsDir + "/mimeType.go.tmpl"
|
||||
mimeTypeTestTmplName = "mimeType.go.tmpl"
|
||||
|
||||
// colors test
|
||||
colorsGold = testDir + "/colors.gold"
|
||||
colorsTestTmplPath = assetsDir + "/colors.go.tmpl"
|
||||
colorsTestTmplName = "colors.go.tmpl"
|
||||
)
|
||||
|
||||
type GeneratorTestSuite struct {
|
||||
@ -243,6 +248,16 @@ func (s *GeneratorTestSuite) SetupSuite() {
|
||||
generate: MimeType,
|
||||
wantOut: mimeTypeGold,
|
||||
},
|
||||
{
|
||||
name: "Colors()",
|
||||
fileToParse: filepath.Join(s.tmpLinguist, languagesFile),
|
||||
samplesDir: "",
|
||||
tmplPath: colorsTestTmplPath,
|
||||
tmplName: colorsTestTmplName,
|
||||
commit: commit,
|
||||
generate: Colors,
|
||||
wantOut: colorsGold,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import "sort"
|
||||
|
||||
type languageInfo struct {
|
||||
Type string `yaml:"type,omitempty"`
|
||||
Color string `yaml:"color,omitempty"`
|
||||
Aliases []string `yaml:"aliases,omitempty"`
|
||||
Extensions []string `yaml:"extensions,omitempty,flow"`
|
||||
Interpreters []string `yaml:"interpreters,omitempty,flow"`
|
||||
|
244
internal/code-generator/generator/test_files/colors.gold
Normal file
244
internal/code-generator/generator/test_files/colors.gold
Normal file
@ -0,0 +1,244 @@
|
||||
// Code generated by github.com/src-d/enry/v2/internal/code-generator DO NOT EDIT.
|
||||
// Extracted from github/linguist commit: e4560984058b4726010ca4b8f03ed9d0f8f464db
|
||||
|
||||
package data
|
||||
|
||||
var LanguagesColor = map[string]string{
|
||||
"1C Enterprise": "#814CCC",
|
||||
"ABAP": "#E8274B",
|
||||
"AGS Script": "#B9D9FF",
|
||||
"AMPL": "#E6EFBB",
|
||||
"ANTLR": "#9DC3FF",
|
||||
"API Blueprint": "#2ACCA8",
|
||||
"APL": "#5A8164",
|
||||
"ASP": "#6a40fd",
|
||||
"ATS": "#1ac620",
|
||||
"ActionScript": "#882B0F",
|
||||
"Ada": "#02f88c",
|
||||
"Agda": "#315665",
|
||||
"Alloy": "#64C800",
|
||||
"AngelScript": "#C7D7DC",
|
||||
"AppleScript": "#101F1F",
|
||||
"Arc": "#aa2afe",
|
||||
"AspectJ": "#a957b0",
|
||||
"Assembly": "#6E4C13",
|
||||
"Asymptote": "#4a0c0c",
|
||||
"AutoHotkey": "#6594b9",
|
||||
"AutoIt": "#1C3552",
|
||||
"Ballerina": "#FF5000",
|
||||
"Batchfile": "#C1F12E",
|
||||
"BlitzMax": "#cd6400",
|
||||
"Boo": "#d4bec1",
|
||||
"Brainfuck": "#2F2530",
|
||||
"C": "#555555",
|
||||
"C#": "#178600",
|
||||
"C++": "#f34b7d",
|
||||
"CSS": "#563d7c",
|
||||
"Ceylon": "#dfa535",
|
||||
"Chapel": "#8dc63f",
|
||||
"Cirru": "#ccccff",
|
||||
"Clarion": "#db901e",
|
||||
"Clean": "#3F85AF",
|
||||
"Click": "#E4E6F3",
|
||||
"Clojure": "#db5855",
|
||||
"CoffeeScript": "#244776",
|
||||
"ColdFusion": "#ed2cd6",
|
||||
"Common Lisp": "#3fb68b",
|
||||
"Common Workflow Language": "#B5314C",
|
||||
"Component Pascal": "#B0CE4E",
|
||||
"Crystal": "#000100",
|
||||
"Cuda": "#3A4E3A",
|
||||
"D": "#ba595e",
|
||||
"DM": "#447265",
|
||||
"Dart": "#00B4AB",
|
||||
"DataWeave": "#003a52",
|
||||
"Dockerfile": "#384d54",
|
||||
"Dogescript": "#cca760",
|
||||
"Dylan": "#6c616e",
|
||||
"E": "#ccce35",
|
||||
"ECL": "#8a1267",
|
||||
"EQ": "#a78649",
|
||||
"Eiffel": "#946d57",
|
||||
"Elixir": "#6e4a7e",
|
||||
"Elm": "#60B5CC",
|
||||
"Emacs Lisp": "#c065db",
|
||||
"EmberScript": "#FFF4F3",
|
||||
"Erlang": "#B83998",
|
||||
"F#": "#b845fc",
|
||||
"F*": "#572e30",
|
||||
"FLUX": "#88ccff",
|
||||
"Factor": "#636746",
|
||||
"Fancy": "#7b9db4",
|
||||
"Fantom": "#14253c",
|
||||
"Forth": "#341708",
|
||||
"Fortran": "#4d41b1",
|
||||
"FreeMarker": "#0050b2",
|
||||
"Frege": "#00cafe",
|
||||
"GDScript": "#355570",
|
||||
"Game Maker Language": "#71b417",
|
||||
"Genie": "#fb855d",
|
||||
"Gherkin": "#5B2063",
|
||||
"Glyph": "#c1ac7f",
|
||||
"Gnuplot": "#f0a9f0",
|
||||
"Go": "#00ADD8",
|
||||
"Golo": "#88562A",
|
||||
"Gosu": "#82937f",
|
||||
"Grammatical Framework": "#79aa7a",
|
||||
"Groovy": "#e69f56",
|
||||
"HTML": "#e34c26",
|
||||
"Hack": "#878787",
|
||||
"Harbour": "#0e60e3",
|
||||
"Haskell": "#5e5086",
|
||||
"Haxe": "#df7900",
|
||||
"HiveQL": "#dce200",
|
||||
"Hy": "#7790B2",
|
||||
"IDL": "#a3522f",
|
||||
"Idris": "#b30000",
|
||||
"Io": "#a9188d",
|
||||
"Ioke": "#078193",
|
||||
"Isabelle": "#FEFE00",
|
||||
"J": "#9EEDFF",
|
||||
"JSONiq": "#40d47e",
|
||||
"Java": "#b07219",
|
||||
"JavaScript": "#f1e05a",
|
||||
"Jolie": "#843179",
|
||||
"Julia": "#a270ba",
|
||||
"Jupyter Notebook": "#DA5B0B",
|
||||
"KRL": "#28430A",
|
||||
"Kotlin": "#F18E33",
|
||||
"LFE": "#4C3023",
|
||||
"LLVM": "#185619",
|
||||
"LOLCODE": "#cc9900",
|
||||
"LSL": "#3d9970",
|
||||
"Lasso": "#999999",
|
||||
"Lex": "#DBCA00",
|
||||
"LiveScript": "#499886",
|
||||
"LookML": "#652B81",
|
||||
"Lua": "#000080",
|
||||
"MATLAB": "#e16737",
|
||||
"MAXScript": "#00a6a6",
|
||||
"MQL4": "#62A8D6",
|
||||
"MQL5": "#4A76B8",
|
||||
"MTML": "#b7e1f4",
|
||||
"Makefile": "#427819",
|
||||
"Mask": "#f97732",
|
||||
"Max": "#c4a79c",
|
||||
"Mercury": "#ff2b2b",
|
||||
"Meson": "#007800",
|
||||
"Metal": "#8f14e9",
|
||||
"Mirah": "#c7a938",
|
||||
"Modula-3": "#223388",
|
||||
"NCL": "#28431f",
|
||||
"Nearley": "#990000",
|
||||
"Nemerle": "#3d3c6e",
|
||||
"NetLinx": "#0aa0ff",
|
||||
"NetLinx+ERB": "#747faa",
|
||||
"NetLogo": "#ff6375",
|
||||
"NewLisp": "#87AED7",
|
||||
"Nextflow": "#3ac486",
|
||||
"Nim": "#37775b",
|
||||
"Nit": "#009917",
|
||||
"Nix": "#7e7eff",
|
||||
"Nu": "#c9df40",
|
||||
"OCaml": "#3be133",
|
||||
"Objective-C": "#438eff",
|
||||
"Objective-C++": "#6866fb",
|
||||
"Objective-J": "#ff0c5a",
|
||||
"Omgrofl": "#cabbff",
|
||||
"Opal": "#f7ede0",
|
||||
"Oxygene": "#cdd0e3",
|
||||
"Oz": "#fab738",
|
||||
"P4": "#7055b5",
|
||||
"PHP": "#4F5D95",
|
||||
"PLSQL": "#dad8d8",
|
||||
"Pan": "#cc0000",
|
||||
"Papyrus": "#6600cc",
|
||||
"Parrot": "#f3ca0a",
|
||||
"Pascal": "#E3F171",
|
||||
"Pawn": "#dbb284",
|
||||
"Pep8": "#C76F5B",
|
||||
"Perl": "#0298c3",
|
||||
"Perl 6": "#0000fb",
|
||||
"PigLatin": "#fcd7de",
|
||||
"Pike": "#005390",
|
||||
"PogoScript": "#d80074",
|
||||
"PostScript": "#da291c",
|
||||
"PowerBuilder": "#8f0f8d",
|
||||
"PowerShell": "#012456",
|
||||
"Processing": "#0096D8",
|
||||
"Prolog": "#74283c",
|
||||
"Propeller Spin": "#7fa2a7",
|
||||
"Puppet": "#302B6D",
|
||||
"PureBasic": "#5a6986",
|
||||
"PureScript": "#1D222D",
|
||||
"Python": "#3572A5",
|
||||
"QML": "#44a51c",
|
||||
"Quake": "#882233",
|
||||
"R": "#198CE7",
|
||||
"RAML": "#77d9fb",
|
||||
"RUNOFF": "#665a4e",
|
||||
"Racket": "#22228f",
|
||||
"Ragel": "#9d5200",
|
||||
"Rascal": "#fffaa0",
|
||||
"Rebol": "#358a5b",
|
||||
"Red": "#f50000",
|
||||
"Ren'Py": "#ff7f7f",
|
||||
"Ring": "#2D54CB",
|
||||
"Roff": "#ecdebe",
|
||||
"Rouge": "#cc0088",
|
||||
"Ruby": "#701516",
|
||||
"Rust": "#dea584",
|
||||
"SAS": "#B34936",
|
||||
"SQF": "#3F3F3F",
|
||||
"SRecode Template": "#348a34",
|
||||
"SaltStack": "#646464",
|
||||
"Scala": "#c22d40",
|
||||
"Scheme": "#1e4aec",
|
||||
"Self": "#0579aa",
|
||||
"Shell": "#89e051",
|
||||
"Shen": "#120F14",
|
||||
"Slash": "#007eff",
|
||||
"Slice": "#003fa2",
|
||||
"Smalltalk": "#596706",
|
||||
"Solidity": "#AA6746",
|
||||
"SourcePawn": "#5c7611",
|
||||
"Squirrel": "#800000",
|
||||
"Stan": "#b2011d",
|
||||
"Standard ML": "#dc566d",
|
||||
"SuperCollider": "#46390b",
|
||||
"Swift": "#ffac45",
|
||||
"SystemVerilog": "#DAE1C2",
|
||||
"TI Program": "#A0AA87",
|
||||
"Tcl": "#e4cc98",
|
||||
"TeX": "#3D6117",
|
||||
"Terra": "#00004c",
|
||||
"Turing": "#cf142b",
|
||||
"TypeScript": "#2b7489",
|
||||
"UnrealScript": "#a54c4d",
|
||||
"VCL": "#148AA8",
|
||||
"VHDL": "#adb2cb",
|
||||
"Vala": "#fbe5cd",
|
||||
"Verilog": "#b2b7f8",
|
||||
"Vim script": "#199f4b",
|
||||
"Visual Basic": "#945db7",
|
||||
"Volt": "#1F1F1F",
|
||||
"Vue": "#2c3e50",
|
||||
"WebAssembly": "#04133b",
|
||||
"X10": "#4B6BEF",
|
||||
"XC": "#99DA07",
|
||||
"XQuery": "#5232e7",
|
||||
"XSLT": "#EB8CEB",
|
||||
"YARA": "#220000",
|
||||
"YASnippet": "#32AB90",
|
||||
"Yacc": "#4B6C4B",
|
||||
"Zephir": "#118f9e",
|
||||
"Zig": "#ec915c",
|
||||
"eC": "#913960",
|
||||
"nesC": "#94B0C7",
|
||||
"ooc": "#b0b77e",
|
||||
"q": "#0040cd",
|
||||
"sed": "#64b970",
|
||||
"wdl": "#42f1f4",
|
||||
"wisp": "#7582D1",
|
||||
"xBase": "#403a40",
|
||||
}
|
@ -72,6 +72,11 @@ const (
|
||||
mimeTypeTmplPath = "internal/code-generator/assets/mimeType.go.tmpl"
|
||||
mimeTypeTmpl = "mimeType.go.tmpl"
|
||||
|
||||
// colors.go generation
|
||||
colorsFile = "data/colors.go"
|
||||
colorsTmplPath = "internal/code-generator/assets/colors.go.tmpl"
|
||||
colorsTmpl = "colors.go.tmpl"
|
||||
|
||||
commitPath = ".linguist/.git/HEAD"
|
||||
)
|
||||
|
||||
@ -103,6 +108,7 @@ func main() {
|
||||
{generator.Frequencies, "", samplesDir, frequenciesFile, frequenciesTmplPath, frequenciesTmpl, commit},
|
||||
{generator.Commit, "", "", commitFile, commitTmplPath, commitTmpl, commit},
|
||||
{generator.MimeType, languagesYAML, "", mimeTypeFile, mimeTypeTmplPath, mimeTypeTmpl, commit},
|
||||
{generator.Colors, languagesYAML, "", colorsFile, colorsTmplPath, colorsTmpl, commit},
|
||||
}
|
||||
|
||||
for _, file := range fileList {
|
||||
|
@ -217,4 +217,13 @@ public class Enry {
|
||||
return toJavaBool(nativeLib.IsVendor(toGoString(path)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a color code for given language.
|
||||
*
|
||||
* @param language of the file
|
||||
* @return color code
|
||||
*/
|
||||
public static synchronized String getColor(String language) {
|
||||
return toJavaString(nativeLib.GetColor(toGoString(language)));
|
||||
}
|
||||
}
|
||||
|
@ -161,6 +161,14 @@ public class EnryTest {
|
||||
assertFalse(Enry.isImage("nope.go"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getColor() {
|
||||
assertEquals(
|
||||
"#00ADD8",
|
||||
Enry.getColor("Go")
|
||||
);
|
||||
}
|
||||
|
||||
void assertGuess(String language, boolean safe, Guess guess) {
|
||||
assertEquals(language, guess.language);
|
||||
assertEquals(safe, guess.safe);
|
||||
|
@ -126,6 +126,11 @@ func IsVendor(path string) bool {
|
||||
return enry.IsVendor(path)
|
||||
}
|
||||
|
||||
//export GetColor
|
||||
func GetColor(language string) string {
|
||||
return enry.GetColor(language)
|
||||
}
|
||||
|
||||
func strSliceCopy(result *[]*C.char, slice []string) {
|
||||
for _, str := range slice {
|
||||
*result = append(*result, C.CString(str))
|
||||
|
9
utils.go
9
utils.go
@ -73,3 +73,12 @@ func IsBinary(data []byte) bool {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// GetColor returns a HTML color code of a given language.
|
||||
func GetColor(language string) string {
|
||||
if color, ok := data.LanguagesColor[language]; ok {
|
||||
return color
|
||||
}
|
||||
|
||||
return "#cccccc"
|
||||
}
|
||||
|
@ -133,3 +133,19 @@ func TestIsDotFile(t *testing.T) {
|
||||
assert.Equal(t, test.expected, is, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetColor(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
language string
|
||||
expected string
|
||||
}{
|
||||
{name: "TestGetColor_1", language: "Go", expected: "#00ADD8"},
|
||||
{name: "TestGetColor_2", language: "SomeRandom", expected: "#cccccc"},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
color := GetColor(test.language)
|
||||
assert.Equal(t, test.expected, color, fmt.Sprintf("%v: is = %v, expected: %v", test.name, color, test.expected))
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user