Struct tokei::Language [] [src]

pub struct Language {
    pub blanks: usize,
    pub code: usize,
    pub comments: usize,
    pub files: Vec<PathBuf>,
    pub stats: Vec<Stats>,
    pub lines: usize,
    pub line_comment: &'static [&'static str],
    pub multi_line: &'static [(&'static str, &'static str)],
    pub nested: bool,
    pub nested_comments: &'static [(&'static str, &'static str)],
    pub quotes: &'static [(&'static str, &'static str)],
}

Struct representing a single Language.

Fields

Number of blank lines.

Number of lines of code.

Number of comments(both single, and multi-line)

A collection of files to be analysed.

A collection of statistics based on the files provide from files

Number of total lines.

A collection of single line comments in the language. ie. // in Rust.

A collection of tuples representing the start and end of multi line comments. ie. /* comment */ in Rust.

Whether the language supports nested multi line comments or not.

A list of specific nested comments if this is empty all multi_line comments count.

A list of quotes by default it is "".

Methods

impl Language
[src]

[src]

Constructs a new empty Language with the comments provided.

let mut rust = Language::new(&["//"], &[("/*", "*/")]);

[src]

Convience constructor for creating a language that has no commenting syntax.

let empty_array: &'static [&'static str] = &[];
let json = Language::new_blank();
assert_eq!(json.line_comment, empty_array);

[src]

Convience constructor for creating a language that has the same commenting syntax as C like languages.

let rust = Language::new(&["//"], &[("/*", "*/")]);
let c = Language::new_c();

assert_eq!(rust.line_comment, c.line_comment);
assert_eq!(rust.multi_line, c.multi_line);

[src]

Convience constructor for creating a language that has the same commenting syntax as ML like languages.

let ocaml = Language::new_multi(&[("(*", "*)")]);
let coq = Language::new_func();

assert_eq!(ocaml.line_comment, coq.line_comment);
assert_eq!(ocaml.multi_line, coq.multi_line);

[src]

Convience constructor for creating a language that has the same commenting syntax as HTML like languages.

let xml = Language::new_multi(&[("<!--", "-->")]);
let html = Language::new_html();

assert_eq!(xml.line_comment, html.line_comment);
assert_eq!(xml.multi_line, html.multi_line);

[src]

Convience constructor for creating a language that has the same commenting syntax as Bash.

let bash = Language::new_single(&["#"]);
let yaml = Language::new_hash();

assert_eq!(bash.line_comment, yaml.line_comment);
assert_eq!(bash.multi_line, yaml.multi_line);

[src]

Convience constructor for creating a language that has the same commenting syntax as Haskell.

let haskell = Language::new(&["--"], &[("{-", "-}")]).nested();
let idris = Language::new_haskell();

assert_eq!(haskell.line_comment, haskell.line_comment);
assert_eq!(haskell.multi_line, haskell.multi_line);

[src]

Convience constructor for creating a language that only has multi line comments.

let mustache = Language::new_multi(&[("{{!", "}}")]);

[src]

Convience constructor for creating a language that has the same commenting syntax as Prolog.

let prolog = Language::new(&["%"], &[("/*", "*/")]);
let oz = Language::new_pro();

assert_eq!(prolog.line_comment, oz.line_comment);
assert_eq!(prolog.multi_line, oz.multi_line);

[src]

Convience constructor for creating a language that only has single line comments.

let haskell = Language::new_single(&["--"]);

[src]

Checks if the language is empty. Empty meaning it doesn't have any statistics.

let rust = Language::new_c();

assert!(rust.is_empty());

[src]

Checks if the language doesn't contain any comments.

let json = Language::new_blank();

assert!(json.is_blank());

[src]

Specify if the the language supports nested multi line comments.

let mut rust = Language::new(&["//"], &[("/*", "*/")]).nested();
assert!(rust.nested);

[src]

Specify if the the language supports nested multi line comments. And which are nested. If this is specified there is no need to call the nested function.

let mut d = Language::new(&["//"], &[("/*", "*/")])
                        .nested_comments(&[("/+", "+/")]);
assert!(d.nested);
assert_eq!(d.nested_comments, &[("/+", "+/")]);

[src]

Specifies if the language has a quotes to define a string where the commenting syntax would be ignored. By default it is only "" quotes that are ignored.

let mut javascript = Language::new(&["//"], &[("/*", "*/")])
                        .set_quotes(&[("\"", "\""), ("'", "'")]);
assert!(!javascript.quotes.is_empty());

[src]

Sorts each of the Stats structs contained in the language based on what category is provided panic!'s if given the wrong category.

use tokei::{Language, Stats, Sort};
use std::path::PathBuf;

let mut rust = Language::new_c();
let mut foo_stats = Stats::new(PathBuf::from("foo"));
let mut bar_stats = Stats::new(PathBuf::from("bar"));

foo_stats.code += 20;
bar_stats.code += 10;

rust.stats.push(bar_stats.clone());
rust.stats.push(foo_stats.clone());

assert_eq!(rust.stats, vec![bar_stats.clone(), foo_stats.clone()]);

rust.sort_by(Sort::Code);

assert_eq!(rust.stats, vec![foo_stats, bar_stats]);

Trait Implementations

impl Clone for Language
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Language
[src]

[src]

Formats the value using the given formatter.

impl AddAssign for Language
[src]

[src]

Performs the += operation.

impl AddAssign<Stats> for Language
[src]

[src]

Performs the += operation.

impl Default for Language
[src]

[src]

Returns the "default value" for a type. Read more