src-d / enry

A faster file programming language detector
https://blog.sourced.tech/post/enry/
Apache License 2.0
460 stars 51 forks source link

Added TSX language color based on Typescript one #251

Closed Aviortheking closed 4 years ago

Aviortheking commented 4 years ago

I added TSX language to the language list in colors example at https://git.delta-wings.net/dzeio/markblog

kuba-- commented 4 years ago

@bzz - ping

bzz commented 4 years ago

This file, as everything under data/*, is automatically generated from upstream github/linguist/languages.yml#L4990 and thus should not be edited manually as it will be overwritten during the next release process. The change should be applied to the .yml file above instead.

bzz commented 4 years ago

By looking more at the https://github.com/go-gitea/gitea/pull/10287 I realized there is an option for runtime customizations that gitea team might want to consider for assigning custom colors, if changes to the upstream are not desirable.

I'm not sure if this exactly is the use case here, but as soon as it's exposed on the API surface the client could customize the data.LanguagesColor e.g inside the init() function, adding whatever is needed, before calling to enry.

Here is an example:

package main

import (
    "fmt"

    "github.com/src-d/enry/v2"
    "github.com/src-d/enry/v2/data"
)

func main() {
    fmt.Printf("Before, %d: %s\n", len(data.LanguagesColor), enry.GetColor("TSX"))

    data.LanguagesColor["TSX"] = "#2b7489"

    fmt.Printf("After,  %d: %s\n", len(data.LanguagesColor), enry.GetColor("TSX"))
}

Hope this helps!