Crate languages

Source
Expand description

A Rust library for GitHub’s programming language data.

This library provides functions to look up language information based on name, file extension, or CodeMirror mode. The data is sourced from GitHub’s Linguist repository and embedded at compile time.

§Examples

// Look up a language by its name
let rust = languages::from_name("Rust").unwrap();
assert_eq!(rust.language_type, "programming");
assert_eq!(rust.color, Some("#dea584"));

// Look up by extension
let js = languages::from_extension("js").unwrap();
assert_eq!(js.name, "JavaScript");

Structs§

Language

Constants§

ALL_LANGUAGES

Statics§

CODEMIRROR_MODE_MAP
EXTENSION_MAP
NAME_MAP

Functions§

from_codemirror_mode
Retrieves a Language by its CodeMirror mode.
from_extension
Retrieves a Language by a file extension.
from_name
Retrieves a Language by its official name or one of its aliases.