Skip to content

Commit 21f7dbf

Browse files
committed
docs: readme updates
1 parent d63f336 commit 21f7dbf

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

Diff for: README.md

+34-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
# `kdl`
22

3-
`kdl` is a "document-oriented" parser and API. That means that, unlike
4-
serde-based implementations, it's meant to preserve formatting when
5-
editing, as well as inserting values with custom formatting. This is
6-
useful when working with human-maintained KDL files.
3+
`kdl` is a "document-oriented" parser and API for the [KDL Document
4+
Language](https://kdl.dev), a node-based, human-friendly configuration and
5+
serialization format. Unlike serde-based implementations, this crate
6+
preserves formatting when editing, as well as when inserting or changing
7+
values with custom formatting. This is most useful when working with
8+
human-maintained KDL files.
79

810
You can think of this crate as
911
[`toml_edit`](https://crates.io/crates/toml_edit), but for KDL.
1012

13+
If you don't care about formatting or programmatic manipulation, you might
14+
check out [`knuffel`](https://crates.io/crates/knuffel) or
15+
[`kaydle`](https://crates.io/crates/kaydle) instead for serde (or
16+
serde-like) parsing.
17+
1118
### Example
1219

1320
```rust
@@ -59,6 +66,29 @@ assert_eq!(&doc.to_string(), node_str);
5966
[`KdlDocument`], [`KdlNode`], [`KdlEntry`], and [`KdlIdentifier`] can all
6067
be parsed and managed this way.
6168

69+
70+
This error implements [`miette::Diagnostic`] and can be used to display
71+
detailed, pretty-printed diagnostic messages when using [`miette::Result`]
72+
and the `"pretty"` feature flag for `miette`:
73+
74+
```rust
75+
fn main() -> miette::Result<()> {
76+
"foo 1.".parse::<kdl::KdlDocument>()?;
77+
Ok(())
78+
}
79+
```
80+
81+
This will display a message like:
82+
```
83+
Error:
84+
× Expected valid value.
85+
╭────
86+
1 │ foo 1.
87+
· ─┬
88+
· ╰── invalid float
89+
╰────
90+
help: Floating point numbers must be base 10, and have numbers after the decimal point.
91+
```
6292
### License
6393

6494
The code in this repository is covered by [the Apache-2.0

Diff for: src/lib.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
//! `kdl` is a "document-oriented" parser and API. That means that, unlike
2-
//! serde-based implementations, it's meant to preserve formatting when
3-
//! editing, as well as inserting values with custom formatting. This is
4-
//! useful when working with human-maintained KDL files.
1+
//! `kdl` is a "document-oriented" parser and API for the [KDL Document
2+
//! Language](https://kdl.dev), a node-based, human-friendly configuration and
3+
//! serialization format. Unlike serde-based implementations, this crate
4+
//! preserves formatting when editing, as well as when inserting or changing
5+
//! values with custom formatting. This is most useful when working with
6+
//! human-maintained KDL files.
57
//!
68
//! You can think of this crate as
79
//! [`toml_edit`](https://crates.io/crates/toml_edit), but for KDL.
810
//!
9-
//! If you don't care about formatting or programmatic manipulation, you
10-
//! should check out [`knuffel`](https://crates.io/crates/knuffel) or
11+
//! If you don't care about formatting or programmatic manipulation, you might
12+
//! check out [`knuffel`](https://crates.io/crates/knuffel) or
1113
//! [`kaydle`](https://crates.io/crates/kaydle) instead for serde (or
1214
//! serde-like) parsing.
1315
//!

0 commit comments

Comments
 (0)