- Rust 82.7%
- RenderScript 17.2%
- Just 0.1%
Fork of hyperpolyglot for application please_code_count
This is fork of the following crate. This fork serves for the language detection library of the following please_code_count.
Purpose
Hyperpolyglot is a fast programming language detector written in Rust based on Github's Linguist Ruby library. It is a library which can be used for detecting the programming language of a file or detecting the programming language makeup of a directory. For more details on how the language detection is done, see the Linguist README.
Using this Library
Adding as a dependency
[dependencies]
hyperpolyglot = "0.1.0"
Detect
usehyperpolyglot;letdetection=hyperpolyglot::detect(Path::new("src/bin/main.rs"));assert_eq!(Ok(Some(Detection::Heuristics("Rust"))),detection);Breakdown
usehyperpolyglot::{get_language_breakdown};letbreakdown: HashMap<&'staticstr,Vec<(Detection,PathBuf)>>=get_language_breakdown("src/");println!("{:?}",breakdown.get("Rust"));Divergences from Linguist
-
An additional heuristic was added for .h files.
-
Vim and Emacs modelines are not considered in the detection process.
-
Linguist has duplicate file name entries. Example: HOSTS/hosts as file name for INI files and hosts files. This crate prioritize one languages over the others in this case. Might come up with something better in the future.
Accuracy
All of the programming language detectors are far from perfect and hyperpolyglot is no exception. It's language detections mirror Linguist and enry for most files with the biggest divergences coming from files that need to fall back on the classifier.
Supported Languages
Supported languages are currently based on the tag v9.3.0 of the linguist repository.
Changeslog and Differences between this fork and the original hyperpolyglot
See this changelog
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Setup
- run
just git_submodules
Additional used tools for development
How to update supported languages
- Go into git submodule of linguist and checkout a newer commit or more preferably the latest tag
- Run
just codegen - Make sure all test pass. Aka
just testgoes through without failed tests
Note about codegen
Git will likely show changed file under the directory no matter if the listed languages have changed. Reason: The code generation produces random ordering of keys and values of the pdf generated hash maps.
How is your contribution licensed
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.