Skip to main content

aiproof_parse/
plain.rs

1use aiproof_core::document::{Document, Kind, PromptText, Role};
2use std::path::Path;
3
4pub fn parse(path: &Path, source: &str) -> anyhow::Result<Vec<Document>> {
5    Ok(vec![Document {
6        path: path.to_path_buf(),
7        role: Role::Unknown,
8        source: source.to_string(),
9        prompt: PromptText {
10            text: source.to_string(),
11            origin_span: None,
12        },
13        kind: Kind::PlainText,
14    }])
15}
16
17#[cfg(test)]
18mod tests {
19    use super::*;
20
21    #[test]
22    fn plain_roundtrips_source() {
23        let docs = parse(std::path::Path::new("a.prompt"), "hello").unwrap();
24        assert_eq!(docs.len(), 1);
25        assert_eq!(docs[0].prompt.text, "hello");
26    }
27}