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: Vec<&'static str>,
    pub multi_line: Vec<(&'static str, &'static str)>,
    pub nested: bool,
}

Fields

blanks: usize

Number of blank lines.

code: usize

Number of lines of code.

comments: usize

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

files: Vec<PathBuf>

A collection of files to be analysed.

stats: Vec<Stats>

A collection of statistics based on the files provide from files

lines: usize

Number of total lines.

line_comment: Vec<&'static str>

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

multi_line: Vec<(&'static str, &'static str)>

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

nested: bool

Whether the language supports nested multi line comments or not.

Methods

impl Language
[src]

fn new(line_comment: Vec<&'static str>, multi_line: Vec<(&'static str, &'static str)>) -> Self

Constructs a new empty Language with the comments provided.

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

fn new_blank() -> Self

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

let json = Language::new_blank();
let blank_vec: Vec<&str> = vec![];
assert_eq!(json.line_comment, blank_vec);

fn new_c() -> Self

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

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

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

fn new_func() -> Self

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

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

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

fn new_html() -> Self

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

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

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

fn new_hash() -> Self

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

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

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

fn new_multi(multi_line: Vec<(&'static str, &'static str)>) -> Self

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

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

fn new_pro() -> Self

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

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

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

fn new_single(line_comment: Vec<&'static str>) -> Self

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

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

fn is_empty(&self) -> bool

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

let rust = Language::new_c();

assert!(rust.is_empty());

fn is_blank(&self) -> bool

Checks if the language doesn't contain any comments.

let json = Language::new_blank();

assert!(json.is_blank());

fn nested(self) -> Self

Specify if the the language supports nested multi line comments.

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

fn sort_by(&mut self, category: Sort)

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

let mut rust = Language::new_c();
let mut foo_stats = Stats::new("foo");
let mut bar_stats = Stats::new("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 PartialOrd for Language
[src]

fn partial_cmp(&self, __arg_0: &Language) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more

fn lt(&self, __arg_0: &Language) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more

fn le(&self, __arg_0: &Language) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

fn gt(&self, __arg_0: &Language) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more

fn ge(&self, __arg_0: &Language) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl PartialEq for Language
[src]

fn eq(&self, __arg_0: &Language) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, __arg_0: &Language) -> bool

This method tests for !=.

impl Ord for Language
[src]

fn cmp(&self, __arg_0: &Language) -> Ordering

This method returns an Ordering between self and other. Read more

impl Eq for Language
[src]

impl Default for Language
[src]

fn default() -> Language

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

impl Debug for Language
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl Clone for Language
[src]

fn clone(&self) -> Language

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

impl AddAssign for Language
[src]

fn add_assign(&mut self, rhs: Self)

The method for the += operator

impl<'a> AddAssign<&'a Language> for Language
[src]

fn add_assign(&mut self, rhs: &'a Self)

The method for the += operator

impl<'a> AddAssign<&'a mut Language> for Language
[src]

fn add_assign(&mut self, rhs: &mut Self)

The method for the += operator

impl AddAssign<Stats> for Language
[src]

fn add_assign(&mut self, rhs: Stats)

The method for the += operator