2020-06-19 06:44:03 +00:00
|
|
|
//! # Tokei: Count your code quickly.
|
2016-06-07 11:09:38 +00:00
|
|
|
//!
|
2019-01-10 09:53:24 +00:00
|
|
|
//! A simple, efficient library for counting code in directories. This
|
|
|
|
//! functionality is also provided as a
|
2019-03-30 11:25:35 +00:00
|
|
|
//! [CLI utility](//github.com/XAMPPRocky/tokei). Tokei uses a small state
|
2019-01-10 09:53:24 +00:00
|
|
|
//! machine rather than regular expressions found in other code counters. Tokei
|
|
|
|
//! can accurately count a lot more edge cases such as nested comments, or
|
|
|
|
//! comment syntax inside string literals.
|
2016-06-10 21:33:27 +00:00
|
|
|
//!
|
2019-01-10 09:53:24 +00:00
|
|
|
//! # Examples
|
2016-06-10 21:33:27 +00:00
|
|
|
//!
|
2019-01-10 09:53:24 +00:00
|
|
|
//! Gets the total lines of code from all rust files in current directory,
|
|
|
|
//! and all subdirectories.
|
2016-06-10 21:33:27 +00:00
|
|
|
//!
|
|
|
|
//! ```no_run
|
|
|
|
//! use std::collections::BTreeMap;
|
|
|
|
//! use std::fs::File;
|
|
|
|
//! use std::io::Read;
|
|
|
|
//!
|
2019-01-10 09:53:24 +00:00
|
|
|
//! use tokei::{Config, Languages, LanguageType};
|
2016-06-10 21:33:27 +00:00
|
|
|
//!
|
2020-02-13 16:02:59 +00:00
|
|
|
//! // The paths to search. Accepts absolute, relative, and glob paths.
|
|
|
|
//! let paths = &["src", "tests"];
|
|
|
|
//! // Exclude any path that contains any of these strings.
|
|
|
|
//! let excluded = &["target"];
|
|
|
|
//! // `Config` allows you to configure what is searched and counted.
|
|
|
|
//! let config = Config::default();
|
2016-06-10 21:33:27 +00:00
|
|
|
//!
|
2020-02-13 16:02:59 +00:00
|
|
|
//! let mut languages = Languages::new();
|
|
|
|
//! languages.get_statistics(paths, excluded, &config);
|
|
|
|
//! let rust = &languages[&LanguageType::Rust];
|
2016-06-10 21:33:27 +00:00
|
|
|
//!
|
2020-02-13 16:02:59 +00:00
|
|
|
//! println!("Lines of code: {}", rust.code);
|
2016-06-10 21:33:27 +00:00
|
|
|
//! ```
|
2016-06-07 11:09:38 +00:00
|
|
|
|
2019-10-30 19:31:24 +00:00
|
|
|
#![deny(
|
|
|
|
trivial_casts,
|
|
|
|
trivial_numeric_casts,
|
|
|
|
unused_variables,
|
|
|
|
unstable_features,
|
|
|
|
unused_import_braces,
|
|
|
|
missing_docs
|
|
|
|
)]
|
2019-01-10 09:53:24 +00:00
|
|
|
|
2019-10-30 19:31:24 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate log;
|
|
|
|
#[macro_use]
|
2020-03-20 17:22:48 +00:00
|
|
|
extern crate serde;
|
2016-06-07 11:09:38 +00:00
|
|
|
|
2019-10-30 19:31:24 +00:00
|
|
|
#[macro_use]
|
|
|
|
mod utils;
|
2019-01-10 09:53:24 +00:00
|
|
|
mod config;
|
2016-11-27 15:54:35 +00:00
|
|
|
mod language;
|
|
|
|
mod sort;
|
2019-01-10 09:53:24 +00:00
|
|
|
mod stats;
|
2016-07-17 21:17:49 +00:00
|
|
|
|
2019-06-01 18:25:12 +00:00
|
|
|
pub use self::{
|
|
|
|
config::Config,
|
2019-10-30 19:31:24 +00:00
|
|
|
language::{Language, LanguageType, Languages},
|
2019-06-01 18:25:12 +00:00
|
|
|
sort::Sort,
|
2020-07-17 19:45:44 +00:00
|
|
|
stats::{find_char_boundary, CodeStats, Report},
|
2019-06-01 18:25:12 +00:00
|
|
|
};
|