tartrazine/internal/code-generator/assets/content.go.tmpl

40 lines
1.1 KiB
Cheetah
Raw Normal View History

package data
2017-04-05 14:01:31 +00:00
2017-06-08 07:27:27 +00:00
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
2017-04-05 14:01:31 +00:00
// THIS FILE SHOULD NOT BE EDITED BY HAND
// Extracted from github/linguist commit: {{ getCommit }}
import (
"regexp"
)
2017-05-31 10:07:46 +00:00
type languageMatcher func ([]byte) []string
2017-04-05 14:01:31 +00:00
var ContentMatchers = map[string]languageMatcher{
2017-04-05 14:01:31 +00:00
{{ range $index, $disambiguator := . -}}
2017-05-31 10:07:46 +00:00
{{ printf "%q" $disambiguator.Extension }}: func(i []byte) []string {
2017-04-05 14:01:31 +00:00
{{ range $i, $language := $disambiguator.Languages -}}
{{- if not (avoidLanguage $language) }}
{{- if gt (len $language.Heuristics) 0 }}
{{- if gt $i 0 }} else {{ end -}}
if {{- range $j, $heuristic := $language.Heuristics }} {{ $heuristic.Name }}.Match(i)
2017-04-05 14:01:31 +00:00
{{- if lt $j (len $language.LogicRelations) }} {{index $language.LogicRelations $j}} {{- end -}} {{ end }} {
2017-05-31 10:07:46 +00:00
return []string{ {{- printf "%q" $language.Language -}} }
2017-04-05 14:01:31 +00:00
}
2017-04-05 14:01:31 +00:00
{{- end -}}
{{- end -}}
{{- end}}
2017-05-31 10:07:46 +00:00
return {{ returnLanguages $disambiguator.Languages | returnStringSlice }}
2017-04-05 14:01:31 +00:00
},
{{ end -}}
}
var (
{{ range $index, $heuristic := getAllHeuristics . -}}
{{ $heuristic.Name }} = regexp.MustCompile(`{{ $heuristic.Regexp }}`)
{{ end -}}
)