diff --git a/src/input.rs b/src/input.rs index f632bb1..b4e8d69 100644 --- a/src/input.rs +++ b/src/input.rs @@ -45,6 +45,7 @@ static TS_QUERY_JAVASCRIPT: LazyLock = LazyLock::new(|| { }); impl FileType { + /// Get [Tree Sitter query](tree_sitter::Query) for file type. pub fn tree_sitter_query(&self) -> &'static tree_sitter::Query { match self { FileType::Python => &TS_QUERY_PYTHON, @@ -53,6 +54,7 @@ impl FileType { } } + /// Get [Tree Sitter language](tree_sitter::Language) object from file type. pub fn tree_sitter_language(&self) -> tree_sitter::Language { match self { FileType::Python => tree_sitter_python::LANGUAGE.into(), @@ -62,10 +64,18 @@ impl FileType { } } +/// Read content of file in `path` to a String. +/// +/// # Errors +/// If there's a problem reading the file (e.g. if it doesn't exist). pub fn read_file(path: &PathBuf) -> Result { fs::read_to_string(path).map_err(|e| anyhow::anyhow!("Failed to read file: {}", e)) } +/// Determine file type from `path` extension. See [FileType]. +/// +/// # Errors +/// If the file type is not supported. pub fn determine_file_type(path: &PathBuf) -> Result { FileType::try_from(path) } diff --git a/src/parser.rs b/src/parser.rs index 81d7fce..b119bc8 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -20,7 +20,6 @@ pub const TAG: &str = "@"; /// /// # Errors /// If parsing the source code fails, or the tree-sitter query is invalid. -/// ``` pub fn extract_annotations( source_code: &str, file_type: &FileType, diff --git a/uv.lock b/uv.lock index 97a722a..db574be 100644 --- a/uv.lock +++ b/uv.lock @@ -3,7 +3,7 @@ requires-python = ">=3.9" [[package]] name = "anot" -version = "0.0.4" +version = "0.0.3" source = { virtual = "." } dependencies = [ { name = "maturin" },