mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-09-15 18:07:32 +00:00
As discussed in https://github.com/go-enry/go-enry/issues/54, this provides an API for accessing a LanguageInfo struct which is populated with all the data from the Linguist YAML source file. Functions are provided to access the LanguageInfo by name or ID. The other top-level functions like GetLanguageExtensions, GetLanguageGroup, etc. could in principle be implemented using this structure, which would simplify the code generation. But that would be a big change so I didn't do any of that. Perhaps in the next major version something like that would make sense.
50 lines
833 B
Cheetah
50 lines
833 B
Cheetah
package data
|
|
|
|
// Type represent language's type. Either data, programming, markup, prose, or unknown.
|
|
type Type int
|
|
|
|
// Type's values.
|
|
const (
|
|
TypeUnknown Type = iota
|
|
TypeData
|
|
TypeProgramming
|
|
TypeMarkup
|
|
TypeProse
|
|
)
|
|
|
|
func (t Type) String() string {
|
|
switch t {
|
|
case TypeData:
|
|
return "data"
|
|
case TypeProgramming:
|
|
return "programming"
|
|
case TypeMarkup:
|
|
return "markup"
|
|
case TypeProse:
|
|
return "prose"
|
|
default:
|
|
return "unknown"
|
|
}
|
|
}
|
|
|
|
func TypeForString(s string) Type {
|
|
switch s {
|
|
case "data":
|
|
return TypeData
|
|
case "programming":
|
|
return TypeProgramming
|
|
case "markup":
|
|
return TypeMarkup
|
|
case "prose":
|
|
return TypeProse
|
|
default:
|
|
return TypeUnknown
|
|
}
|
|
}
|
|
|
|
var LanguagesType = map[string]int{
|
|
{{range $language, $type := . -}}
|
|
"{{ $language }}": {{ $type -}},
|
|
{{end -}}
|
|
}
|