pub enum Language {
TypeScript,
JavaScript,
Python,
Rust,
Go,
Java,
Markdown,
}Expand description
Supported programming languages and markup formats
ARCHITECTURE: Adding a new language requires:
- Add variant here
- Add tree-sitter grammar to Cargo.toml
- Implement
to_tree_sitter()mapping - Add file extension in
from_extension()
Variants§
Implementations§
Source§impl Language
impl Language
Sourcepub fn from_extension(ext: &str) -> Option<Self>
pub fn from_extension(ext: &str) -> Option<Self>
Detect language from file extension
§Examples
use std::path::Path;
use rskim_core::Language;
assert_eq!(Language::from_extension("ts"), Some(Language::TypeScript));
assert_eq!(Language::from_extension("py"), Some(Language::Python));
assert_eq!(Language::from_extension("unknown"), None);Sourcepub fn from_path(path: &Path) -> Option<Self>
pub fn from_path(path: &Path) -> Option<Self>
Detect language from file path
§Security
Rejects paths with parent directory traversal components (..)
to prevent path traversal attacks in future caching features.
Absolute paths are allowed.
Sourcepub fn to_tree_sitter(self) -> Language
pub fn to_tree_sitter(self) -> Language
Convert to tree-sitter Language
ARCHITECTURE: This is the ONLY place where tree-sitter grammars are loaded. Pattern: Lazy loading per language (don’t load all grammars upfront).
§Note on Markdown
tree-sitter-md has two parsers: LANGUAGE (block) and INLINE_LANGUAGE (inline). We only use LANGUAGE (block parser) since we’re extracting headers, not inline formatting.
Trait Implementations§
impl Copy for Language
impl Eq for Language
impl StructuralPartialEq for Language
Auto Trait Implementations§
impl Freeze for Language
impl RefUnwindSafe for Language
impl Send for Language
impl Sync for Language
impl Unpin for Language
impl UnwindSafe for Language
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more