mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-19 06:33:06 -03:00
Expose LanguageInfo with all Linguist data
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.
This commit is contained in:
@ -87,9 +87,14 @@ var (
|
||||
|
||||
// id.go generation
|
||||
idFile = "data/id.go"
|
||||
idTmplPath = "internal/code-generator/assets/id.go.tmpl"
|
||||
idTmplPath = filepath.Join(assetsDir, "id.go.tmpl")
|
||||
idTmpl = "id.go.tmpl"
|
||||
|
||||
// languageInfo.go generation
|
||||
languageInfoFile = filepath.Join("data", "languageInfo.go")
|
||||
langaugeInfoTmplPath = filepath.Join(assetsDir, "languageInfo.go.tmpl")
|
||||
langaugeInfoTmpl = "languageInfo.go.tmpl"
|
||||
|
||||
commitPath = filepath.Join(".linguist", ".git", "HEAD")
|
||||
)
|
||||
|
||||
@ -124,11 +129,12 @@ func main() {
|
||||
{generator.Colors, languagesYAML, "", colorsFile, colorsTmplPath, colorsTmpl, commit},
|
||||
{generator.Groups, languagesYAML, "", groupsFile, groupsTmplPath, groupsTmpl, commit},
|
||||
{generator.ID, languagesYAML, "", idFile, idTmplPath, idTmpl, commit},
|
||||
{generator.LanguageInfo, languagesYAML, "", languageInfoFile, langaugeInfoTmplPath, langaugeInfoTmpl, commit},
|
||||
}
|
||||
|
||||
for _, file := range fileList {
|
||||
if err := file.generate(file.fileToParse, file.samplesDir, file.outPath, file.tmplPath, file.tmplName, file.commit); err != nil {
|
||||
log.Println(err)
|
||||
log.Printf("Error generating template %q to %q: %+v", file.tmplPath, file.outPath, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user