Skip to content

Commit

Permalink
marked-yaml: Update to yaml-rust2, and release 0.4.0
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
  • Loading branch information
kinnison committed Mar 26, 2024
1 parent ed46c99 commit 0133662
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 14 deletions.
104 changes: 98 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
members = [
"marked-yaml",
]
resolver = "2"
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,13 @@ came from.

Currently we provide:

* `marked-data`: The core data mark library
* `marked-yaml`: A deliberately simplified YAML subset which supports data marking

## Marked YAML

The `marked-yaml` library offers a subset of YAML designed for configuration files
and similar use. The data it reads in is "marked" with its origin. If you want
to use `marked-yaml` with your existing `serde` applications, you can enable the
`serde` feature, and if you want the errors produced by the `marked-yaml`
deserializer to include nice paths to any problem, along with ensuring the marker
for the problem area is populated in any errors, use the `serde-path` feature.
38 changes: 38 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[graph]
all-features = true

[licenses]
# List of explicitly allowed licenses
# See https://spdx.org/licenses/ for list of possible licenses
# [possible values: any SPDX 3.11 short identifier (+ optional exception)].
allow = ["MIT", "Apache-2.0", "Unicode-DFS-2016", "BSD-3-Clause"]
# The confidence threshold for detecting a license from license text.
# The higher the value, the more closely the license text must be to the
# canonical license text of a valid SPDX license file.
# [possible values: any between 0.0 and 1.0].
confidence-threshold = 0.8
# Allow 1 or more licenses on a per-crate basis, so that particular licenses
# aren't accepted for every possible crate as with the normal allow list
exceptions = [
# Each entry is the crate and version constraint, and its specific allow
# list
#{ allow = ["Zlib"], crate = "adler32" },
]

# Some crates don't have (easily) machine readable licensing information,
# adding a clarification entry for it allows you to manually specify the
# licensing information
#[[licenses.clarify]]
# The package spec the clarification applies to
#crate = "ring"
# The SPDX expression for the license requirements of the crate
#expression = "MIT AND ISC AND OpenSSL"
# One or more files in the crate's source used as the "source of truth" for
# the license expression. If the contents match, the clarification will be used
# when running the license check, otherwise the clarification will be ignored
# and the crate will be checked normally, which may produce warnings or errors
# depending on the rest of your configuration
#license-files = [
# Each entry is a crate relative path, and the (opaque) hash of its contents
#{ path = "LICENSE", hash = 0xbd0eed23 }
#]
6 changes: 3 additions & 3 deletions marked-yaml/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "marked-yaml"
version = "0.3.0"
version = "0.4.0"
authors = ["Daniel Silverstone <dsilvers@digital-scurf.org>"]
edition = "2018"
edition = "2021"
description = "A simplified YAML structure with provenance spans"
homepage = "https://github.com/kinnison/marked-yaml/"
repository = "https://github.com/kinnison/marked-yaml.git"
Expand All @@ -21,7 +21,7 @@ serde-path = ["serde", "dep:serde_path_to_error"]

[dependencies]
doc-comment = "0.3"
yaml-rust = "0.4.5"
yaml-rust = { version = "0.8", package = "yaml-rust2" }
linked-hash-map = "0.5.6"
serde = { version = "1.0.194", optional = true, features = ["derive"] }
serde_path_to_error = { version = "0.1.16", optional = true }
12 changes: 8 additions & 4 deletions marked-yaml/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,10 @@ impl MarkedEventReceiver for MarkedLoader {
assert_eq!(curstate, StartStream);
StartDocument
}
Event::MappingStart(aid) => {
if aid == 0 {
Event::MappingStart(aid, tag) => {
if tag.is_some() {
Error(LoadError::UnexpectedTag(mark))
} else if aid == 0 {
match curstate {
StartDocument => MappingWaitingOnKey(mark, MappingHash::new()),
MappingWaitingOnKey(_, _) => Error(LoadError::MappingKeyMustBeScalar(mark)),
Expand Down Expand Up @@ -185,8 +187,10 @@ impl MarkedEventReceiver for MarkedLoader {
}
_ => unreachable!(),
},
Event::SequenceStart(aid) => {
if aid == 0 {
Event::SequenceStart(aid, tag) => {
if tag.is_some() {
Error(LoadError::UnexpectedTag(mark))
} else if aid == 0 {
match curstate {
StartDocument => Error(LoadError::TopLevelMustBeMapping(mark)),
MappingWaitingOnKey(_, _) => Error(LoadError::MappingKeyMustBeScalar(mark)),
Expand Down

0 comments on commit 0133662

Please sign in to comment.