Skip to content

Commit

Permalink
doc: add contributing.md
Browse files Browse the repository at this point in the history
  • Loading branch information
benlubas committed Oct 19, 2024
1 parent a15600c commit 1c2225b
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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.

<!-- vim: set tw=85 -->
48 changes: 48 additions & 0 deletions src/main.rs.bak
Original file line number Diff line number Diff line change
@@ -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<File>`
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<usize>`
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());
}

0 comments on commit 1c2225b

Please sign in to comment.