From 1c2225b421f9550910d88f4df5da72d97e446b20 Mon Sep 17 00:00:00 2001 From: Ben Lubas Date: Sat, 19 Oct 2024 11:22:28 -0400 Subject: [PATCH] doc: add contributing.md --- CONTRIBUTING.md | 22 ++++++++++++++++++++++ src/main.rs.bak | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 CONTRIBUTING.md create mode 100644 src/main.rs.bak diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..1734617 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,22 @@ +# Contributing + +If you're considering contributing, please open an issue before a PR. A lot of discussion +also happens in the [Neorg Discord](https://discord.gg/T6EgTAX7ht), so you might consider +joining. + +## Tests + +If you change a behavior or fix a bug, please make sure to add a test for it! + +- run the test suite with `cargo test` + +There are snapshot tests and prop tests. If you change the parser behavior or add a new +test case, the snapshots will change and you will see a test failure. You can approve the +new version of the snapshot with: + +- `cargo insta review` + +Prop tests essentially fuzz the parser and make sure that it doesn't panic. Failed test +cases are saved and version controlled to avoid regressions. + + diff --git a/src/main.rs.bak b/src/main.rs.bak new file mode 100644 index 0000000..3bd8a42 --- /dev/null +++ b/src/main.rs.bak @@ -0,0 +1,48 @@ +use std::fs::File; +use std::io::Read; +use std::path::Path; + +use chumsky::Parser as _; + +use rust_norg::parse; +use rust_norg::parse_tree; +// use rust_norg::parse_tree; +use rust_norg::stage_1; + +fn main() { + let file_path = Path::new("test.norg"); + // Open the path in read-only mode, returns `io::Result` + let mut file = match File::open(file_path) { + Err(why) => panic!("couldn't open {file_path:?}: {why:?}"), + Ok(file) => file, + }; + // Read the file contents into a string, returns `io::Result` + let mut s = String::new(); + match file.read_to_string(&mut s) { + Err(why) => panic!("couldn't read {:?}: {}", file_path, why), + Ok(_) => print!("{:?} contains:\n{}", file_path, s), + } + + + // let tag_type = "@"; + // let tag_name = "0"; + // let parameter = "a"; + // let multi_parameter = "\\"; + // let content = "\\"; + // + // // let content = format!("@{} {} {}\n{}\n@end", tag_name, parameter, multi_parameter, content); + // // let content = format!("{tag_type}{tag_name} {parameter} {multi_parameter}\n{content}\n{tag_type}end\n"); + // let content = "@0 a \\\n\\\n@end".to_string(); + + let content = " + #comment + #id 123 + some text + ".to_string(); + + println!("{:#?}", stage_1().parse(content.clone()).unwrap()); + + + println!("{:#?}", parse(&content).unwrap()); + println!("{:#?}", parse_tree(&content).unwrap()); +}