Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/language/src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use thread_utilities::RapidMap;
///
/// ## Examples
///
/// ```rust
/// ```ignore
/// use thread_language::Html;
/// use thread_ast_engine::{Language, LanguageExt};
///
Expand Down
34 changes: 22 additions & 12 deletions crates/language/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
//!
//! ## Usage
//!
//! ```rust
//! ```ignore
//! use thread_language::{SupportLang, Rust};
//! use thread_ast_engine::{Language, LanguageExt};
//!
Expand Down Expand Up @@ -248,15 +248,15 @@ macro_rules! impl_lang {
/// - `Cow::Owned` if replacement occurred
///
/// # Examples
/// ```rust
/// # use thread_language::pre_process_pattern;
/// ```ignore
/// // use thread_language::pre_process_pattern;
/// // Python doesn't accept $ in identifiers, so use µ
/// let result = pre_process_pattern('µ', "def $FUNC($ARG): pass");
/// assert_eq!(result, "def µFUNC(µARG): pass");
/// // let result = pre_process_pattern('µ', "def $FUNC($ARG): pass");
/// // assert_eq!(result, "def µFUNC(µARG): pass");
///
/// // No change needed
/// let result = pre_process_pattern('µ', "def hello(): pass");
/// assert_eq!(result, "def hello(): pass");
/// // let result = pre_process_pattern('µ', "def hello(): pass");
/// // assert_eq!(result, "def hello(): pass");
/// ```
#[allow(dead_code)]
fn pre_process_pattern(expando: char, query: &str) -> std::borrow::Cow<'_, str> {
Expand Down Expand Up @@ -337,7 +337,7 @@ fn pre_process_pattern(expando: char, query: &str) -> std::borrow::Cow<'_, str>
/// - Provide the expando character via [`Language::expando_char`]
///
/// # Examples
/// ```rust
/// ```ignore
/// # use thread_language::Python;
/// # use thread_ast_engine::Language;
/// let python = Python;
Expand Down Expand Up @@ -656,7 +656,7 @@ impl_lang!(Yaml, language_yaml);
/// Each variant corresponds to a specific programming language implementation.
///
/// # Language Detection
/// ```rust,ignore
/// ```ignore,ignore
/// use thread_language::SupportLang;
/// use std::path::Path;
///
Expand All @@ -670,7 +670,7 @@ impl_lang!(Yaml, language_yaml);
/// ```
///
/// # Usage with AST Analysis
/// ```rust,ignore
/// ```ignore,ignore
/// use thread_language::SupportLang;
/// use thread_ast_engine::{Language, LanguageExt};
///
Expand Down Expand Up @@ -1737,7 +1737,7 @@ pub fn from_extension(path: &Path) -> Option<SupportLang> {
}

// Silence unused variable warning if bash and ruby and all-parsers are not enabled
let _ = file_name;
let _ = _file_name;
}

// 3. Try shebang check as last resort
Expand Down Expand Up @@ -1958,7 +1958,17 @@ mod test {
}
}

// TODO: add test for file_types
#[test]
fn test_file_types() {
let rust_types = SupportLang::Rust.file_types();
assert!(rust_types.matched("test.rs", false).is_whitelist());
assert!(rust_types.matched("test.js", false).is_ignore());

let js_types = SupportLang::JavaScript.file_types();
assert!(js_types.matched("test.js", false).is_whitelist());
assert!(js_types.matched("test.jsx", false).is_whitelist());
assert!(js_types.matched("test.rs", false).is_ignore());
}

#[test]
fn test_from_extension_shebang() {
Expand Down
Loading
Loading