-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a major rewrite of kdl-rs to comply with the KDL v2 spec.
- Loading branch information
Showing
290 changed files
with
2,960 additions
and
1,290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package { | ||
name "kdl" | ||
name kdl | ||
version "0.0.0" | ||
description "kat's document language" | ||
description "The kdl document language" | ||
authors "Kat Marchán <[email protected]>" | ||
license-file "LICENSE.md" | ||
license-file LICENSE.md | ||
edition "2018" | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,52 @@ | ||
// This example is a GitHub Action if it used KDL syntax. | ||
// See .github/workflows/ci.yml for the file this was based on. | ||
name "CI" | ||
name CI | ||
|
||
on "push" "pull_request" | ||
on push pull_request | ||
|
||
env { | ||
RUSTFLAGS "-Dwarnings" | ||
RUSTFLAGS -Dwarnings | ||
} | ||
|
||
jobs { | ||
fmt_and_docs "Check fmt & build docs" { | ||
runs-on "ubuntu-latest" | ||
runs-on ubuntu-latest | ||
steps { | ||
step uses="actions/checkout@v1" | ||
step "Install Rust" uses="actions-rs/toolchain@v1" { | ||
profile "minimal" | ||
toolchain "stable" | ||
components "rustfmt" | ||
override true | ||
profile minimal | ||
toolchain stable | ||
components rustfmt | ||
override #true | ||
} | ||
step "rustfmt" run="cargo fmt --all -- --check" | ||
step "docs" run="cargo doc --no-deps" | ||
step rustfmt { run cargo fmt --all -- --check } | ||
step docs { run cargo doc --no-deps } | ||
} | ||
} | ||
build_and_test "Build & Test" { | ||
runs-on "${{ matrix.os }}" | ||
strategy { | ||
matrix { | ||
rust "1.46.0" "stable" | ||
os "ubuntu-latest" "macOS-latest" "windows-latest" | ||
rust "1.46.0" stable | ||
os ubuntu-latest macOS-latest windows-latest | ||
} | ||
} | ||
|
||
steps { | ||
step uses="actions/checkout@v1" | ||
step "Install Rust" uses="actions-rs/toolchain@v1" { | ||
profile "minimal" | ||
profile minimal | ||
toolchain "${{ matrix.rust }}" | ||
components "clippy" | ||
override true | ||
components clippy | ||
override #true | ||
} | ||
step "Clippy" run="cargo clippy --all -- -D warnings" | ||
step "Run tests" run="cargo test --all --verbose" | ||
step Clippy { run cargo clippy --all -- -D warnings } | ||
step "Run tests" { run cargo test --all --verbose } | ||
step "Other Stuff" run=" | ||
echo foo | ||
echo bar | ||
echo baz | ||
" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,50 @@ | ||
/// Show how to build your own diagnostics, without having to use the | ||
/// `fancy` feature or having `main()` return `miette::Result` | ||
use kdl::KdlDocument; | ||
use miette::Diagnostic; | ||
use miette::SourceSpan; | ||
// TODO(@zkat): Error stuff has changed, so this needs updating. | ||
|
||
#[derive(Debug)] | ||
pub struct MyError { | ||
pub message: String, | ||
} | ||
// /// Show how to build your own diagnostics, without having to use the | ||
// /// `fancy` feature or having `main()` return `miette::Result` | ||
// /// | ||
// use kdl::KdlDocument; | ||
// use miette::Diagnostic; | ||
// use miette::SourceSpan; | ||
|
||
fn parse(input: &str) -> Result<KdlDocument, MyError> { | ||
let doc = input.parse::<KdlDocument>(); | ||
doc.map_err(|error| { | ||
let source = error | ||
.source_code() | ||
.expect("parse errors should have source code"); | ||
let help = error.help.unwrap_or_default(); | ||
let span: SourceSpan = error.span; | ||
let contents = source | ||
.read_span(&span, 0, 0) | ||
.expect("source should have span contents"); | ||
// miette uses 0 based indexes, but humans prefer 1-based | ||
let line = contents.line() + 1; | ||
let column = contents.column() + 1; | ||
let message = format!( | ||
"line {}, column {}: {}\n help: {}", | ||
line, column, error, help | ||
); | ||
MyError { message } | ||
}) | ||
} | ||
// #[derive(Debug)] | ||
// pub struct MyError { | ||
// pub message: String, | ||
// } | ||
|
||
// fn parse(input: &str) -> Result<KdlDocument, MyError> { | ||
// let doc = input.parse::<KdlDocument>(); | ||
// doc.map_err(|error| { | ||
// let source = error | ||
// .source_code() | ||
// .expect("parse errors should have source code"); | ||
// let help = error.help.unwrap_or_default(); | ||
// let span: SourceSpan = error.span; | ||
// let contents = source | ||
// .read_span(&span, 0, 0) | ||
// .expect("source should have span contents"); | ||
// // miette uses 0 based indexes, but humans prefer 1-based | ||
// let line = contents.line() + 1; | ||
// let column = contents.column() + 1; | ||
// let message = format!( | ||
// "line {}, column {}: {}\n help: {}", | ||
// line, column, error, help | ||
// ); | ||
// MyError { message } | ||
// }) | ||
// } | ||
|
||
fn main() { | ||
let input = r#" | ||
foo { | ||
bar { | ||
baz 1. | ||
} | ||
} | ||
"#; | ||
let err = parse(input).unwrap_err(); | ||
eprintln!("{}", err.message); | ||
// Output: | ||
// line 4, column 14: Expected valid value. | ||
// help: Floating point numbers must be base 10, and have numbers after the decimal point. | ||
// let input = r#" | ||
// foo { | ||
// bar { | ||
// baz 1. | ||
// } | ||
// } | ||
// "#; | ||
// let err = parse(input).unwrap_err(); | ||
// eprintln!("{}", err.message); | ||
// // Output: | ||
// // line 4, column 14: Expected valid value. | ||
// // help: Floating point numbers must be base 10, and have numbers after the decimal point. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.