diff --git a/go.mod b/go.mod index 0930b0d168..404ca6d5c5 100644 --- a/go.mod +++ b/go.mod @@ -43,6 +43,7 @@ require ( github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 // indirect github.com/gliderlabs/ssh v0.2.2 github.com/glycerine/go-unsnap-stream v0.0.0-20190901134440-81cf024a9e0a // indirect + github.com/go-enry/go-enry/v2 v2.3.0 github.com/go-git/go-billy/v5 v5.0.0 github.com/go-git/go-git/v5 v5.0.0 github.com/go-openapi/jsonreference v0.19.3 // indirect @@ -93,7 +94,6 @@ require ( github.com/sergi/go-diff v1.1.0 github.com/shurcooL/httpfs v0.0.0-20190527155220-6a4d4a70508b // indirect github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd - github.com/src-d/enry/v2 v2.1.0 github.com/steveyen/gtreap v0.0.0-20150807155958-0abe01ef9be2 // indirect github.com/stretchr/testify v1.4.0 github.com/tecbot/gorocksdb v0.0.0-20181010114359-8752a9433481 // indirect diff --git a/go.sum b/go.sum index 5944cbb5e7..d904ed86da 100644 --- a/go.sum +++ b/go.sum @@ -183,6 +183,10 @@ github.com/glycerine/go-unsnap-stream v0.0.0-20190901134440-81cf024a9e0a h1:FQqo github.com/glycerine/go-unsnap-stream v0.0.0-20190901134440-81cf024a9e0a/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31 h1:gclg6gY70GLy3PbkQ1AERPfmLMMagS60DKF78eWwLn8= github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= +github.com/go-enry/go-enry/v2 v2.3.0 h1:o8KwgY6uSplysrIpj+Y42J/xGPp90ogVpxE2Z3s8Unk= +github.com/go-enry/go-enry/v2 v2.3.0/go.mod h1:+xFJwbqWi15bvqFHb2ELUWVRKFQtwB61+sDrkvvxxGI= +github.com/go-enry/go-oniguruma v1.2.0 h1:oBO9XC1IDT9+AoWW5oFsa/7gFeOPacEqDbyXZKWXuDs= +github.com/go-enry/go-oniguruma v1.2.0/go.mod h1:bWDhYP+S6xZQgiRL7wlTScFYBe023B6ilRZbCAD5Hf4= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= github.com/go-git/go-billy/v5 v5.0.0 h1:7NQHvd9FVid8VL4qVUMm8XifBK+2xCoZ2lSk0agRrHM= @@ -560,10 +564,6 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= -github.com/src-d/enry/v2 v2.1.0 h1:z1L8t+B8bh3mmjPkJrgOTnVRpFGmTPJsplHX9wAn6BI= -github.com/src-d/enry/v2 v2.1.0/go.mod h1:qQeCMRwzMF3ckeGr+h0tJLdxXnq+NVZsIDMELj0t028= -github.com/src-d/go-oniguruma v1.1.0 h1:EG+Nm5n2JqWUaCjtM0NtutPxU7ZN5Tp50GWrrV8bTww= -github.com/src-d/go-oniguruma v1.1.0/go.mod h1:chVbff8kcVtmrhxtZ3yBVLLquXbzCS6DrxQaAK/CeqM= github.com/steveyen/gtreap v0.0.0-20150807155958-0abe01ef9be2 h1:JNEGSiWg6D3lcBCMCBqN3ELniXujt+0QNHLhNnO0w3s= github.com/steveyen/gtreap v0.0.0-20150807155958-0abe01ef9be2/go.mod h1:mjqs7N0Q6m5HpR7QfXVBZXZWSqTjQLeTujjA/xUp2uw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -829,6 +829,8 @@ gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/models/repo_language_stats.go b/models/repo_language_stats.go index fd5bcbb8ec..5f1aed1f30 100644 --- a/models/repo_language_stats.go +++ b/models/repo_language_stats.go @@ -10,7 +10,7 @@ import ( "code.gitea.io/gitea/modules/timeutil" - "github.com/src-d/enry/v2" + "github.com/go-enry/go-enry/v2" ) // LanguageStat describes language statistics of a repository diff --git a/modules/analyze/code_langauge.go b/modules/analyze/code_langauge.go index f7dd3e7cfc..3bd2d512f9 100644 --- a/modules/analyze/code_langauge.go +++ b/modules/analyze/code_langauge.go @@ -7,7 +7,7 @@ package analyze import ( "path/filepath" - "github.com/src-d/enry/v2" + "github.com/go-enry/go-enry/v2" ) // GetCodeLanguageWithCallback detects code language based on file name and content using callback diff --git a/modules/git/repo_language_stats.go b/modules/git/repo_language_stats.go index d18ae02d8b..ba58bcc2da 100644 --- a/modules/git/repo_language_stats.go +++ b/modules/git/repo_language_stats.go @@ -12,10 +12,10 @@ import ( "code.gitea.io/gitea/modules/analyze" + "github.com/go-enry/go-enry/v2" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/object" - "github.com/src-d/enry/v2" ) const fileSizeLimit int64 = 16 * 1024 * 1024 diff --git a/modules/indexer/code/bleve.go b/modules/indexer/code/bleve.go index 39171d17a6..576cc3e5e4 100644 --- a/modules/indexer/code/bleve.go +++ b/modules/indexer/code/bleve.go @@ -30,7 +30,7 @@ import ( "github.com/blevesearch/bleve/mapping" "github.com/blevesearch/bleve/search/query" "github.com/ethantkoenig/rupture" - "github.com/src-d/enry/v2" + "github.com/go-enry/go-enry/v2" ) const unicodeNormalizeName = "unicodeNormalize" diff --git a/vendor/github.com/src-d/enry/v2/.gitignore b/vendor/github.com/go-enry/go-enry/v2/.gitignore similarity index 85% rename from vendor/github.com/src-d/enry/v2/.gitignore rename to vendor/github.com/go-enry/go-enry/v2/.gitignore index 78b3fb1614..9ab3afa87d 100644 --- a/vendor/github.com/src-d/enry/v2/.gitignore +++ b/vendor/github.com/go-enry/go-enry/v2/.gitignore @@ -1,4 +1,4 @@ -.linguist +.linguist* benchmarks/output .ci Makefile.main @@ -9,3 +9,4 @@ build/ vendor/ java/lib/ .vscode/ +.venv diff --git a/vendor/github.com/src-d/enry/v2/.travis.yml b/vendor/github.com/go-enry/go-enry/v2/.travis.yml similarity index 96% rename from vendor/github.com/src-d/enry/v2/.travis.yml rename to vendor/github.com/go-enry/go-enry/v2/.travis.yml index 004bc52f99..c7afb06f27 100644 --- a/vendor/github.com/src-d/enry/v2/.travis.yml +++ b/vendor/github.com/go-enry/go-enry/v2/.travis.yml @@ -1,8 +1,9 @@ dist: trusty language: go go: - - '1.12.x' - - '1.11.x' + - '1.14.x' + - '1.13.x' + env: global: - GO_VERSION_FOR_JVM='1.11.x' @@ -12,8 +13,6 @@ env: matrix: - ONIGURUMA=0 - ONIGURUMA=1 -matrix: - fast_finish: true stages: - name: test @@ -22,7 +21,6 @@ stages: - name: publish if: tag IS present -stage: test install: - > if [[ "${ONIGURUMA}" -gt 0 ]]; then @@ -36,7 +34,7 @@ install: sudo dpkg -i "libonig-dev_${ONIGURUMA_VERSION}-1_amd64.deb" fi; script: - - make test-coverage + - go test ./... after_success: - bash <(curl -s https://codecov.io/bash) @@ -98,7 +96,7 @@ jobs: - sudo apt-get install -y --no-install-recommends clang g++ gcc gcc-multilib libc6-dev libc6-dev-i386 mingw-w64 patch xz-utils - cd ${HOME} - curl -sfSL ${OSXCROSS_URL} | tar -C ${HOME} -xzf - - - cd $GOPATH/src/github.com/src-d/enry + - cd $GOPATH/src/github.com/bzz/enry script: make darwin-shared deploy: provider: releases diff --git a/vendor/github.com/src-d/enry/v2/LICENSE b/vendor/github.com/go-enry/go-enry/v2/LICENSE similarity index 99% rename from vendor/github.com/src-d/enry/v2/LICENSE rename to vendor/github.com/go-enry/go-enry/v2/LICENSE index 7f5eae0694..7a4a3ea242 100644 --- a/vendor/github.com/src-d/enry/v2/LICENSE +++ b/vendor/github.com/go-enry/go-enry/v2/LICENSE @@ -1,3 +1,4 @@ + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -178,7 +179,7 @@ APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" + boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a @@ -186,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2017 Sourced Technologies, S.L. + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -198,4 +199,4 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and - limitations under the License. + limitations under the License. \ No newline at end of file diff --git a/vendor/github.com/src-d/enry/v2/Makefile b/vendor/github.com/go-enry/go-enry/v2/Makefile similarity index 73% rename from vendor/github.com/src-d/enry/v2/Makefile rename to vendor/github.com/go-enry/go-enry/v2/Makefile index fb978eb843..07bba14837 100644 --- a/vendor/github.com/src-d/enry/v2/Makefile +++ b/vendor/github.com/go-enry/go-enry/v2/Makefile @@ -1,26 +1,3 @@ -# Package configuration -PROJECT = enry -COMMANDS = cmd/enry - -# Including ci Makefile -CI_REPOSITORY ?= https://github.com/src-d/ci.git -CI_BRANCH ?= v1 -CI_PATH ?= .ci -MAKEFILE := $(CI_PATH)/Makefile.main -$(MAKEFILE): - git clone --quiet --depth 1 -b $(CI_BRANCH) $(CI_REPOSITORY) $(CI_PATH); --include $(MAKEFILE) - -# Docsrv: configure the languages whose api-doc can be auto generated -LANGUAGES = go -# Docs: do not edit this -DOCS_REPOSITORY := https://github.com/src-d/docs -SHARED_PATH ?= $(shell pwd)/.docsrv-resources -DOCS_PATH ?= $(SHARED_PATH)/.docs -$(DOCS_PATH)/Makefile.inc: - git clone --quiet --depth 1 $(DOCS_REPOSITORY) $(DOCS_PATH); --include $(DOCS_PATH)/Makefile.inc - LINGUIST_PATH = .linguist # shared objects @@ -29,6 +6,7 @@ LINUX_DIR=$(RESOURCES_DIR)/linux-x86-64 LINUX_SHARED_LIB=$(LINUX_DIR)/libenry.so DARWIN_DIR=$(RESOURCES_DIR)/darwin DARWIN_SHARED_LIB=$(DARWIN_DIR)/libenry.dylib +STATIC_LIB=$(RESOURCES_DIR)/libenry.a HEADER_FILE=libenry.h NATIVE_LIB=./shared/enry.go @@ -79,4 +57,10 @@ $(LINUX_SHARED_LIB): CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -buildmode=c-shared -o $(LINUX_SHARED_LIB) $(NATIVE_LIB) && \ mv $(LINUX_DIR)/$(HEADER_FILE) $(RESOURCES_DIR)/$(HEADER_FILE) + +static: $(STATIC_LIB) + +$(STATIC_LIB): + CGO_ENABLED=1 go build -buildmode=c-archive -o $(STATIC_LIB) $(NATIVE_LIB) + .PHONY: benchmarks benchmarks-samples benchmarks-slow diff --git a/vendor/github.com/go-enry/go-enry/v2/README.md b/vendor/github.com/go-enry/go-enry/v2/README.md new file mode 100644 index 0000000000..3ad9146112 --- /dev/null +++ b/vendor/github.com/go-enry/go-enry/v2/README.md @@ -0,0 +1,303 @@ +# go-enry [![GoDoc](https://godoc.org/github.com/go-enry/go-enry?status.svg)](https://pkg.go.dev/github.com/go-enry/go-enry/v2) [![Test](https://github.com/go-enry/go-enry/workflows/Test/badge.svg)](https://github.com/go-enry/go-enry/actions?query=workflow%3ATest+branch%3Amaster) [![codecov](https://codecov.io/gh/go-enry/go-enry/branch/master/graph/badge.svg)](https://codecov.io/gh/go-enry/go-enry) + +Programming language detector and toolbox to ignore binary or vendored files. *enry*, started as a port to _Go_ of the original [Linguist](https://github.com/github/linguist) _Ruby_ library, that has an improved *2x performance*. + +* [CLI](#cli) +* [Library](#library) + * [Use cases](#use-cases) + * [By filename](#by-filename) + * [By text](#by-text) + * [By file](#by-file) + * [Filtering](#filtering-vendoring-binaries-etc) + * [Coloring](#language-colors-and-groups) + * [Languages](#languages) + * [Go](#go) + * [Java bindings](#java-bindings) + * [Python bindings](#python-bindings) +* [Divergences from linguist](#divergences-from-linguist) +* [Benchmarks](#benchmarks) +* [Why Enry?](#why-enry) +* [Development](#development) + * [Sync with github/linguist upstream](#sync-with-githublinguist-upstream) +* [Misc](#misc) +* [License](#license) + +# CLI + +The CLI binary is hosted in a separate repository [go-enry/enry](https://github.com/go-enry/enry). + +# Library + +*enry* is also a Go library for guessing a programming language that exposes API through FFI to multiple programming environments. + +## Use cases + +*enry* guesses a programming language using a sequence of matching *strategies* that are +applied progressively to narrow down the possible options. Each *strategy* varies on the type +of input data that it needs to make a decision: file name, extension, the first line of the file, the full content of the file, etc. + +Depending on available input data, enry API can be roughly divided into the next categories or use cases. + +### By filename +Next functions require only a name of the file to make a guess: + - `GetLanguageByExtension` uses only file extension (wich may be ambiguous) + - `GetLanguageByFilename` useful for cases like `.gitignore`, `.bashrc`, etc + - all [filtering helpers](#filtering) + + Please note that such guesses are expected not to be very accurate. + +### By text +To make a guess only based on the content of the file or a text snippet, use + - `GetLanguageByShebang` reads only the first line of text to identify the [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)). + - `GetLanguageByModeline` for cases when Vim/Emacs modeline e.g. `/* vim: set ft=cpp: */` may be present at a head or a tail of the text. + - `GetLanguageByClassifier` uses a Bayesian classifier trained on all the `./samples/` from Linguist. + + It usually is a last-resort strategy that is used to disambiguate the guess of the previous strategies, and thus it requires a list of "candidate" guesses. One can provide a list of all known languages - keys from the `data.LanguagesLogProbabilities` as possible candidates if more intelligent hypotheses are not available, at the price of possibly suboptimal accuracy. + +### By file +The most accurate guess would be one when both, the file name and the content are available: + - `GetLanguagesByContent` only uses file extension and a set of regexp-based content heuristics. + - `GetLanguages` uses the full set of matching strategies and is expected to be most accurate. + +### Filtering: vendoring, binaries, etc +*enry* expose a set of file-level helpers `Is*` to simplify filtering out the files that are less interesting for the purpose of source code analysis: + - `IsBinary` + - `IsVendor` + - `IsConfiguration` + - `IsDocumentation` + - `IsDotFile` + - `IsImage` + +### Language colors and groups +*enry* exposes function to get language color to use for example in presenting statistics in graphs: + - `GetColor` + - `GetLanguageGroup` can be used to group similar languages together e.g. for `Less` this function will return `CSS` + +## Languages + +### Go + +In a [Go module](https://github.com/golang/go/wiki/Modules), +import `enry` to the module by running: + +```sh +go get github.com/go-enry/go-enry/v2 +``` + +The rest of the examples will assume you have either done this or fetched the +library into your `GOPATH`. + +```go +// The examples here and below assume you have imported the library. +import "github.com/go-enry/go-enry/v2" + +lang, safe := enry.GetLanguageByExtension("foo.go") +fmt.Println(lang, safe) +// result: Go true + +lang, safe := enry.GetLanguageByContent("foo.m", []byte("")) +fmt.Println(lang, safe) +// result: Matlab true + +lang, safe := enry.GetLanguageByContent("bar.m", []byte("")) +fmt.Println(lang, safe) +// result: Objective-C true + +// all strategies together +lang := enry.GetLanguage("foo.cpp", []byte("")) +// result: C++ true +``` + +Note that the returned boolean value `safe` is `true` if there is only one possible language detected. + +A plural version of the same API allows getting a list of all possible languages for a given file. + +```go +langs := enry.GetLanguages("foo.h", []byte("")) +// result: []string{"C", "C++", "Objective-C} + +langs := enry.GetLanguagesByExtension("foo.asc", []byte(""), nil) +// result: []string{"AGS Script", "AsciiDoc", "Public Key"} + +langs := enry.GetLanguagesByFilename("Gemfile", []byte(""), []string{}) +// result: []string{"Ruby"} +``` + +### Java bindings + +Generated Java bindings using a C shared library and JNI are available under [`java`](https://github.com/go-enry/go-enry/blob/master/java). + +A library is published on Maven as [tech.sourced:enry-java](https://mvnrepository.com/artifact/tech.sourced/enry-java) for macOS and linux platforms. Windows support is planned under [src-d/enry#150](https://github.com/src-d/enry/issues/150). + +### Python bindings + +Generated Python bindings using a C shared library and cffi are WIP under [src-d/enry#154](https://github.com/src-d/enry/issues/154). + +A library is going to be published on pypi as [enry](https://pypi.org/project/enry/) for +macOS and linux platforms. Windows support is planned under [src-d/enry#150](https://github.com/src-d/enry/issues/150). + +Divergences from Linguist +------------ + +The `enry` library is based on the data from `github/linguist` version **v7.9.0**. + +Parsing [linguist/samples](https://github.com/github/linguist/tree/master/samples) the following `enry` results are different from the Linguist: + +* [Heuristics for ".es" extension](https://github.com/github/linguist/blob/e761f9b013e5b61161481fcb898b59721ee40e3d/lib/linguist/heuristics.yml#L103) in JavaScript could not be parsed, due to unsupported backreference in RE2 regexp engine. + +* [Heuristics for ".rno" extension](https://github.com/github/linguist/blob/3a1bd3c3d3e741a8aaec4704f782e06f5cd2a00d/lib/linguist/heuristics.yml#L365) in RUNOFF could not be parsed, due to unsupported lookahead in RE2 regexp engine. + +* [Heuristics for ".inc" extension](https://github.com/github/linguist/blob/f0e2d0d7f1ce600b2a5acccaef6b149c87d8b99c/lib/linguist/heuristics.yml#L222) in NASL could not be parsed, due to unsupported possessive quantifier in RE2 regexp engine. + +* As of [Linguist v5.3.2](https://github.com/github/linguist/releases/tag/v5.3.2) it is using [flex-based scanner in C for tokenization](https://github.com/github/linguist/pull/3846). Enry still uses [extract_token](https://github.com/github/linguist/pull/3846/files#diff-d5179df0b71620e3fac4535cd1368d15L60) regex-based algorithm. See [#193](https://github.com/src-d/enry/issues/193). + +* Bayesian classifier can't distinguish "SQL" from "PLpgSQL. See [#194](https://github.com/src-d/enry/issues/194). + +* Detection of [generated files](https://github.com/github/linguist/blob/bf95666fc15e49d556f2def4d0a85338423c25f3/lib/linguist/generated.rb#L53) is not supported yet. + (Thus they are not excluded from CLI output). See [#213](https://github.com/src-d/enry/issues/213). + +* XML detection strategy is not implemented. See [#192](https://github.com/src-d/enry/issues/192). + +* Overriding languages and types though `.gitattributes` is not yet supported. See [#18](https://github.com/src-d/enry/issues/18). + +* `enry` CLI output does NOT exclude `.gitignore`ed files and git submodules, as Linguist does + +In all the cases above that have an issue number - we plan to update enry to match Linguist behavior. + + +Benchmarks +------------ + +Enry's language detection has been compared with Linguist's on [*linguist/samples*](https://github.com/github/linguist/tree/master/samples). + +We got these results: + +![histogram](benchmarks/histogram/distribution.png) + +The histogram shows the _number of files_ (y-axis) per _time interval bucket_ (x-axis). +Most of the files were detected faster by enry. + +There are several cases where enry is slower than Linguist due to +Go regexp engine being slower than Ruby's on, wich is based on [oniguruma](https://github.com/kkos/oniguruma) library, written in C. + +See [instructions](#misc) for running enry with oniguruma. + + +Why Enry? +------------ + +In the movie [My Fair Lady](https://en.wikipedia.org/wiki/My_Fair_Lady), [Professor Henry Higgins](http://www.imdb.com/character/ch0011719/) is a linguist who at the very beginning of the movie enjoys guessing the origin of people based on their accent. + +"Enry Iggins" is how [Eliza Doolittle](http://www.imdb.com/character/ch0011720/), [pronounces](https://www.youtube.com/watch?v=pwNKyTktDIE) the name of the Professor. + +## Development + +To run the tests use: + + go test ./... + +Setting `ENRY_TEST_REPO` to the path to existing checkout of Linguist will avoid cloning it and sepeed tests up. +Setting `ENRY_DEBUG=1` will provide insight in the Bayesian classifier building done by `make code-generate`. + + +### Sync with github/linguist upstream + +*enry* re-uses parts of the original [github/linguist](https://github.com/github/linguist) to generate internal data structures. +In order to update to the latest release of linguist do: + +```bash +$ git clone https://github.com/github/linguist.git .linguist +$ cd .linguist; git checkout ; cd .. + +# put the new release's commit sha in the generator_test.go (to re-generate .gold test fixtures) +# https://github.com/go-enry/go-enry/blob/13d3d66d37a87f23a013246a1b0678c9ee3d524b/internal/code-generator/generator/generator_test.go#L18 + +$ make code-generate +``` + +To stay in sync, enry needs to be updated when a new release of the linguist includes changes to any of the following files: + +* [languages.yml](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml) +* [heuristics.yml](https://github.com/github/linguist/blob/master/lib/linguist/heuristics.yml) +* [vendor.yml](https://github.com/github/linguist/blob/master/lib/linguist/vendor.yml) +* [documentation.yml](https://github.com/github/linguist/blob/master/lib/linguist/documentation.yml) + +There is no automation for detecting the changes in the linguist project, so this process above has to be done manually from time to time. + +When submitting a pull request syncing up to a new release, please make sure it only contains the changes in +the generated files (in [data](https://github.com/go-enry/go-enry/blob/master/data) subdirectory). + +Separating all the necessary "manual" code changes to a different PR that includes some background description and an update to the documentation on ["divergences from linguist"](#divergences-from-linguist) is very much appreciated as it simplifies the maintenance (review/release notes/etc). + + + +## Misc + +
+ Running a benchmark & faster regexp engine + +### Benchmark + +All benchmark scripts are in [*benchmarks*](https://github.com/go-enry/go-enry/blob/master/benchmarks) directory. + + +#### Dependencies +As benchmarks depend on Ruby and Github-Linguist gem make sure you have: + - Ruby (e.g using [`rbenv`](https://github.com/rbenv/rbenv)), [`bundler`](https://bundler.io/) installed + - Docker + - [native dependencies](https://github.com/github/linguist/#dependencies) installed + - Build the gem `cd .linguist && bundle install && rake build_gem && cd -` + - Install it `gem install --no-rdoc --no-ri --local .linguist/github-linguist-*.gem` + + +#### Quick benchmark +To run quicker benchmarks + + make benchmarks + +to get average times for the primary detection function and strategies for the whole samples set. If you want to see measures per sample file use: + + make benchmarks-samples + + +#### Full benchmark +If you want to reproduce the same benchmarks as reported above: + - Make sure all [dependencies](#benchmark-dependencies) are installed + - Install [gnuplot](http://gnuplot.info) (in order to plot the histogram) + - Run `ENRY_TEST_REPO="$PWD/.linguist" benchmarks/run.sh` (takes ~15h) + +It will run the benchmarks for enry and Linguist, parse the output, create csv files and plot the histogram. + +### Faster regexp engine (optional) + +[Oniguruma](https://github.com/kkos/oniguruma) is CRuby's regular expression engine. +It is very fast and performs better than the one built into Go runtime. *enry* supports swapping +between those two engines thanks to [rubex](https://github.com/moovweb/rubex) project. +The typical overall speedup from using Oniguruma is 1.5-2x. However, it requires CGo and the external shared library. +On macOS with [Homebrew](https://brew.sh/), it is: + +``` +brew install oniguruma +``` + +On Ubuntu, it is + +``` +sudo apt install libonig-dev +``` + +To build enry with Oniguruma regexps use the `oniguruma` build tag + +``` +go get -v -t --tags oniguruma ./... +``` + +and then rebuild the project. + +
+ + +License +------------ + +Apache License, Version 2.0. See [LICENSE](LICENSE) diff --git a/vendor/github.com/src-d/enry/v2/classifier.go b/vendor/github.com/go-enry/go-enry/v2/classifier.go similarity index 80% rename from vendor/github.com/src-d/enry/v2/classifier.go rename to vendor/github.com/go-enry/go-enry/v2/classifier.go index e70efc38f0..ebc3e3b002 100644 --- a/vendor/github.com/src-d/enry/v2/classifier.go +++ b/vendor/github.com/go-enry/go-enry/v2/classifier.go @@ -4,16 +4,16 @@ import ( "math" "sort" - "github.com/src-d/enry/v2/internal/tokenizer" + "github.com/go-enry/go-enry/v2/internal/tokenizer" ) -// Classifier is the interface in charge to detect the possible languages of the given content based on a set of +// classifier is the interface in charge to detect the possible languages of the given content based on a set of // candidates. Candidates is a map which can be used to assign weights to languages dynamically. -type Classifier interface { - Classify(content []byte, candidates map[string]float64) (languages []string) +type classifier interface { + classify(content []byte, candidates map[string]float64) (languages []string) } -type classifier struct { +type naiveBayes struct { languagesLogProbabilities map[string]float64 tokensLogProbabilities map[string]map[string]float64 tokensTotal float64 @@ -24,8 +24,8 @@ type scoredLanguage struct { score float64 } -// Classify returns a sorted slice of possible languages sorted by decreasing language's probability -func (c *classifier) Classify(content []byte, candidates map[string]float64) []string { +// classify returns a sorted slice of possible languages sorted by decreasing language's probability +func (c *naiveBayes) classify(content []byte, candidates map[string]float64) []string { var languages map[string]float64 if len(candidates) == 0 { @@ -73,7 +73,7 @@ func sortLanguagesByScore(scoredLangs []*scoredLanguage) []string { return sortedLanguages } -func (c *classifier) knownLangs() map[string]float64 { +func (c *naiveBayes) knownLangs() map[string]float64 { langs := make(map[string]float64, len(c.languagesLogProbabilities)) for lang := range c.languagesLogProbabilities { langs[lang]++ @@ -82,7 +82,7 @@ func (c *classifier) knownLangs() map[string]float64 { return langs } -func (c *classifier) tokensLogProbability(tokens []string, language string) float64 { +func (c *naiveBayes) tokensLogProbability(tokens []string, language string) float64 { var sum float64 for _, token := range tokens { sum += c.tokenProbability(token, language) @@ -91,7 +91,7 @@ func (c *classifier) tokensLogProbability(tokens []string, language string) floa return sum } -func (c *classifier) tokenProbability(token, language string) float64 { +func (c *naiveBayes) tokenProbability(token, language string) float64 { tokenProb, ok := c.tokensLogProbabilities[language][token] if !ok { tokenProb = math.Log(1.000000 / c.tokensTotal) diff --git a/vendor/github.com/src-d/enry/v2/common.go b/vendor/github.com/go-enry/go-enry/v2/common.go similarity index 91% rename from vendor/github.com/src-d/enry/v2/common.go rename to vendor/github.com/go-enry/go-enry/v2/common.go index 058d884864..a5a4248547 100644 --- a/vendor/github.com/src-d/enry/v2/common.go +++ b/vendor/github.com/go-enry/go-enry/v2/common.go @@ -6,8 +6,8 @@ import ( "path/filepath" "strings" - "github.com/src-d/enry/v2/data" - "github.com/src-d/enry/v2/regex" + "github.com/go-enry/go-enry/v2/data" + "github.com/go-enry/go-enry/v2/regex" ) // OtherLanguage is used as a zero value when a function can not return a specific language. @@ -26,8 +26,8 @@ var DefaultStrategies = []Strategy{ GetLanguagesByClassifier, } -// DefaultClassifier is a Naive Bayes classifier trained on Linguist samples. -var DefaultClassifier Classifier = &classifier{ +// defaultClassifier is a Naive Bayes classifier trained on Linguist samples. +var defaultClassifier classifier = &naiveBayes{ languagesLogProbabilities: data.LanguagesLogProbabilities, tokensLogProbabilities: data.TokensLogProbabilities, tokensTotal: data.TokensTotal, @@ -92,7 +92,7 @@ func GetLanguageByContent(filename string, content []byte) (language string, saf } // GetLanguageByClassifier returns the most probably language detected for the given content. It uses -// DefaultClassifier, if no candidates are provided it returns OtherLanguage. +// defaultClassifier, if no candidates are provided it returns OtherLanguage. func GetLanguageByClassifier(content []byte, candidates []string) (language string, safe bool) { return getLanguageByStrategy(GetLanguagesByClassifier, "", content, candidates) } @@ -108,10 +108,10 @@ func getFirstLanguageAndSafe(languages []string) (language string, safe bool) { return } -// GetLanguageBySpecificClassifier returns the most probably language for the given content using +// getLanguageBySpecificClassifier returns the most probably language for the given content using // classifier to detect language. -func GetLanguageBySpecificClassifier(content []byte, candidates []string, classifier Classifier) (language string, safe bool) { - languages := GetLanguagesBySpecificClassifier(content, candidates, classifier) +func getLanguageBySpecificClassifier(content []byte, candidates []string, classifier classifier) (language string, safe bool) { + languages := getLanguagesBySpecificClassifier(content, candidates, classifier) return getFirstLanguageAndSafe(languages) } @@ -413,27 +413,28 @@ func GetLanguagesByContent(filename string, content []byte, _ []string) []string return heuristic.Match(content) } -// GetLanguagesByClassifier uses DefaultClassifier as a Classifier and returns a sorted slice of possible languages ordered by -// decreasing language's probability. If there are not candidates it returns nil. It complies with the signature to be a Strategy type. +// GetLanguagesByClassifier returns a sorted slice of possible languages ordered by +// decreasing language's probability. If there are not candidates it returns nil. +// It is a Strategy that uses a pre-trained defaultClassifier. func GetLanguagesByClassifier(filename string, content []byte, candidates []string) (languages []string) { if len(candidates) == 0 { return nil } - return GetLanguagesBySpecificClassifier(content, candidates, DefaultClassifier) + return getLanguagesBySpecificClassifier(content, candidates, defaultClassifier) } -// GetLanguagesBySpecificClassifier returns a slice of possible languages. It takes in a Classifier to be used. -func GetLanguagesBySpecificClassifier(content []byte, candidates []string, classifier Classifier) (languages []string) { +// getLanguagesBySpecificClassifier returns a slice of possible languages. It takes in a Classifier to be used. +func getLanguagesBySpecificClassifier(content []byte, candidates []string, classifier classifier) (languages []string) { mapCandidates := make(map[string]float64) for _, candidate := range candidates { mapCandidates[candidate]++ } - return classifier.Classify(content, mapCandidates) + return classifier.classify(content, mapCandidates) } -// GetLanguageExtensions returns the different extensions being used by the language. +// GetLanguageExtensions returns all extensions associated with the given language. func GetLanguageExtensions(language string) []string { return data.ExtensionsByLanguage[language] } @@ -470,3 +471,12 @@ func GetLanguageByAlias(alias string) (lang string, ok bool) { return } + +// GetLanguageGroup returns language group or empty string if language does not have group. +func GetLanguageGroup(language string) string { + if group, ok := data.LanguagesGroup[language]; ok { + return group + } + + return "" +} diff --git a/vendor/github.com/go-enry/go-enry/v2/data/alias.go b/vendor/github.com/go-enry/go-enry/v2/data/alias.go new file mode 100644 index 0000000000..baa93446aa --- /dev/null +++ b/vendor/github.com/go-enry/go-enry/v2/data/alias.go @@ -0,0 +1,842 @@ +// Code generated by github.com/go-enry/go-enry/v2/internal/code-generator DO NOT EDIT. +// Extracted from github/linguist commit: 40992ba7f86889f80dfed3ba95e11e1082200bad + +package data + +import "strings" + +// LanguageByAliasMap keeps alias for different languages and use the name of the languages as an alias too. +// All the keys (alias or not) are written in lower case and the whitespaces has been replaced by underscores. +var LanguageByAliasMap = map[string]string{ + "1c_enterprise": "1C Enterprise", + "4d": "4D", + "abap": "ABAP", + "abl": "OpenEdge ABL", + "abnf": "ABNF", + "abuild": "Alpine Abuild", + "acfm": "Adobe Font Metrics", + "aconf": "ApacheConf", + "actionscript": "ActionScript", + "actionscript3": "ActionScript", + "actionscript_3": "ActionScript", + "ada": "Ada", + "ada2005": "Ada", + "ada95": "Ada", + "adobe_composite_font_metrics": "Adobe Font Metrics", + "adobe_font_metrics": "Adobe Font Metrics", + "adobe_multiple_font_metrics": "Adobe Font Metrics", + "advpl": "xBase", + "afdko": "OpenType Feature File", + "agda": "Agda", + "ags": "AGS Script", + "ags_script": "AGS Script", + "ahk": "AutoHotkey", + "alloy": "Alloy", + "alpine_abuild": "Alpine Abuild", + "altium": "Altium Designer", + "altium_designer": "Altium Designer", + "amfm": "Adobe Font Metrics", + "ampl": "AMPL", + "amusewiki": "Muse", + "angelscript": "AngelScript", + "ant_build_system": "Ant Build System", + "antlr": "ANTLR", + "apache": "ApacheConf", + "apacheconf": "ApacheConf", + "apex": "Apex", + "api_blueprint": "API Blueprint", + "apkbuild": "Alpine Abuild", + "apl": "APL", + "apollo_guidance_computer": "Apollo Guidance Computer", + "applescript": "AppleScript", + "arc": "Arc", + "arexx": "REXX", + "as3": "ActionScript", + "asciidoc": "AsciiDoc", + "asm": "Assembly", + "asn.1": "ASN.1", + "asp": "ASP", + "aspectj": "AspectJ", + "aspx": "ASP", + "aspx-vb": "ASP", + "assembly": "Assembly", + "asymptote": "Asymptote", + "ats": "ATS", + "ats2": "ATS", + "au3": "AutoIt", + "augeas": "Augeas", + "autoconf": "M4Sugar", + "autohotkey": "AutoHotkey", + "autoit": "AutoIt", + "autoit3": "AutoIt", + "autoitscript": "AutoIt", + "awk": "Awk", + "b3d": "BlitzBasic", + "ballerina": "Ballerina", + "bash": "Shell", + "bash_session": "ShellSession", + "bat": "Batchfile", + "batch": "Batchfile", + "batchfile": "Batchfile", + "bazel": "Starlark", + "befunge": "Befunge", + "bibtex": "BibTeX", + "bison": "Bison", + "bitbake": "BitBake", + "blade": "Blade", + "blitz3d": "BlitzBasic", + "blitzbasic": "BlitzBasic", + "blitzmax": "BlitzMax", + "blitzplus": "BlitzBasic", + "bluespec": "Bluespec", + "bmax": "BlitzMax", + "boo": "Boo", + "bplus": "BlitzBasic", + "brainfuck": "Brainfuck", + "brightscript": "Brightscript", + "bro": "Zeek", + "bsdmake": "Makefile", + "byond": "DM", + "bzl": "Starlark", + "c": "C", + "c#": "C#", + "c++": "C++", + "c++-objdump": "Cpp-ObjDump", + "c-objdump": "C-ObjDump", + "c2hs": "C2hs Haskell", + "c2hs_haskell": "C2hs Haskell", + "cabal": "Cabal Config", + "cabal_config": "Cabal Config", + "cap'n_proto": "Cap'n Proto", + "carto": "CartoCSS", + "cartocss": "CartoCSS", + "ceylon": "Ceylon", + "cfc": "ColdFusion CFC", + "cfm": "ColdFusion", + "cfml": "ColdFusion", + "chapel": "Chapel", + "charity": "Charity", + "chpl": "Chapel", + "chuck": "ChucK", + "cirru": "Cirru", + "clarion": "Clarion", + "clean": "Clean", + "click": "Click", + "clipper": "xBase", + "clips": "CLIPS", + "clojure": "Clojure", + "closure_templates": "Closure Templates", + "cloud_firestore_security_rules": "Cloud Firestore Security Rules", + "cmake": "CMake", + "cobol": "COBOL", + "coccinelle": "SmPL", + "codeql": "CodeQL", + "coffee": "CoffeeScript", + "coffee-script": "CoffeeScript", + "coffeescript": "CoffeeScript", + "coldfusion": "ColdFusion", + "coldfusion_cfc": "ColdFusion CFC", + "coldfusion_html": "ColdFusion", + "collada": "COLLADA", + "common_lisp": "Common Lisp", + "common_workflow_language": "Common Workflow Language", + "component_pascal": "Component Pascal", + "conll": "CoNLL-U", + "conll-u": "CoNLL-U", + "conll-x": "CoNLL-U", + "console": "ShellSession", + "cool": "Cool", + "coq": "Coq", + "cperl": "Perl", + "cpp": "C++", + "cpp-objdump": "Cpp-ObjDump", + "creole": "Creole", + "crystal": "Crystal", + "csharp": "C#", + "cson": "CSON", + "csound": "Csound", + "csound-csd": "Csound Document", + "csound-orc": "Csound", + "csound-sco": "Csound Score", + "csound_document": "Csound Document", + "csound_score": "Csound Score", + "css": "CSS", + "csv": "CSV", + "cucumber": "Gherkin", + "cuda": "Cuda", + "curl_config": "cURL Config", + "curlrc": "cURL Config", + "cweb": "CWeb", + "cwl": "Common Workflow Language", + "cycript": "Cycript", + "cython": "Cython", + "d": "D", + "d-objdump": "D-ObjDump", + "darcs_patch": "Darcs Patch", + "dart": "Dart", + "dataweave": "DataWeave", + "dcl": "DIGITAL Command Language", + "delphi": "Component Pascal", + "desktop": "desktop", + "dhall": "Dhall", + "diff": "Diff", + "digital_command_language": "DIGITAL Command Language", + "dircolors": "dircolors", + "directx_3d_file": "DirectX 3D File", + "django": "HTML+Django", + "dm": "DM", + "dns_zone": "DNS Zone", + "dockerfile": "Dockerfile", + "dogescript": "Dogescript", + "dosbatch": "Batchfile", + "dosini": "INI", + "dpatch": "Darcs Patch", + "dtrace": "DTrace", + "dtrace-script": "DTrace", + "dylan": "Dylan", + "e": "E", + "eagle": "Eagle", + "easybuild": "Easybuild", + "ebnf": "EBNF", + "ec": "eC", + "ecere_projects": "Ecere Projects", + "ecl": "ECL", + "eclipse": "ECLiPSe", + "ecr": "HTML+ECR", + "editor-config": "EditorConfig", + "editorconfig": "EditorConfig", + "edje_data_collection": "Edje Data Collection", + "edn": "edn", + "eeschema_schematic": "KiCad Schematic", + "eex": "HTML+EEX", + "eiffel": "Eiffel", + "ejs": "EJS", + "elisp": "Emacs Lisp", + "elixir": "Elixir", + "elm": "Elm", + "emacs": "Emacs Lisp", + "emacs_lisp": "Emacs Lisp", + "emacs_muse": "Muse", + "emberscript": "EmberScript", + "eml": "EML", + "eq": "EQ", + "erb": "HTML+ERB", + "erlang": "Erlang", + "f#": "F#", + "f*": "F*", + "factor": "Factor", + "fancy": "Fancy", + "fantom": "Fantom", + "faust": "Faust", + "figfont": "FIGlet Font", + "figlet_font": "FIGlet Font", + "filebench_wml": "Filebench WML", + "filterscript": "Filterscript", + "fish": "fish", + "flex": "Lex", + "flux": "FLUX", + "formatted": "Formatted", + "forth": "Forth", + "fortran": "Fortran", + "foxpro": "xBase", + "freemarker": "FreeMarker", + "frege": "Frege", + "fsharp": "F#", + "fstar": "F*", + "ftl": "FreeMarker", + "fundamental": "Text", + "g-code": "G-code", + "game_maker_language": "Game Maker Language", + "gaml": "GAML", + "gams": "GAMS", + "gap": "GAP", + "gcc_machine_description": "GCC Machine Description", + "gdb": "GDB", + "gdscript": "GDScript", + "genie": "Genie", + "genshi": "Genshi", + "gentoo_ebuild": "Gentoo Ebuild", + "gentoo_eclass": "Gentoo Eclass", + "gerber_image": "Gerber Image", + "gettext_catalog": "Gettext Catalog", + "gf": "Grammatical Framework", + "gherkin": "Gherkin", + "git-ignore": "Ignore List", + "git_attributes": "Git Attributes", + "git_config": "Git Config", + "gitattributes": "Git Attributes", + "gitconfig": "Git Config", + "gitignore": "Ignore List", + "gitmodules": "Git Config", + "glsl": "GLSL", + "glyph": "Glyph", + "glyph_bitmap_distribution_format": "Glyph Bitmap Distribution Format", + "gn": "GN", + "gnuplot": "Gnuplot", + "go": "Go", + "golang": "Go", + "golo": "Golo", + "gosu": "Gosu", + "grace": "Grace", + "gradle": "Gradle", + "grammatical_framework": "Grammatical Framework", + "graph_modeling_language": "Graph Modeling Language", + "graphql": "GraphQL", + "graphviz_(dot)": "Graphviz (DOT)", + "groff": "Roff", + "groovy": "Groovy", + "groovy_server_pages": "Groovy Server Pages", + "gsp": "Groovy Server Pages", + "hack": "Hack", + "haml": "Haml", + "handlebars": "Handlebars", + "haproxy": "HAProxy", + "harbour": "Harbour", + "haskell": "Haskell", + "haxe": "Haxe", + "hbs": "Handlebars", + "hcl": "HCL", + "hiveql": "HiveQL", + "hlsl": "HLSL", + "holyc": "HolyC", + "html": "HTML", + "html+django": "HTML+Django", + "html+django/jinja": "HTML+Django", + "html+ecr": "HTML+ECR", + "html+eex": "HTML+EEX", + "html+erb": "HTML+ERB", + "html+jinja": "HTML+Django", + "html+php": "HTML+PHP", + "html+razor": "HTML+Razor", + "html+ruby": "RHTML", + "htmlbars": "Handlebars", + "htmldjango": "HTML+Django", + "http": "HTTP", + "hxml": "HXML", + "hy": "Hy", + "hylang": "Hy", + "hyphy": "HyPhy", + "i7": "Inform 7", + "idl": "IDL", + "idris": "Idris", + "ignore": "Ignore List", + "ignore_list": "Ignore List", + "igor": "IGOR Pro", + "igor_pro": "IGOR Pro", + "igorpro": "IGOR Pro", + "inc": "PHP", + "inform7": "Inform 7", + "inform_7": "Inform 7", + "ini": "INI", + "inno_setup": "Inno Setup", + "inputrc": "Readline Config", + "io": "Io", + "ioke": "Ioke", + "ipython_notebook": "Jupyter Notebook", + "irc": "IRC log", + "irc_log": "IRC log", + "irc_logs": "IRC log", + "isabelle": "Isabelle", + "isabelle_root": "Isabelle ROOT", + "j": "J", + "jasmin": "Jasmin", + "java": "Java", + "java_properties": "Java Properties", + "java_server_page": "Groovy Server Pages", + "java_server_pages": "Java Server Pages", + "javascript": "JavaScript", + "javascript+erb": "JavaScript+ERB", + "jflex": "JFlex", + "jison": "Jison", + "jison_lex": "Jison Lex", + "jolie": "Jolie", + "jruby": "Ruby", + "js": "JavaScript", + "json": "JSON", + "json5": "JSON5", + "json_with_comments": "JSON with Comments", + "jsonc": "JSON with Comments", + "jsoniq": "JSONiq", + "jsonld": "JSONLD", + "jsonnet": "Jsonnet", + "jsp": "Java Server Pages", + "jsx": "JSX", + "julia": "Julia", + "jupyter_notebook": "Jupyter Notebook", + "kicad_layout": "KiCad Layout", + "kicad_legacy_layout": "KiCad Legacy Layout", + "kicad_schematic": "KiCad Schematic", + "kit": "Kit", + "kotlin": "Kotlin", + "krl": "KRL", + "labview": "LabVIEW", + "lasso": "Lasso", + "lassoscript": "Lasso", + "latex": "TeX", + "latte": "Latte", + "lean": "Lean", + "less": "Less", + "lex": "Lex", + "lfe": "LFE", + "lhaskell": "Literate Haskell", + "lhs": "Literate Haskell", + "lilypond": "LilyPond", + "limbo": "Limbo", + "linker_script": "Linker Script", + "linux_kernel_module": "Linux Kernel Module", + "liquid": "Liquid", + "lisp": "Common Lisp", + "litcoffee": "Literate CoffeeScript", + "literate_agda": "Literate Agda", + "literate_coffeescript": "Literate CoffeeScript", + "literate_haskell": "Literate Haskell", + "live-script": "LiveScript", + "livescript": "LiveScript", + "llvm": "LLVM", + "logos": "Logos", + "logtalk": "Logtalk", + "lolcode": "LOLCODE", + "lookml": "LookML", + "loomscript": "LoomScript", + "ls": "LiveScript", + "lsl": "LSL", + "ltspice_symbol": "LTspice Symbol", + "lua": "Lua", + "m": "M", + "m4": "M4", + "m4sugar": "M4Sugar", + "m68k": "Motorola 68K Assembly", + "macruby": "Ruby", + "make": "Makefile", + "makefile": "Makefile", + "mako": "Mako", + "man": "Roff", + "man-page": "Roff", + "man_page": "Roff", + "manpage": "Roff", + "markdown": "Markdown", + "marko": "Marko", + "markojs": "Marko", + "mask": "Mask", + "mathematica": "Mathematica", + "matlab": "MATLAB", + "maven_pom": "Maven POM", + "max": "Max", + "max/msp": "Max", + "maxmsp": "Max", + "maxscript": "MAXScript", + "mcfunction": "mcfunction", + "mdoc": "Roff", + "mediawiki": "MediaWiki", + "mercury": "Mercury", + "meson": "Meson", + "metal": "Metal", + "mf": "Makefile", + "microsoft_developer_studio_project": "Microsoft Developer Studio Project", + "minid": "MiniD", + "mirah": "Mirah", + "mirc_script": "mIRC Script", + "mlir": "MLIR", + "mma": "Mathematica", + "modelica": "Modelica", + "modula-2": "Modula-2", + "modula-3": "Modula-3", + "module_management_system": "Module Management System", + "monkey": "Monkey", + "moocode": "Moocode", + "moonscript": "MoonScript", + "motorola_68k_assembly": "Motorola 68K Assembly", + "mql4": "MQL4", + "mql5": "MQL5", + "mtml": "MTML", + "muf": "MUF", + "mumps": "M", + "mupad": "mupad", + "muse": "Muse", + "myghty": "Myghty", + "nanorc": "nanorc", + "nasl": "NASL", + "nasm": "Assembly", + "ncl": "NCL", + "nearley": "Nearley", + "nemerle": "Nemerle", + "neosnippet": "Vim Snippet", + "nesc": "nesC", + "netlinx": "NetLinx", + "netlinx+erb": "NetLinx+ERB", + "netlogo": "NetLogo", + "newlisp": "NewLisp", + "nextflow": "Nextflow", + "nginx": "Nginx", + "nginx_configuration_file": "Nginx", + "nim": "Nim", + "ninja": "Ninja", + "nit": "Nit", + "nix": "Nix", + "nixos": "Nix", + "njk": "HTML+Django", + "nl": "NL", + "node": "JavaScript", + "npm_config": "NPM Config", + "npmrc": "NPM Config", + "nroff": "Roff", + "nsis": "NSIS", + "nu": "Nu", + "numpy": "NumPy", + "nunjucks": "HTML+Django", + "nush": "Nu", + "nvim": "Vim script", + "obj-c": "Objective-C", + "obj-c++": "Objective-C++", + "obj-j": "Objective-J", + "objc": "Objective-C", + "objc++": "Objective-C++", + "objdump": "ObjDump", + "object_data_instance_notation": "Object Data Instance Notation", + "objective-c": "Objective-C", + "objective-c++": "Objective-C++", + "objective-j": "Objective-J", + "objectivec": "Objective-C", + "objectivec++": "Objective-C++", + "objectivej": "Objective-J", + "objectpascal": "Component Pascal", + "objectscript": "ObjectScript", + "objj": "Objective-J", + "ocaml": "OCaml", + "octave": "MATLAB", + "odin": "Odin", + "odin-lang": "Odin", + "odinlang": "Odin", + "omgrofl": "Omgrofl", + "oncrpc": "RPC", + "ooc": "ooc", + "opa": "Opa", + "opal": "Opal", + "open_policy_agent": "Open Policy Agent", + "opencl": "OpenCL", + "openedge": "OpenEdge ABL", + "openedge_abl": "OpenEdge ABL", + "openqasm": "OpenQASM", + "openrc": "OpenRC runscript", + "openrc_runscript": "OpenRC runscript", + "openscad": "OpenSCAD", + "openstep_property_list": "OpenStep Property List", + "opentype_feature_file": "OpenType Feature File", + "org": "Org", + "osascript": "AppleScript", + "ox": "Ox", + "oxygene": "Oxygene", + "oz": "Oz", + "p4": "P4", + "pan": "Pan", + "pandoc": "Markdown", + "papyrus": "Papyrus", + "parrot": "Parrot", + "parrot_assembly": "Parrot Assembly", + "parrot_internal_representation": "Parrot Internal Representation", + "pascal": "Pascal", + "pasm": "Parrot Assembly", + "pawn": "Pawn", + "pcbnew": "KiCad Layout", + "pep8": "Pep8", + "perl": "Perl", + "perl-6": "Raku", + "perl6": "Raku", + "php": "PHP", + "pic": "Pic", + "pickle": "Pickle", + "picolisp": "PicoLisp", + "piglatin": "PigLatin", + "pike": "Pike", + "pir": "Parrot Internal Representation", + "plantuml": "PlantUML", + "plpgsql": "PLpgSQL", + "plsql": "PLSQL", + "pod": "Pod", + "pod_6": "Pod 6", + "pogoscript": "PogoScript", + "pony": "Pony", + "posh": "PowerShell", + "postcss": "PostCSS", + "postscr": "PostScript", + "postscript": "PostScript", + "pot": "Gettext Catalog", + "pov-ray": "POV-Ray SDL", + "pov-ray_sdl": "POV-Ray SDL", + "povray": "POV-Ray SDL", + "powerbuilder": "PowerBuilder", + "powershell": "PowerShell", + "prisma": "Prisma", + "processing": "Processing", + "progress": "OpenEdge ABL", + "proguard": "Proguard", + "prolog": "Prolog", + "propeller_spin": "Propeller Spin", + "protobuf": "Protocol Buffer", + "protocol_buffer": "Protocol Buffer", + "protocol_buffers": "Protocol Buffer", + "public_key": "Public Key", + "pug": "Pug", + "puppet": "Puppet", + "pure_data": "Pure Data", + "purebasic": "PureBasic", + "purescript": "PureScript", + "pwsh": "PowerShell", + "pycon": "Python console", + "pyrex": "Cython", + "python": "Python", + "python3": "Python", + "python_console": "Python console", + "python_traceback": "Python traceback", + "q": "q", + "ql": "CodeQL", + "qmake": "QMake", + "qml": "QML", + "quake": "Quake", + "r": "R", + "racket": "Racket", + "ragel": "Ragel", + "ragel-rb": "Ragel", + "ragel-ruby": "Ragel", + "rake": "Ruby", + "raku": "Raku", + "raml": "RAML", + "rascal": "Rascal", + "raw": "Raw token data", + "raw_token_data": "Raw token data", + "razor": "HTML+Razor", + "rb": "Ruby", + "rbx": "Ruby", + "rdoc": "RDoc", + "readline": "Readline Config", + "readline_config": "Readline Config", + "realbasic": "REALbasic", + "reason": "Reason", + "rebol": "Rebol", + "red": "Red", + "red/system": "Red", + "redcode": "Redcode", + "regex": "Regular Expression", + "regexp": "Regular Expression", + "regular_expression": "Regular Expression", + "ren'py": "Ren'Py", + "renderscript": "RenderScript", + "renpy": "Ren'Py", + "restructuredtext": "reStructuredText", + "rexx": "REXX", + "rhtml": "RHTML", + "rich_text_format": "Rich Text Format", + "ring": "Ring", + "riot": "Riot", + "rmarkdown": "RMarkdown", + "robotframework": "RobotFramework", + "roff": "Roff", + "roff_manpage": "Roff Manpage", + "rouge": "Rouge", + "rpc": "RPC", + "rpcgen": "RPC", + "rpm_spec": "RPM Spec", + "rs-274x": "Gerber Image", + "rscript": "R", + "rss": "XML", + "rst": "reStructuredText", + "ruby": "Ruby", + "runoff": "RUNOFF", + "rust": "Rust", + "rusthon": "Python", + "sage": "Sage", + "salt": "SaltStack", + "saltstack": "SaltStack", + "saltstate": "SaltStack", + "sas": "SAS", + "sass": "Sass", + "scala": "Scala", + "scaml": "Scaml", + "scheme": "Scheme", + "scilab": "Scilab", + "scss": "SCSS", + "sed": "sed", + "self": "Self", + "sh": "Shell", + "shaderlab": "ShaderLab", + "shell": "Shell", + "shell-script": "Shell", + "shellsession": "ShellSession", + "shen": "Shen", + "slash": "Slash", + "slice": "Slice", + "slim": "Slim", + "smali": "Smali", + "smalltalk": "Smalltalk", + "smarty": "Smarty", + "sml": "Standard ML", + "smpl": "SmPL", + "smt": "SMT", + "snipmate": "Vim Snippet", + "snippet": "YASnippet", + "solidity": "Solidity", + "sourcemod": "SourcePawn", + "sourcepawn": "SourcePawn", + "soy": "Closure Templates", + "sparql": "SPARQL", + "specfile": "RPM Spec", + "spline_font_database": "Spline Font Database", + "splus": "R", + "sqf": "SQF", + "sql": "SQL", + "sqlpl": "SQLPL", + "squeak": "Smalltalk", + "squirrel": "Squirrel", + "srecode_template": "SRecode Template", + "ssh_config": "SSH Config", + "stan": "Stan", + "standard_ml": "Standard ML", + "starlark": "Starlark", + "stata": "Stata", + "ston": "STON", + "stylus": "Stylus", + "subrip_text": "SubRip Text", + "sugarss": "SugarSS", + "supercollider": "SuperCollider", + "svelte": "Svelte", + "svg": "SVG", + "swift": "Swift", + "swig": "SWIG", + "systemverilog": "SystemVerilog", + "tcl": "Tcl", + "tcsh": "Tcsh", + "tea": "Tea", + "terra": "Terra", + "terraform": "HCL", + "tex": "TeX", + "texinfo": "Texinfo", + "text": "Text", + "textile": "Textile", + "thrift": "Thrift", + "ti_program": "TI Program", + "tl": "Type Language", + "tla": "TLA", + "toml": "TOML", + "troff": "Roff", + "ts": "TypeScript", + "tsql": "TSQL", + "tsx": "TSX", + "turing": "Turing", + "turtle": "Turtle", + "twig": "Twig", + "txl": "TXL", + "type_language": "Type Language", + "typescript": "TypeScript", + "udiff": "Diff", + "ultisnip": "Vim Snippet", + "ultisnips": "Vim Snippet", + "unified_parallel_c": "Unified Parallel C", + "unity3d_asset": "Unity3D Asset", + "unix_assembly": "Unix Assembly", + "uno": "Uno", + "unrealscript": "UnrealScript", + "ur": "UrWeb", + "ur/web": "UrWeb", + "urweb": "UrWeb", + "v": "V", + "vala": "Vala", + "vb.net": "Visual Basic .NET", + "vb6": "VBA", + "vb_.net": "Visual Basic .NET", + "vba": "VBA", + "vbnet": "Visual Basic .NET", + "vbscript": "VBScript", + "vcl": "VCL", + "verilog": "Verilog", + "vhdl": "VHDL", + "vim": "Vim script", + "vim_script": "Vim script", + "vim_snippet": "Vim Snippet", + "viml": "Vim script", + "visual_basic": "Visual Basic .NET", + "visual_basic_.net": "Visual Basic .NET", + "visual_basic_6": "VBA", + "visual_basic_for_applications": "VBA", + "vlang": "V", + "volt": "Volt", + "vue": "Vue", + "wasm": "WebAssembly", + "wast": "WebAssembly", + "wavefront_material": "Wavefront Material", + "wavefront_object": "Wavefront Object", + "wdl": "wdl", + "web_ontology_language": "Web Ontology Language", + "webassembly": "WebAssembly", + "webidl": "WebIDL", + "webvtt": "WebVTT", + "wget_config": "Wget Config", + "wgetrc": "Wget Config", + "winbatch": "Batchfile", + "windows_registry_entries": "Windows Registry Entries", + "wisp": "wisp", + "wollok": "Wollok", + "world_of_warcraft_addon_data": "World of Warcraft Addon Data", + "wsdl": "XML", + "x10": "X10", + "x_bitmap": "X BitMap", + "x_font_directory_index": "X Font Directory Index", + "x_pixmap": "X PixMap", + "xbase": "xBase", + "xbm": "X BitMap", + "xc": "XC", + "xcompose": "XCompose", + "xdr": "RPC", + "xhtml": "HTML", + "xml": "XML", + "xml+genshi": "Genshi", + "xml+kid": "Genshi", + "xml_property_list": "XML Property List", + "xojo": "Xojo", + "xpages": "XPages", + "xpm": "X PixMap", + "xproc": "XProc", + "xquery": "XQuery", + "xs": "XS", + "xsd": "XML", + "xsl": "XSLT", + "xslt": "XSLT", + "xten": "X10", + "xtend": "Xtend", + "yacc": "Yacc", + "yaml": "YAML", + "yang": "YANG", + "yara": "YARA", + "yas": "YASnippet", + "yasnippet": "YASnippet", + "yml": "YAML", + "zap": "ZAP", + "zeek": "Zeek", + "zenscript": "ZenScript", + "zephir": "Zephir", + "zig": "Zig", + "zil": "ZIL", + "zimpl": "Zimpl", + "zsh": "Shell", +} + +// LanguageByAlias looks up the language name by it's alias or name. +// It mirrors the logic of github linguist and is needed e.g for heuristcs.yml +// that mixes names and aliases in a language field (see XPM example). +func LanguageByAlias(langOrAlias string) (lang string, ok bool) { + k := convertToAliasKey(langOrAlias) + lang, ok = LanguageByAliasMap[k] + return +} + +// convertToAliasKey converts language name to a key in LanguageByAliasMap. +// Following +// - internal.code-generator.generator.convertToAliasKey() +// - GetLanguageByAlias() +// conventions. +// It is here to avoid dependency on "generate" and "enry" packages. +func convertToAliasKey(langName string) string { + ak := strings.SplitN(langName, `,`, 2)[0] + ak = strings.Replace(ak, ` `, `_`, -1) + ak = strings.ToLower(ak) + return ak +} diff --git a/vendor/github.com/src-d/enry/v2/data/colors.go b/vendor/github.com/go-enry/go-enry/v2/data/colors.go similarity index 92% rename from vendor/github.com/src-d/enry/v2/data/colors.go rename to vendor/github.com/go-enry/go-enry/v2/data/colors.go index 39d2acc2df..3e47ce1b3a 100644 --- a/vendor/github.com/src-d/enry/v2/data/colors.go +++ b/vendor/github.com/go-enry/go-enry/v2/data/colors.go @@ -1,5 +1,5 @@ -// Code generated by github.com/src-d/enry/v2/internal/code-generator DO NOT EDIT. -// Extracted from github/linguist commit: 3a1bd3c3d3e741a8aaec4704f782e06f5cd2a00d +// Code generated by github.com/go-enry/go-enry/v2/internal/code-generator DO NOT EDIT. +// Extracted from github/linguist commit: 40992ba7f86889f80dfed3ba95e11e1082200bad package data @@ -71,11 +71,13 @@ var LanguagesColor = map[string]string{ "Factor": "#636746", "Fancy": "#7b9db4", "Fantom": "#14253c", + "Faust": "#c37240", "Forth": "#341708", "Fortran": "#4d41b1", "FreeMarker": "#0050b2", "Frege": "#00cafe", "G-code": "#D08CF2", + "GAML": "#FFC766", "GDScript": "#355570", "Game Maker Language": "#71b417", "Genie": "#fb855d", @@ -96,6 +98,7 @@ var LanguagesColor = map[string]string{ "HolyC": "#ffefaf", "Hy": "#7790B2", "IDL": "#a3522f", + "IGOR Pro": "#0000cc", "Idris": "#b30000", "Io": "#a9188d", "Ioke": "#078193", @@ -121,6 +124,7 @@ var LanguagesColor = map[string]string{ "Lua": "#000080", "MATLAB": "#e16737", "MAXScript": "#00a6a6", + "MLIR": "#5EC8DB", "MQL4": "#62A8D6", "MQL5": "#4A76B8", "MTML": "#b7e1f4", @@ -149,8 +153,10 @@ var LanguagesColor = map[string]string{ "Objective-C": "#438eff", "Objective-C++": "#6866fb", "Objective-J": "#ff0c5a", + "Odin": "#60AFFE", "Omgrofl": "#cabbff", "Opal": "#f7ede0", + "OpenQASM": "#AA70FF", "Oxygene": "#cdd0e3", "Oz": "#fab738", "P4": "#7055b5", @@ -163,7 +169,6 @@ var LanguagesColor = map[string]string{ "Pawn": "#dbb284", "Pep8": "#C76F5B", "Perl": "#0298c3", - "Perl 6": "#0000fb", "PigLatin": "#fcd7de", "Pike": "#005390", "PogoScript": "#d80074", @@ -184,11 +189,14 @@ var LanguagesColor = map[string]string{ "RUNOFF": "#665a4e", "Racket": "#3c5caa", "Ragel": "#9d5200", + "Raku": "#0000fb", "Rascal": "#fffaa0", + "Reason": "#ff5847", "Rebol": "#358a5b", "Red": "#f50000", "Ren'Py": "#ff7f7f", "Ring": "#2D54CB", + "Riot": "#A71E49", "Roff": "#ecdebe", "Rouge": "#cc0088", "Ruby": "#701516", @@ -204,12 +212,14 @@ var LanguagesColor = map[string]string{ "Shen": "#120F14", "Slash": "#007eff", "Slice": "#003fa2", + "SmPL": "#c94949", "Smalltalk": "#596706", "Solidity": "#AA6746", "SourcePawn": "#5c7611", "Squirrel": "#800000", "Stan": "#b2011d", "Standard ML": "#dc566d", + "Starlark": "#76d275", "SuperCollider": "#46390b", "Swift": "#ffac45", "SystemVerilog": "#DAE1C2", @@ -220,12 +230,15 @@ var LanguagesColor = map[string]string{ "Turing": "#cf142b", "TypeScript": "#2b7489", "UnrealScript": "#a54c4d", + "V": "#5d87bd", + "VBA": "#867db1", + "VBScript": "#15dcdc", "VCL": "#148AA8", "VHDL": "#adb2cb", "Vala": "#fbe5cd", "Verilog": "#b2b7f8", "Vim script": "#199f4b", - "Visual Basic": "#945db7", + "Visual Basic .NET": "#945db7", "Volt": "#1F1F1F", "Vue": "#2c3e50", "WebAssembly": "#04133b", @@ -243,6 +256,7 @@ var LanguagesColor = map[string]string{ "Zephir": "#118f9e", "Zig": "#ec915c", "eC": "#913960", + "mIRC Script": "#926059", "mcfunction": "#E22837", "nesC": "#94B0C7", "ooc": "#b0b77e", diff --git a/vendor/github.com/go-enry/go-enry/v2/data/commit.go b/vendor/github.com/go-enry/go-enry/v2/data/commit.go new file mode 100644 index 0000000000..abe581387c --- /dev/null +++ b/vendor/github.com/go-enry/go-enry/v2/data/commit.go @@ -0,0 +1,7 @@ +// Code generated by github.com/go-enry/go-enry/v2/internal/code-generator DO NOT EDIT. +// Extracted from github/linguist commit: 40992ba7f86889f80dfed3ba95e11e1082200bad + +package data + +// linguist's commit from which files were generated. +var LinguistCommit = "40992ba7f86889f80dfed3ba95e11e1082200bad" diff --git a/vendor/github.com/src-d/enry/v2/data/content.go b/vendor/github.com/go-enry/go-enry/v2/data/content.go similarity index 89% rename from vendor/github.com/src-d/enry/v2/data/content.go rename to vendor/github.com/go-enry/go-enry/v2/data/content.go index dab33dd866..8f62f98f24 100644 --- a/vendor/github.com/src-d/enry/v2/data/content.go +++ b/vendor/github.com/go-enry/go-enry/v2/data/content.go @@ -1,12 +1,12 @@ -// Code generated by github.com/src-d/enry/v2/internal/code-generator DO NOT EDIT. -// Extracted from github/linguist commit: 3a1bd3c3d3e741a8aaec4704f782e06f5cd2a00d +// Code generated by github.com/go-enry/go-enry/v2/internal/code-generator DO NOT EDIT. +// Extracted from github/linguist commit: 40992ba7f86889f80dfed3ba95e11e1082200bad package data import ( "regexp" - "github.com/src-d/enry/v2/data/rule" + "github.com/go-enry/go-enry/v2/data/rule" ) var ContentHeuristics = map[string]*Heuristics{ @@ -591,6 +591,12 @@ var ContentHeuristics = map[string]*Heuristics{ regexp.MustCompile(`(?m)^(\/\/.+|((import|export)\s+)?(function|int|float|char)\s+((room|repeatedly|on|game)_)?([A-Za-z]+[A-Za-z_0-9]+)\s*[;\(])`), ), }, + ".asm": &Heuristics{ + rule.Or( + rule.MatchingLanguages("Motorola 68K Assembly"), + regexp.MustCompile(`(?m)(?im)\bmoveq(?:\.l)?\s+#(?:\$-?[0-9a-f]{1,3}|%[0-1]{1,8}|-?[0-9]{1,3}),\s*d[0-7]\b|(?im)^\s*move(?:\.[bwl])?\s+(?:sr|usp),\s*[^\s]+|(?im)^\s*move\.[bwl]\s+.*\b[ad]\d|(?im)^\s*movem\.[bwl]\b|(?im)^\s*move[mp](?:\.[wl])?\b|(?im)^\s*btst\b|(?im)^\s*dbra\b`), + ), + }, ".asy": &Heuristics{ rule.Or( rule.MatchingLanguages("LTspice Symbol"), @@ -673,6 +679,16 @@ var ContentHeuristics = map[string]*Heuristics{ regexp.MustCompile(`(?m)([\/\\].*:\s+.*\s\\$|: \\$|^[ %]:|^[\w\s\/\\.]+\w+\.\w+\s*:\s+[\w\s\/\\.]+\w+\.\w+)`), ), }, + ".dsp": &Heuristics{ + rule.Or( + rule.MatchingLanguages("Microsoft Developer Studio Project"), + regexp.MustCompile(`(?m)# Microsoft Developer Studio Generated Build File`), + ), + rule.Or( + rule.MatchingLanguages("Faust"), + regexp.MustCompile(`(?m)\bprocess\s*[(=]|\b(library|import)\s*\(\s*"|\bdeclare\s+(name|version|author|copyright|license)\s+"`), + ), + }, ".ecl": &Heuristics{ rule.Or( rule.MatchingLanguages("ECLiPSe"), @@ -772,6 +788,10 @@ var ContentHeuristics = map[string]*Heuristics{ ), }, ".gs": &Heuristics{ + rule.Or( + rule.MatchingLanguages("GLSL"), + regexp.MustCompile(`(?m)^#version\s+[0-9]+\b`), + ), rule.Or( rule.MatchingLanguages("Gosu"), regexp.MustCompile(`(?m)^uses java\.`), @@ -793,6 +813,16 @@ var ContentHeuristics = map[string]*Heuristics{ regexp.MustCompile(`(?m)<\?hh`), ), }, + ".i": &Heuristics{ + rule.Or( + rule.MatchingLanguages("Motorola 68K Assembly"), + regexp.MustCompile(`(?m)(?im)\bmoveq(?:\.l)?\s+#(?:\$-?[0-9a-f]{1,3}|%[0-1]{1,8}|-?[0-9]{1,3}),\s*d[0-7]\b|(?im)^\s*move(?:\.[bwl])?\s+(?:sr|usp),\s*[^\s]+|(?im)^\s*move\.[bwl]\s+.*\b[ad]\d|(?im)^\s*movem\.[bwl]\b|(?im)^\s*move[mp](?:\.[wl])?\b|(?im)^\s*btst\b|(?im)^\s*dbra\b`), + ), + rule.Or( + rule.MatchingLanguages("SWIG"), + regexp.MustCompile(`(?m)^[ \t]*%[a-z_]+\b|^%[{}]$`), + ), + }, ".ice": &Heuristics{ rule.Or( rule.MatchingLanguages("JSON"), @@ -803,6 +833,10 @@ var ContentHeuristics = map[string]*Heuristics{ ), }, ".inc": &Heuristics{ + rule.Or( + rule.MatchingLanguages("Motorola 68K Assembly"), + regexp.MustCompile(`(?m)(?im)\bmoveq(?:\.l)?\s+#(?:\$-?[0-9a-f]{1,3}|%[0-1]{1,8}|-?[0-9]{1,3}),\s*d[0-7]\b|(?im)^\s*move(?:\.[bwl])?\s+(?:sr|usp),\s*[^\s]+|(?im)^\s*move\.[bwl]\s+.*\b[ad]\d|(?im)^\s*movem\.[bwl]\b|(?im)^\s*move[mp](?:\.[wl])?\b|(?im)^\s*btst\b|(?im)^\s*dbra\b`), + ), rule.Or( rule.MatchingLanguages("PHP"), regexp.MustCompile(`(?m)^<\?(?:php)?`), @@ -931,6 +965,12 @@ var ContentHeuristics = map[string]*Heuristics{ rule.MatchingLanguages("Roff"), ), }, + ".mask": &Heuristics{ + rule.Or( + rule.MatchingLanguages("Unity3d Asset"), + regexp.MustCompile(`(?m)tag:unity3d.com`), + ), + }, ".md": &Heuristics{ rule.Or( rule.MatchingLanguages("Markdown"), @@ -1047,6 +1087,25 @@ var ContentHeuristics = map[string]*Heuristics{ rule.MatchingLanguages("NewLisp"), ), }, + ".odin": &Heuristics{ + rule.Or( + rule.MatchingLanguages("Object Data Instance Notation"), + regexp.MustCompile(`(?m)(?:^|<)\s*[A-Za-z0-9_]+\s*=\s*<`), + ), + rule.Or( + rule.MatchingLanguages("Odin"), + regexp.MustCompile(`(?m)package\s+\w+|\b(?:im|ex)port\s*"[\w:./]+"|\w+\s*::\s*(?:proc|struct)\s*\(|^\s*//\s`), + ), + }, + ".p": &Heuristics{ + rule.Or( + rule.MatchingLanguages("Gnuplot"), + regexp.MustCompile(`(?m)^s?plot\b|^set\s+(term|terminal|out|output|[xy]tics|[xy]label|[xy]range|style)\b`), + ), + rule.Always( + rule.MatchingLanguages("OpenEdge ABL"), + ), + }, ".php": &Heuristics{ rule.Or( rule.MatchingLanguages("Hack"), @@ -1067,17 +1126,26 @@ var ContentHeuristics = map[string]*Heuristics{ regexp.MustCompile(`(?m)\buse\s+(?:strict\b|v?5\.)`), ), rule.Or( - rule.MatchingLanguages("Perl 6"), + rule.MatchingLanguages("Raku"), regexp.MustCompile(`(?m)^\s*(?:use\s+v6\b|\bmodule\b|\b(?:my\s+)?class\b)`), ), }, + ".plist": &Heuristics{ + rule.Or( + rule.MatchingLanguages("XML Property List"), + regexp.MustCompile(`(?m)": -6.085258, + "ASSERT": -5.104429, + "C": -2.619523, + "CONTENT": -7.183871, + "C_COLLECTION": -7.183871, + "C_OBJECT": -4.698964, + "C_TEXT": -4.986646, + "Case": -6.085258, + "Choose": -7.183871, + "Count": -6.085258, + "Current": -6.490724, + "Else": -5.237961, + "End": -4.475821, + "False": -5.797576, + "File": -7.183871, + "Folder": -6.085258, + "For": -6.490724, + "Formula": -5.392111, + "Get": -6.085258, + "HTTP": -6.085258, + "If": -4.986646, + "In": -7.183871, + "Is": -6.085258, + "JSON": -7.183871, + "K": -4.881286, + "Length": -7.183871, + "New": -5.104429, + "Null": -5.392111, + "OBJECT": -7.183871, + "OPEN": -7.183871, + "PAGE": -7.183871, + "PREFERENCE": -7.183871, + "SET": -6.085258, + "String": -5.574433, + "Stringify": -7.183871, + "This": -4.986646, + "True": -5.574433, + "URL": -7.183871, + "VISIBLE": -7.183871, + "Value": -6.490724, + "WA": -5.797576, + "WEB": -6.490724, + "Web": -7.183871, + "Year": -7.183871, + "[": -5.104429, + "\\": -4.544813, + "]": -5.104429, + "ascending": -6.085258, + "attributes": -5.797576, + "base": -6.490724, + "c": -5.797576, + "c.orderBy": -7.183871, + "c.push": -7.183871, + "case": -5.797576, + "cases": -7.183871, + "ck": -6.085258, + "class": -5.797576, + "clear_files": -7.183871, + "collection": -5.797576, + "content": -7.183871, + "database": -7.183871, + "date": -6.490724, + "db": -7.183871, + "each": -5.797576, + "enable": -7.183871, + "error": -7.183871, + "fk": -5.797576, + "folder": -6.490724, + "for": -6.490724, + "from": -6.490724, + "generate_project_plugin_stub": -7.183871, + "generate_project_source": -7.183871, + "generate_project_vs": -7.183871, + "generate_project_xcode": -7.183871, + "get": -7.183871, + "if": -4.986646, + "info": -7.183871, + "initiatialisation": -7.183871, + "inspector": -7.183871, + "macOS": -7.183871, + "newIndex": -6.490724, + "newIndex.getText": -7.183871, + "o": -4.986646, + "o.constructor": -7.183871, + "o.fomulas.push": -7.183871, + "o.functions": -7.183871, + "o.functions.orderBy": -7.183871, + "o.functions.push": -7.183871, + "o.name": -6.085258, + "o.properties": -7.183871, + "o.properties.orderBy": -7.183871, + "o.properties.push": -6.490724, + "o.url": -6.490724, + "object": -5.237961, + "of": -5.797576, + "options.webPortID": -7.183871, + "parameters": -6.085258, + "params": -5.574433, + "params.AUTHOR": -7.183871, + "params.COPYRIGHT_YEAR": -7.183871, + "params.CREATE_DATE": -7.183871, + "params.PRODUCT_NAME": -7.183871, + "params.PRODUCT_VERSION": -7.183871, + "path": -5.797576, + "path.platformPath": -7.183871, + "platform": -6.490724, + "response": -5.797576, + "result": -6.490724, + "result#Null": -7.183871, + "result.success": -7.183871, + "rl": -6.490724, + "rl.path": -7.183871, + "root": -7.183871, + "server": -6.490724, + "settings": -6.085258, + "settings.HTTPEnabled": -7.183871, + "settings.HTTPPort": -7.183871, + "settings.HTTPSEnabled": -7.183871, + "settings.HTTPSPort": -7.183871, + "settings.certificateFolder": -7.183871, + "settings.defaultHomepage": -7.183871, + "settings.rootFolder": -6.490724, + "some": -7.183871, + "statusCode": -5.797576, + "string": -6.490724, + "t": -3.888034, + "the": -7.183871, + "true": -7.183871, + "type": -6.490724, + "using": -7.183871, + "we": -7.183871, + "web": -7.183871, + "webArea": -6.085258, + "webObject": -6.490724, + "webObject.isRunning": -7.183871, + "webObject.start": -7.183871, + "webObject.stop": -7.183871, + "webServer": -7.183871, + "widget": -7.183871, + "{": -5.797576, + "}": -5.797576, + "…": -2.159990, + }, "ABAP": map[string]float64{ - "!": -4.637712, - "\"": -7.202661, - "(": -5.816367, - ")": -5.816367, - "*": -3.619142, - "+": -5.005437, - "-": -0.322277, - ".": -5.005437, - "<-()]>": -6.509514, - "": -6.509514, - "": -5.816367, - "": -6.104049, - "=": -4.900076, - ">": -5.123220, - "ABAP_BOOL": -7.202661, - "C": -7.202661, - "CLASS": -6.509514, - "CL_CSV_PARSER": -5.410902, - "CONSTRUCTOR": -7.202661, - "CSV": -7.202661, - "CSVSTRING": -7.202661, - "CX": -7.202661, - "CX_CSV_PARSE_ERROR": -7.202661, - "DEFINITION": -6.509514, - "DELEGATE": -7.202661, - "Get": -7.202661, - "IF_CSV_PARSER_DELEGATE": -7.202661, - "IMPLEMENTATION": -6.509514, - "Instance": -6.509514, - "Method": -6.509514, - "Parse": -7.202661, - "Private": -7.202661, - "Public": -7.202661, - "REF": -7.202661, - "RETURNING": -7.202661, - "SEPARATOR": -7.202661, - "SIGNATURE": -6.509514, - "SKIP_FIRST_LINE": -7.202661, - "STRING": -7.202661, - "STRINGTAB": -6.104049, - "Space": -6.509514, - "TO": -7.202661, - "TYPE": -5.256751, - "This": -7.202661, - "[": -5.593223, - "]": -5.816367, - "_LINES": -7.202661, - "_csvstring": -6.509514, - "_delegate": -7.202661, - "_lines": -7.202661, - "_lines.": -7.202661, - "_parse_line": -6.509514, - "_separator": -7.202661, - "_skip_first_line": -7.202661, - "_textindicator": -7.202661, - "`": -5.816367, - "abap": -7.202661, - "abap_bool": -6.509514, - "abap_true.": -6.509514, - "an": -7.202661, - "append": -6.509514, - "assigning": -7.202661, - "at": -6.509514, - "c": -6.509514, - "char": -6.509514, - "cl_abap_char_utilities": -7.202661, - "cl_csv_parser": -6.509514, - "cl_object": -7.202661, - "class": -6.509514, - "clear": -7.202661, - "concatenate": -5.816367, - "constants": -7.202661, - "constructor": -6.509514, - "constructor.": -7.202661, - "cr_lf": -7.202661, - "create": -7.202661, - "csv": -7.202661, - "csvstring": -7.202661, - "csvstring.": -7.202661, - "csvvalue": -5.410902, - "csvvalue.": -5.593223, - "csvvalues.": -6.509514, - "cx_csv_parse_error": -6.509514, - "data": -6.104049, - "definition": -7.202661, - "delegate": -7.202661, - "delegate.": -7.202661, - "do": -6.104049, - "e": -7.202661, - "else.": -5.816367, - "endclass.": -7.202661, - "endif.": -5.410902, - "endmethod.": -6.509514, - "endwhile.": -6.509514, - "error": -7.202661, - "exception": -7.202661, - "exporting": -7.202661, - "field": -7.202661, - "files": -6.104049, - "final": -7.202661, - "formatting": -7.202661, - "from": -7.202661, - "here": -6.104049, - "if_csv_parser_delegate": -7.202661, - "implementation.": -7.202661, - "importing": -7.202661, - "in": -7.202661, - "include": -6.104049, - "indicates": -7.202661, - "inheriting": -7.202661, - "into": -5.410902, - "is_first_line": -7.202661, - "line": -7.202661, - "lines": -5.816367, - "loop": -7.202661, - "message": -6.509514, - "method": -6.509514, - "methods": -6.509514, - "msg.": -6.509514, - "not": -6.104049, - "of": -6.509514, - "other": -6.104049, - "parse": -6.509514, - "pools": -7.202661, - "pos": -6.509514, - "private": -7.202661, - "protected": -7.202661, - "public": -6.104049, - "raise": -7.202661, - "raising": -7.202661, - "ref": -7.202661, - "returning.": -7.202661, - "section.": -6.104049, - "separator": -7.202661, - "separator.": -7.202661, - "skip_first_line": -7.202661, - "skip_first_line.": -7.202661, - "source": -6.104049, - "split": -7.202661, - "standard": -6.509514, - "string": -7.202661, - "string.": -6.104049, - "super": -7.202661, - "symbols": -7.202661, - "table": -6.104049, - "text_ended": -7.202661, - "the": -6.104049, - "to": -6.104049, - "type": -4.804766, - "value": -6.509514, - "values": -6.509514, - "|": -5.256751, + "!": -4.570738, + "\"": -7.135687, + "(": -5.749393, + ")": -5.749393, + "*": -3.580339, + "+": -5.056246, + "-": -0.345590, + ".": -4.938463, + "<-()]>": -6.442540, + "": -6.442540, + "": -5.749393, + "": -6.037075, + "=": -4.833102, + ">": -5.056246, + "ABAP_BOOL": -7.135687, + "C": -7.135687, + "CLASS": -6.442540, + "CL_CSV_PARSER": -5.343928, + "CONSTRUCTOR": -7.135687, + "CSV": -7.135687, + "CSVSTRING": -7.135687, + "CX": -7.135687, + "CX_CSV_PARSE_ERROR": -7.135687, + "DEFINITION": -6.442540, + "DELEGATE": -7.135687, + "Get": -7.135687, + "IF_CSV_PARSER_DELEGATE": -7.135687, + "IMPLEMENTATION": -6.442540, + "Instance": -6.442540, + "Method": -6.442540, + "Parse": -7.135687, + "Private": -7.135687, + "Public": -7.135687, + "REF": -7.135687, + "RETURNING": -6.442540, + "SEPARATOR": -7.135687, + "SIGNATURE": -6.442540, + "SKIP_FIRST_LINE": -7.135687, + "STRING": -7.135687, + "STRINGTAB": -6.442540, + "Space": -6.442540, + "TO": -7.135687, + "TYPE": -5.343928, + "This": -7.135687, + "[": -5.526249, + "]": -5.749393, + "_LINES": -7.135687, + "_csvstring": -6.442540, + "_delegate": -7.135687, + "_lines": -7.135687, + "_lines.": -7.135687, + "_parse_line": -6.442540, + "_separator": -7.135687, + "_skip_first_line": -7.135687, + "_textindicator": -7.135687, + "`": -5.749393, + "abap": -7.135687, + "abap_bool": -6.442540, + "abap_true.": -6.442540, + "an": -7.135687, + "append": -6.442540, + "assigning": -7.135687, + "at": -6.442540, + "c": -6.442540, + "char": -6.442540, + "cl_abap_char_utilities": -7.135687, + "cl_csv_parser": -6.442540, + "cl_object": -7.135687, + "class": -6.442540, + "clear": -7.135687, + "concatenate": -5.749393, + "constants": -7.135687, + "constructor": -6.442540, + "constructor.": -7.135687, + "cr_lf": -7.135687, + "create": -7.135687, + "csv": -7.135687, + "csvstring": -7.135687, + "csvstring.": -7.135687, + "csvvalue": -5.343928, + "csvvalue.": -5.526249, + "csvvalues.": -6.442540, + "cx_csv_parse_error": -6.442540, + "data": -6.037075, + "definition": -7.135687, + "delegate": -7.135687, + "delegate.": -7.135687, + "do": -6.037075, + "e": -7.135687, + "else.": -5.749393, + "endclass.": -7.135687, + "endif.": -5.343928, + "endmethod.": -6.442540, + "endwhile.": -6.442540, + "error": -7.135687, + "exception": -7.135687, + "exporting": -7.135687, + "field": -7.135687, + "files": -6.037075, + "final": -7.135687, + "formatting": -7.135687, + "from": -7.135687, + "here": -6.037075, + "if_csv_parser_delegate": -7.135687, + "implementation.": -7.135687, + "importing": -7.135687, + "in": -7.135687, + "include": -6.037075, + "indicates": -7.135687, + "inheriting": -7.135687, + "into": -5.343928, + "is_first_line": -7.135687, + "line": -7.135687, + "lines": -5.749393, + "loop": -7.135687, + "message": -6.442540, + "method": -6.442540, + "methods": -6.442540, + "msg.": -6.442540, + "not": -6.037075, + "of": -6.442540, + "other": -6.037075, + "parse": -6.442540, + "pools": -7.135687, + "pos": -6.442540, + "private": -7.135687, + "protected": -7.135687, + "public": -6.037075, + "raise": -7.135687, + "raising": -7.135687, + "ref": -7.135687, + "returning.": -7.135687, + "section.": -6.037075, + "separator": -7.135687, + "separator.": -7.135687, + "skip_first_line": -7.135687, + "skip_first_line.": -7.135687, + "source": -6.037075, + "split": -7.135687, + "standard": -6.442540, + "string": -7.135687, + "string.": -6.037075, + "super": -7.135687, + "symbols": -7.135687, + "table": -6.037075, + "text_ended": -7.135687, + "the": -6.037075, + "to": -6.037075, + "type": -4.737792, + "value": -6.442540, + "values": -6.442540, + "|": -5.189777, }, "ABNF": map[string]float64{ "%": -3.171745, @@ -1376,266 +1582,269 @@ var TokensLogProbabilities = map[string]map[string]float64{ "–": -5.622211, }, "APL": map[string]float64{ - "!": -7.546446, - "#": -7.546446, - "#.": -6.853299, - "#.DISPLAY": -7.546446, - "#.Files.Dir": -7.546446, - "#.UT.appdir": -6.447834, - "#.UT.expect": -7.546446, - "#.UT.run": -7.546446, - "(": -3.521095, - ")": -3.503395, - "+": -5.061540, - ",": -3.080538, - "-": -5.349222, - "/": -4.907389, - "//tryapl.org/": -7.546446, - "/C": -7.546446, - "/Functions": -7.546446, - "/Page": -7.546446, - "/Z": -7.546446, - "/config": -7.546446, - "/input": -7.546446, - "/lines": -7.546446, - "/usr/local/bin/apl": -7.546446, - ":": -3.341754, - ";": -3.341754, - "": -7.546446, - "": -7.546446, - "": -7.546446, - "": -7.546446, - "": -6.853299, - "": -7.546446, - "": -7.546446, - "": -7.546446, - "
":                              -7.546446,
-		"":                           -7.548556,
+		"":                           -6.855409,
+		"":                              -7.548556,
+		"":                             -7.548556,
+		"":                             -7.548556,
+		"
":                              -7.548556,
+		"":                       -5.793014,
-		"":                       -5.793014,
-		"":                         -5.793014,
-		"":                         -5.793014,
-		"":                         -5.793014,
-		"":         -5.793014,
-		"":           -4.694401,
-		"":                       -5.783825,
+		"":                       -5.783825,
+		"":                         -5.783825,
+		"":                         -5.783825,
+		"":                         -5.783825,
+		"":         -5.783825,
+		"":           -4.685213,
+		"":             -8.567126,
-		"":             -6.082219,
-		"":             -8.567126,
-		"":                -5.234921,
-		"":              -6.775366,
-		"":             -7.180831,
-		"":                -5.928068,
-		"":                -6.487684,
-		"":                  -8.567126,
-		"

": -8.567126, - "": -4.318630, - "": -6.775366, - "
": -7.468513, - "
": -6.775366, - "

": -7.671827, + "": -5.800025, + "": -6.978680, + "": -5.474602, + "": -7.671827, + "": -8.364974, + "": -5.880067, + "": -8.364974, + "": -5.032769, + "": -6.573215, + "": -6.978680, + "": -5.725917, + "": -6.285532, + "": -8.364974, + "

": -8.364974, + "": -4.116479, + "": -6.573215, + "
": -7.266362, + "
": -6.573215, + "