Skip to main content

miniconf_parser/
lib.rs

1#![doc = include_str!("../docs.md")]
2#![deny(unsafe_code)]
3#![warn(missing_docs)]
4
5/// Abstract syntax tree types used to represent parsed documents.
6pub mod ast;
7/// Error types emitted by the parser.
8pub mod error;
9/// Low-level parser utilities and the generated pest machinery.
10#[allow(missing_docs)]
11pub mod parser;
12
13pub use ast::{Document, Entry, Section, Value};
14pub use error::{MiniConfError, ParseErrorKind};
15
16/// Convenience function that parses `source` into a [`Document`].
17pub fn parse_str(source: &str) -> Result<Document, MiniConfError> {
18    parser::parse_document(source)
19}
20
21#[cfg(test)]
22mod tests {
23    use super::*;
24
25    #[test]
26    fn parses_minimal_document() {
27        let doc = parse_str("key = value\n").expect("parsed");
28        let root = doc.section("root").expect("root section");
29        assert_eq!(root.entries[0].key, "key");
30    }
31}