Enum tokei::LanguageType
source · #[non_exhaustive]
pub enum LanguageType {
Show 258 variants
ABNF,
AWK,
Abap,
ActionScript,
Ada,
Agda,
Alex,
Alloy,
Arduino,
AsciiDoc,
Asn1,
Asp,
AspNet,
Assembly,
AssemblyGAS,
Ats,
AutoHotKey,
Autoconf,
Autoit,
Automake,
Bash,
Batch,
Bean,
Bitbake,
BrightScript,
C,
CHeader,
CMake,
CSharp,
CShell,
Cabal,
Cassius,
Ceylon,
Clojure,
ClojureC,
ClojureScript,
Cobol,
CodeQL,
CoffeeScript,
Cogent,
ColdFusion,
ColdFusionScript,
Coq,
Cpp,
CppHeader,
Crystal,
Css,
Cuda,
Cython,
D,
Daml,
Dart,
DeviceTree,
Dhall,
Dockerfile,
DotNetResource,
DreamMaker,
Dust,
Ebuild,
Edn,
Elisp,
Elixir,
Elm,
Elvish,
EmacsDevEnv,
Emojicode,
Erlang,
FEN,
FSharp,
Factor,
Fennel,
Fish,
FlatBuffers,
ForgeConfig,
Forth,
FortranLegacy,
FortranModern,
FreeMarker,
Fstar,
Futhark,
GDB,
GdScript,
Gherkin,
Gleam,
Glsl,
Gml,
Go,
Gohtml,
Graphql,
Groovy,
Gwion,
Haml,
Hamlet,
Handlebars,
Happy,
Haskell,
Haxe,
Hcl,
Headache,
Hex,
Hlsl,
HolyC,
Html,
Hy,
Idris,
Ini,
IntelHex,
Isabelle,
Jai,
Java,
JavaScript,
Jinja2,
Json,
Jsonnet,
Jsx,
Julia,
Julius,
Jupyter,
K,
KakouneScript,
Kotlin,
Ksh,
KvLanguage,
LLVM,
Lean,
Less,
LinkerScript,
Liquid,
Lisp,
LiveScript,
Logtalk,
LolCode,
Lua,
Lucius,
M4,
Madlang,
Makefile,
Markdown,
Meson,
Metal,
Mint,
Mlatu,
ModuleDef,
MoonScript,
MsBuild,
Mustache,
Nextflow,
Nim,
Nix,
NotQuitePerl,
OCaml,
ObjectiveC,
ObjectiveCpp,
Odin,
OpenPolicyAgent,
OpenType,
Org,
Oz,
PSL,
Pan,
Pascal,
Perl,
Pest,
Php,
Poke,
Polly,
Pony,
PostCss,
PowerShell,
Processing,
Prolog,
Protobuf,
Pug,
Puppet,
PureScript,
Python,
Q,
Qcl,
Qml,
R,
RON,
RPMSpecfile,
Racket,
Rakefile,
Raku,
Razor,
ReScript,
ReStructuredText,
Renpy,
Ruby,
RubyHtml,
Rust,
SRecode,
Sass,
Scala,
Scheme,
Scons,
Sh,
ShaderLab,
Sml,
Solidity,
SpecmanE,
Spice,
Sqf,
Sql,
Stan,
Stratego,
Stylus,
Svelte,
Svg,
Swift,
Swig,
SystemVerilog,
Tcl,
Tera,
Tex,
Text,
Thrift,
Toml,
Tsx,
Ttcn,
Twig,
TypeScript,
UMPL,
Unison,
UnrealDeveloperMarkdown,
UnrealPlugin,
UnrealProject,
UnrealScript,
UnrealShader,
UnrealShaderHeader,
UrWeb,
UrWebProject,
VB6,
VBScript,
Vala,
Velocity,
Verilog,
VerilogArgsFile,
Vhdl,
VimScript,
VisualBasic,
VisualStudioProject,
VisualStudioSolution,
Vue,
WGSL,
WebAssembly,
WenYan,
Wolfram,
XSL,
Xaml,
XcodeConfig,
Xml,
Xtend,
Yaml,
ZenCode,
Zig,
Zsh,
}
Expand description
Represents a individual programming language. Can be used to provide information about the language, such as multi line comments, single line comments, string literal syntax, whether a given language allows nesting comments.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ABNF
AWK
Abap
ActionScript
Ada
Agda
Alex
Alloy
Arduino
AsciiDoc
Asn1
Asp
AspNet
Assembly
AssemblyGAS
Ats
AutoHotKey
Autoconf
Autoit
Automake
Bash
Batch
Bean
Bitbake
BrightScript
C
CHeader
CMake
CSharp
CShell
Cabal
Cassius
Ceylon
Clojure
ClojureC
ClojureScript
Cobol
CodeQL
CoffeeScript
Cogent
ColdFusion
ColdFusionScript
Coq
Cpp
CppHeader
Crystal
Css
Cuda
Cython
D
Daml
Dart
DeviceTree
Dhall
Dockerfile
DotNetResource
DreamMaker
Dust
Ebuild
Edn
Elisp
Elixir
Elm
Elvish
EmacsDevEnv
Emojicode
Erlang
FEN
FSharp
Factor
Fennel
Fish
FlatBuffers
ForgeConfig
Forth
FortranLegacy
FortranModern
FreeMarker
Fstar
Futhark
GDB
GdScript
Gherkin
Gleam
Glsl
Gml
Go
Gohtml
Graphql
Groovy
Gwion
Haml
Hamlet
Handlebars
Happy
Haskell
Haxe
Hcl
Headache
Hex
Hlsl
HolyC
Html
Hy
Idris
Ini
IntelHex
Isabelle
Jai
Java
JavaScript
Jinja2
Json
Jsonnet
Jsx
Julia
Julius
Jupyter
K
KakouneScript
Kotlin
Ksh
KvLanguage
LLVM
Lean
Less
LinkerScript
Liquid
Lisp
LiveScript
Logtalk
LolCode
Lua
Lucius
M4
Madlang
Makefile
Markdown
Meson
Metal
Mint
Mlatu
ModuleDef
MoonScript
MsBuild
Mustache
Nextflow
Nim
Nix
NotQuitePerl
OCaml
ObjectiveC
ObjectiveCpp
Odin
OpenPolicyAgent
OpenType
Org
Oz
PSL
Pan
Pascal
Perl
Pest
Php
Poke
Polly
Pony
PostCss
PowerShell
Processing
Prolog
Protobuf
Pug
Puppet
PureScript
Python
Q
Qcl
Qml
R
RON
RPMSpecfile
Racket
Rakefile
Raku
Razor
ReScript
ReStructuredText
Renpy
Ruby
RubyHtml
Rust
SRecode
Sass
Scala
Scheme
Scons
Sh
ShaderLab
Sml
Solidity
SpecmanE
Spice
Sqf
Sql
Stan
Stratego
Stylus
Svelte
Svg
Swift
Swig
SystemVerilog
Tcl
Tera
Tex
Text
Thrift
Toml
Tsx
Ttcn
Twig
TypeScript
UMPL
Unison
UnrealDeveloperMarkdown
UnrealPlugin
UnrealProject
UnrealScript
UnrealShader
UnrealShaderHeader
UrWeb
UrWebProject
VB6
VBScript
Vala
Velocity
Verilog
VerilogArgsFile
Vhdl
VimScript
VisualBasic
VisualStudioProject
VisualStudioSolution
Vue
WGSL
WebAssembly
WenYan
Wolfram
XSL
Xaml
XcodeConfig
Xml
Xtend
Yaml
ZenCode
Zig
Zsh
Implementations§
source§impl LanguageType
impl LanguageType
sourcepub fn name(self) -> &'static str
pub fn name(self) -> &'static str
Returns the display name of a language.
let bash = LanguageType::Bash;
assert_eq!(bash.name(), "BASH");
sourcepub fn is_literate(self) -> bool
pub fn is_literate(self) -> bool
Returns whether the language is “literate”, meaning that it considered to primarily be documentation and is counted primarily as comments rather than procedural code.
sourcepub fn line_comments(self) -> &'static [&'static str]
pub fn line_comments(self) -> &'static [&'static str]
Returns the single line comments of a language.
use tokei::LanguageType;
let lang = LanguageType::Rust;
assert_eq!(lang.line_comments(), &["//"]);
sourcepub fn multi_line_comments(self) -> &'static [(&'static str, &'static str)]
pub fn multi_line_comments(self) -> &'static [(&'static str, &'static str)]
Returns the single line comments of a language.
use tokei::LanguageType;
let lang = LanguageType::Rust;
assert_eq!(lang.multi_line_comments(), &[("/*", "*/")]);
sourcepub fn allows_nested(self) -> bool
pub fn allows_nested(self) -> bool
Returns whether the language allows nested multi line comments.
use tokei::LanguageType;
let lang = LanguageType::Rust;
assert!(lang.allows_nested());
sourcepub fn nested_comments(self) -> &'static [(&'static str, &'static str)]
pub fn nested_comments(self) -> &'static [(&'static str, &'static str)]
Returns what nested comments the language has. (Currently only D has any of this type.)
use tokei::LanguageType;
let lang = LanguageType::D;
assert_eq!(lang.nested_comments(), &[("/+", "+/")]);
sourcepub fn quotes(self) -> &'static [(&'static str, &'static str)]
pub fn quotes(self) -> &'static [(&'static str, &'static str)]
Returns the quotes of a language.
use tokei::LanguageType;
let lang = LanguageType::C;
assert_eq!(lang.quotes(), &[("\"", "\"")]);
sourcepub fn verbatim_quotes(self) -> &'static [(&'static str, &'static str)]
pub fn verbatim_quotes(self) -> &'static [(&'static str, &'static str)]
Returns the verbatim quotes of a language.
use tokei::LanguageType;
let lang = LanguageType::CSharp;
assert_eq!(lang.verbatim_quotes(), &[("@\"", "\"")]);
sourcepub fn doc_quotes(self) -> &'static [(&'static str, &'static str)]
pub fn doc_quotes(self) -> &'static [(&'static str, &'static str)]
Returns the doc quotes of a language.
use tokei::LanguageType;
let lang = LanguageType::Python;
assert_eq!(lang.doc_quotes(), &[("\"\"\"", "\"\"\""), ("'''", "'''")]);
sourcepub fn shebangs(self) -> &'static [&'static str]
pub fn shebangs(self) -> &'static [&'static str]
Returns the shebang of a language.
use tokei::LanguageType;
let lang = LanguageType::Bash;
assert_eq!(lang.shebangs(), &["#!/bin/bash"]);
sourcepub fn important_syntax(self) -> &'static [&'static str]
pub fn important_syntax(self) -> &'static [&'static str]
Returns the parts of syntax that determines whether tokei can skip large parts of analysis.
sourcepub fn from_path<P: AsRef<Path>>(entry: P, _config: &Config) -> Option<Self>
pub fn from_path<P: AsRef<Path>>(entry: P, _config: &Config) -> Option<Self>
Get language from a file path. May open and read the file.
use tokei::{Config, LanguageType};
let rust = LanguageType::from_path("./main.rs", &Config::default());
assert_eq!(rust, Some(LanguageType::Rust));
sourcepub fn from_file_extension(extension: &str) -> Option<Self>
pub fn from_file_extension(extension: &str) -> Option<Self>
Get language from a file extension.
use tokei::LanguageType;
let rust = LanguageType::from_file_extension("rs");
assert_eq!(rust, Some(LanguageType::Rust));
sourcepub fn from_mime(mime: &str) -> Option<Self>
pub fn from_mime(mime: &str) -> Option<Self>
Get language from its MIME type if available.
use tokei::LanguageType;
let lang = LanguageType::from_mime("application/javascript");
assert_eq!(lang, Some(LanguageType::JavaScript));
sourcepub fn from_shebang<P: AsRef<Path>>(entry: P) -> Option<Self>
pub fn from_shebang<P: AsRef<Path>>(entry: P) -> Option<Self>
Get language from a shebang. May open and read the file.
use tokei::LanguageType;
let rust = LanguageType::from_shebang("./main.rs");
assert_eq!(rust, Some(LanguageType::Rust));
source§impl LanguageType
impl LanguageType
sourcepub fn parse(
self,
path: PathBuf,
config: &Config
) -> Result<Report, (Error, PathBuf)>
pub fn parse( self, path: PathBuf, config: &Config ) -> Result<Report, (Error, PathBuf)>
Parses a given Path
using the LanguageType
. Returning Report
on success and giving back ownership of PathBuf
on error.
sourcepub fn parse_from_str<A: AsRef<str>>(
self,
text: A,
config: &Config
) -> CodeStats
pub fn parse_from_str<A: AsRef<str>>( self, text: A, config: &Config ) -> CodeStats
Parses the text provided as the given LanguageType
.
sourcepub fn parse_from_slice<A: AsRef<[u8]>>(
self,
text: A,
config: &Config
) -> CodeStats
pub fn parse_from_slice<A: AsRef<[u8]>>( self, text: A, config: &Config ) -> CodeStats
Parses the bytes provided as the given LanguageType
.
Trait Implementations§
source§impl<'arbitrary> Arbitrary<'arbitrary> for LanguageType
impl<'arbitrary> Arbitrary<'arbitrary> for LanguageType
source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Self
from the given unstructured data. Read moresource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Self
from the entirety of the given
unstructured data. Read moresource§impl Clone for LanguageType
impl Clone for LanguageType
source§fn clone(&self) -> LanguageType
fn clone(&self) -> LanguageType
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for LanguageType
impl Debug for LanguageType
source§impl<'de> Deserialize<'de> for LanguageType
impl<'de> Deserialize<'de> for LanguageType
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl Display for LanguageType
impl Display for LanguageType
source§impl<'a> From<&'a LanguageType> for Cow<'a, LanguageType>
impl<'a> From<&'a LanguageType> for Cow<'a, LanguageType>
source§fn from(from: &'a LanguageType) -> Self
fn from(from: &'a LanguageType) -> Self
source§impl<'a> From<LanguageType> for Cow<'a, LanguageType>
impl<'a> From<LanguageType> for Cow<'a, LanguageType>
source§fn from(from: LanguageType) -> Self
fn from(from: LanguageType) -> Self
source§impl FromStr for LanguageType
impl FromStr for LanguageType
source§impl Hash for LanguageType
impl Hash for LanguageType
source§impl Ord for LanguageType
impl Ord for LanguageType
source§fn cmp(&self, other: &LanguageType) -> Ordering
fn cmp(&self, other: &LanguageType) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl PartialEq<LanguageType> for LanguageType
impl PartialEq<LanguageType> for LanguageType
source§fn eq(&self, other: &LanguageType) -> bool
fn eq(&self, other: &LanguageType) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<LanguageType> for LanguageType
impl PartialOrd<LanguageType> for LanguageType
source§fn partial_cmp(&self, other: &LanguageType) -> Option<Ordering>
fn partial_cmp(&self, other: &LanguageType) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more