1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! Format-preserving YAML edits.
//!
//! `yamled` changes the values you name in a YAML file and leaves every other
//! byte where it was: comments, blank lines, quoting, block and flow style,
//! and indentation. It indexes the source through `granit-parser` spans and
//! writes values through `serde-saphyr`.
//!
//! ```
//! use indoc::indoc;
//! use yamled::{Document, Path};
//!
//! let mut ledger = Document::parse(indoc! {"
//! ## A work queue.
//! active: A-1
//! queue:
//! - id: A-1
//! title: Write the index
//! "})?;
//!
//! ledger.replace(&Path::root().key("active"), "A-2")?;
//! ledger.replace(
//! &Path::root().key("queue").index(0).key("title"),
//! "Write the index: v2",
//! )?;
//!
//! assert_eq!(
//! ledger.as_str(),
//! indoc! {"
//! ## A work queue.
//! active: A-2
//! queue:
//! - id: A-1
//! title: 'Write the index: v2'
//! "}
//! );
//! # Ok::<(), yamled::Error>(())
//! ```
//!
//! Every edit parses its result. When the result would not parse, the edit
//! returns an [`Error`] and the document keeps its old text.
//!
//! # Features
//!
//! - `serde` (default): the edits that write a value, `replace`, `insert`,
//! `push`, and `insert_item` with their `_text` forms, through `serde` and
//! `serde-saphyr`. Without it the crate depends on `granit-parser` alone and
//! keeps the location index and the edits that move text: `remove`, `take`,
//! `put`, `reorder`, and `reindent`.
pub use cratePosition;
pub use crate;
pub use crateError;
pub use crate;
pub use crate;
pub use crateTextStyle;