gitlab.com/thomasboni/go-enry/v2@v2.8.3-0.20220418031202-30b0d7a3de98/internal/code-generator/assets/languageInfo.go.tmpl (about)

     1  package data
     2  
     3  // LanguageInfo exposes the data for a language's Linguist YAML entry as a Go struct.
     4  // See https://github.com/github/linguist/blob/master/lib/linguist/languages.yml
     5  type LanguageInfo struct {
     6    // Name is the language name. May contain symbols not safe for use in some filesystems (e.g., `F*`).
     7    Name string
     8    // FSName is the filesystem safe name. Will only be set if Name is not safe for use in all filesystems.
     9    FSName string
    10    // Type is the language Type. See data.Type for values.
    11    Type Type
    12    // Color is the CSS hex color to represent the language. Only used if type is "programming" or "markup".
    13    Color string
    14    // Group is the name of the parent language. Languages in a group are counted in the statistics as the parent language.
    15    Group string
    16    // Aliases is a slice of additional aliases (implicitly includes name.downcase)
    17    Aliases []string
    18    // Extensions is a slice of associated extensions (the first one is considered the primary extension).
    19    Extensions []string
    20    // A slice of associated interpreters
    21    Interpreters []string
    22    // Filenames is a slice of filenames commonly associated with the language.
    23    Filenames []string
    24    // MimeType (maps to codemirror_mime_type in linguist.yaml) is the string name of the file mime type used for highlighting whenever a file is edited.
    25    MimeType string
    26    // TMScope is the TextMate scope that represents this programming language.
    27    TMScope string
    28    // AceMode is the name of the Ace Mode used for highlighting whenever a file is edited.
    29    AceMode string
    30    // CodeMirrorMode is the name of the CodeMirror Mode used for highlighting whenever a file is edited.
    31    CodeMirrorMode string
    32    // Wrap is a boolean flag to enable line wrapping in an editor.
    33    Wrap bool
    34    // LanguageID is the Linguist-assigned numeric ID for the language.
    35    LanguageID int
    36  }
    37  
    38  // LanguageInfoByID allows accessing LanguageInfo by a language's ID.
    39  var LanguageInfoByID = map[int]LanguageInfo{
    40    {{range $language, $info := . -}}
    41    {{$info.LanguageID}}: LanguageInfo{
    42      Name: "{{$language}}",
    43      FSName: "{{$info.FSName}}",
    44      Type: TypeForString("{{$info.Type}}"),
    45      Color: "{{$info.Color}}",
    46      Group: "{{$info.Group}}",
    47      Aliases: []string{
    48        {{range $alias := $info.Aliases -}}
    49        "{{$alias}}",
    50        {{end -}}
    51      },
    52      Extensions: []string{
    53        {{range $extension := $info.Extensions -}}
    54        "{{$extension}}",
    55        {{end -}}
    56      },
    57      Interpreters: []string{
    58        {{range $interpreter := $info.Interpreters -}}
    59        "{{$interpreter}}",
    60        {{end -}}
    61      },
    62      Filenames: []string{
    63        {{range $filename := $info.Filenames -}}
    64        "{{$filename}}",
    65        {{end -}}
    66      },
    67      MimeType: "{{$info.MimeType}}",
    68      TMScope: "{{$info.TMScope}}",
    69      AceMode: "{{$info.AceMode}}",
    70      CodeMirrorMode: "{{$info.CodeMirrorMode}}",
    71      Wrap: {{$info.Wrap}},
    72      LanguageID: {{$info.LanguageID}},
    73    },
    74    {{end -}}
    75  }