#[cfg(test)]
mod tests;
mod go;
mod java;
mod js_ts;
mod python;
mod rust;
pub(super) fn is_api_surface_lang(lang: &str) -> bool {
matches!(
lang.to_lowercase().as_str(),
"rust" | "javascript" | "typescript" | "python" | "go" | "java"
)
}
#[derive(Debug)]
pub(super) struct Symbol {
pub(super) is_public: bool,
pub(super) is_documented: bool,
}
pub(super) fn extract_symbols(lang: &str, text: &str) -> Vec<Symbol> {
let lines: Vec<&str> = text.lines().collect();
match lang.to_lowercase().as_str() {
"rust" => rust::extract_symbols(&lines),
"javascript" | "typescript" => js_ts::extract_symbols(&lines),
"python" => python::extract_symbols(&lines),
"go" => go::extract_symbols(&lines),
"java" => java::extract_symbols(&lines),
_ => Vec::new(),
}
}
pub(super) fn has_doc_comment(lines: &[&str], idx: usize) -> bool {
if idx == 0 {
return false;
}
let prev = lines[idx - 1].trim();
prev.starts_with("///")
|| prev.starts_with("//!")
|| prev.starts_with("/**")
|| prev.starts_with("#[doc")
|| prev.starts_with("/// ")
|| prev.starts_with("// ")
|| prev.starts_with("\"\"\"")
|| prev.starts_with("'''")
}