Skip to main content

documented_toml/
lib.rs

1//! Format-preserving merge of a person's TOML configuration with the documented
2//! defaults an application ships.
3//!
4//! The crate documentation is the README, so its examples are compiled and run
5//! with the rest of the tests. `doc/design.md` states the merge rules and
6//! `corpus/` holds the output they produce, which is where the behaviour is
7//! specified.
8#![doc = include_str!("../README.md")]
9
10pub(crate) mod align;
11pub mod decor;
12pub mod error;
13pub mod merge;
14pub mod options;
15pub mod path;
16pub mod report;
17pub mod source;
18pub mod template;
19
20pub use decor::{
21    DEFAULT_PROSE_MARKER, DEFAULT_SAMPLE_MARKER, DefaultEcho, DocBlock, Marker, Prefix, PrefixLine,
22    Sample,
23};
24pub use error::Error;
25pub use merge::{MergeEngine, Merged, Newline};
26pub use options::{MergeOptions, Migration};
27pub use path::DottedPath;
28pub use report::{
29    Diagnostic, DiagnosticKind, Position, Report, Severity, Span, SpanIndex, TomlType,
30};
31pub use source::SourceDocument;
32pub use template::Template;
33
34/// Merges a user document against the defaults with the default marker and no
35/// rename rules. See [`MergeOptions`] for the configurable form.
36pub fn merge(default_src: &str, user_src: &str) -> Result<Merged, Error> {
37    MergeOptions::new().merge(default_src, user_src)
38}