tokei/src/lib.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
1.6 KiB
Rust
Raw Normal View History

//! # 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]
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;
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,
stats::{find_char_boundary, CodeStats, Report},
2019-06-01 18:25:12 +00:00
};