Commit Graph

33 Commits

Author SHA1 Message Date
Tamme Schichler 014c7c57a2
feat(fmt): Configurable autoformat with `FormatConfig` (#95)
Fixes: https://github.com/kdl-org/kdl-rs/issues/85
2024-12-06 12:59:20 -08:00
Kat Marchán 2802578ba0
feat(parser): update to 2.0.0-draft.5 (#90) 2024-12-02 23:26:40 -08:00
Kat Marchán a641995293
refactor(parser): refactor try_parse to be lift more weight 2024-10-08 22:37:43 -07:00
Kat Marchán c9898cdbd2
feat(parser): v2 parser (#70)
This is a major rewrite of kdl-rs to comply with the KDL v2 spec.
2024-10-05 20:51:09 -07:00
jaxter184 6044ef9776 fix: Change numerical key `insert` behavior 2023-04-25 20:44:57 -07:00
jaxter184 f527490d81 fix: Panic when using `remove` with bad positional index 2023-04-25 20:44:57 -07:00
jaxter184 be0dc1708d fix(api): Fix `insert` and `remove` behavior for `KdlNode` 2023-04-25 20:44:57 -07:00
Kat Marchán 6d1a516eb9
feat(kql): implement KQL query engine (#61)
Fixes: https://github.com/kdl-org/kdl-rs/issues/32

This implements a proposed draft of a KQL engine,
allowing CSS selector-style querying of KDL documents (and nodes)
in a variety of different ways.
2022-12-04 19:22:10 -08:00
Aria Beingessner 04471a537e
feat(spans): rework the span API to be strictly by-val (#60)
BREAKING CHANGE: this removes all the `.span_mut()` methods and changes the signature for `.span()`.
2022-12-04 10:19:58 -08:00
Kat Marchán 3d8778a610
feat(api): Improve .get()/.entry() APIs to be more consistent with Rust conventions
BREAKING CHANGE: KdlNode::get* are now KdlNode::entry*. Additionally, KdlDocument::get_dash_vals has been renamed to KdlDocument::get_dash_args.
2022-11-29 23:10:25 -08:00
Aria Beingessner b17ef8e2c6
feat(spans): add spans to most elements (#57)
This necessitates passing the input around through all the sub-parsers so they
can compute their own sub-spans, which in turn necessitates making most of the
subparsers into nom-style 'function builders' by wrapping them in closures and
returning the closures.

The current impl hides this functionality behind an on-by-default "span" feature.

Some fallout of this change:

There is now a private parser::KdlParser type that must be constructed with the
full input for all span computation. The parser::parser method has been moved to
a method of this to make sure the full_input used for span computation is the
same one passed to parsing. In doing this a bug where the span of errors would
be incorrectly computed for non-ascii strings has been fixed.

Types now manually implement PartialEq and Hash to avoid incorporating the span
of the item into those computations.

All parser combinators must first have the KdlParser applied before using them,
making their signatures far more complex. Unfortunately KdlParser::parse can't
apply that for you because I don't think it's possible to express that complex
of a signature and not have the lifetimes get messed up.
2022-08-30 20:24:06 -07:00
Christopher Durham 2e9c0447f9
fix(formatting): Fix formatting when decoration is not present (#56) 2022-08-18 12:22:15 -07:00
Cliff L. Biffle bbc5e4e6a6
fix(fmt): Indent trailing brace of nested nodes. (#49)
In 4.3.0, the Display output for nested nodes always puts the trailing
braces on the left margin:

    a {
        b {
            c {
    }
    }
    }

This commit indents the trailing brace to match the node name, at least
when explicit trailing text is not provided.
2022-07-22 08:00:54 -07:00
Nicola Papale cd2d6e42b1
feat(fmt): Add clear_fmt_recursive method (#45)
Fixes #46

When comparing two different `KdlNode` or `KdlDocument`, it's useful to
have a "canonical" representation where formatting differences do not
matter.

`clear_fmt` removes all formatting from a `KdlNode`, but does not apply
recursively, as a result, it doesn't create a canonical representation.
`clear_fmt_recursive` solves this by applying `clear_fmt` recursively to
the contents of the node.
2022-06-10 17:05:58 -07:00
Kat Marchán 58a40fdf48
fix(compliance): pull in spec test suite and fix issues (#40)
This commit includes a whole bunch of fixes, some of which are significant changes to the parser and some related functionality. But I consider all changes to be bugfixes because they were compliance failures.
2022-04-27 23:21:28 -07:00
Kat Marchán 12d373a1e0
feat(fmt): shiny new comment-preserving formatter! (#38)
Fixes: https://github.com/kdl-org/kdl-rs/issues/34
2022-04-23 22:34:51 -07:00
Kat Marchán 177c42cae7
feat(len): add APIs to calculate component lengths (#36)
Fixes: https://github.com/kdl-org/kdl-rs/issues/19
2022-04-23 02:15:31 -07:00
Kat Marchán 1a8eb35168 fix(parse): small parser tweaks + more tests 2022-04-23 01:21:28 -07:00
Kat Marchán 892bf06e69 feat(clear_fmt): add methods to clear formatting and reset it to default 2022-04-23 01:21:28 -07:00
Kat Marchán fc1d0fd24b chore: clean up and docs 2022-04-23 01:21:28 -07:00
Kat Marchán a1555949ed refactor: clean up parser/FromStr toplevel stuff and add one for KdlIdentifier 2022-04-23 01:21:28 -07:00
Kat Marchán 16c82f1ec1
feat(types): add type annotation support (#31) 2022-04-22 12:00:32 -07:00
Kat Marchán 364ea6173c
feat(api): complete rewrite into document-oriented parser (#29)
This new version of kdl-rs is a complete rewrite that introduces
a formatting-aware-and-preserving parser, much like toml_edit et al.

BREAKING CHANGE: Completely new API and bumped MSRV to 1.56.0.
2022-04-22 02:20:30 -07:00
jam1garner 94190697d8
feat(docs): Add documentation for the entire crate (#16) 2021-05-08 14:40:15 -07:00
hclarke b8c8b52748
feat(display): implemented Display for KdlNode (#6) 2021-05-08 14:39:35 -07:00
Kat Marchán 2c443aed85
cargo fmt 2020-12-18 22:35:52 -08:00
Kat Marchán b4d3f07d09
more stuff 2020-12-18 20:46:52 -08:00
Lily Ballard 685a537658
Add From and TryFrom impls for converting to/from KdlNodeValue (#5)
* Add From impls for KdlNodeValue

Most clients probably don't need to create these directly, but we may as
well make it easy for them.

* Add TryFrom impls to convert from KdlNodeValue to underlying types

This includes converting from borrowed values, which will produce `&str`
instead of `String`.
2020-12-16 17:47:39 -08:00
Kat Marchán 75c176ae54
switch to LF line endings 2020-12-14 00:07:14 -08:00
Kat Marchán 42564a7cf7
rename Node and NodeValue 2020-12-13 22:31:30 -08:00
Kat Marchán a316f6d2ef
some progress + tests 2020-12-12 17:51:18 -08:00
Kat Marchán 100a736145
node, identifier, and comments done 2020-12-12 15:07:19 -08:00
Kat Marchán 3296cc83a0
wip parser 2020-12-12 11:50:34 -08:00