mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-11-10 13:32:24 +00:00
Merge pull request #70 from mcarmonaa/fix/document-safe
documented safe value and plural functions in the README
This commit is contained in:
commit
c6e4c7f41c
21
README.md
21
README.md
@ -22,15 +22,15 @@ Examples
|
|||||||
--------
|
--------
|
||||||
|
|
||||||
```go
|
```go
|
||||||
lang, _ := GetLanguageByExtension("foo.go")
|
lang, safe := enry.GetLanguageByExtension("foo.go")
|
||||||
fmt.Println(lang)
|
fmt.Println(lang)
|
||||||
// result: Go
|
// result: Go
|
||||||
|
|
||||||
lang, _ = GetLanguageByContent("foo.m", "<matlab-code>")
|
lang, safe := enry.GetLanguageByContent("foo.m", "<matlab-code>")
|
||||||
fmt.Println(lang)
|
fmt.Println(lang)
|
||||||
// result: Matlab
|
// result: Matlab
|
||||||
|
|
||||||
lang, _ = GetLanguageByContent("bar.m", "<objective-c-code>")
|
lang, safe := enry.GetLanguageByContent("bar.m", "<objective-c-code>")
|
||||||
fmt.Println(lang)
|
fmt.Println(lang)
|
||||||
// result: Objective-C
|
// result: Objective-C
|
||||||
|
|
||||||
@ -38,6 +38,21 @@ fmt.Println(lang)
|
|||||||
lang := enry.GetLanguage("foo.cpp", "<cpp-code>")
|
lang := enry.GetLanguage("foo.cpp", "<cpp-code>")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note the returned boolean value "safe" is set either to true, if there is only one possible language detected or, to false otherwise.
|
||||||
|
|
||||||
|
To get a list of possible languages for a given file, you can use the plural version of the detecting functions.
|
||||||
|
|
||||||
|
```go
|
||||||
|
langs := enry.GetLanguages("foo.h", "<cpp-code>")
|
||||||
|
// result: []string{"C++", "C"}
|
||||||
|
|
||||||
|
langs := enry.GetLanguagesByExtension("foo.asc", "<content>", nil)
|
||||||
|
// result: []string{"AGS Script", "AsciiDoc", "Public Key"}
|
||||||
|
|
||||||
|
langs := enry.GetLanguagesByFilename("Gemfile", "<content>", []string{})
|
||||||
|
// result: []string{"Ruby"}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
CLI
|
CLI
|
||||||
-----------------
|
-----------------
|
||||||
|
Loading…
Reference in New Issue
Block a user