1pub mod jinja;
4pub mod json_schema;
5pub mod markdown;
6pub mod mustache;
7pub mod plain;
8pub mod python_extract;
9pub mod ts_extract;
10pub mod yaml;
11
12use aiproof_core::document::Document;
13use std::path::Path;
14
15pub fn parse_file(path: &Path, source: &str) -> anyhow::Result<Vec<Document>> {
16 let ext = path.extension().and_then(|e| e.to_str()).unwrap_or("");
17 match ext {
18 "md" => markdown::parse(path, source),
19 "j2" | "jinja" | "jinja2" => jinja::parse(path, source),
20 "mustache" => mustache::parse(path, source),
21 "yaml" | "yml" => yaml::parse(path, source),
22 "json" => json_schema::parse(path, source),
23 "py" => python_extract::parse(path, source),
24 "ts" | "tsx" => ts_extract::parse(path, source),
25 _ => plain::parse(path, source),
26 }
27}