Skip to content

Commit

Permalink
release 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alightgoesout committed Mar 17, 2024
1 parent 05b9bd7 commit e055109
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 17 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright 2022 Hannah Kolbeck
Copyright 2024 Romain Delamare

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
Expand All @@ -12,4 +13,3 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

64 changes: 49 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,57 @@ A Java implementation of a parser for the [KDL Document Language](https://github

## Status

![Gradle CI](https://github.com/hkolbeck/kdl4j/workflows/Gradle%20CI/badge.svg)

This project is beta-quality. It's been extensively tested, but the spec it implements is still in flux.
This branch contains the code for version 0.x of KDL4j that supports KDL 1.0. We recommend that you switch to KDL 2.0
and use KDL4j 2.0 or up.

## Usage

## Dependency

Releases are published on [GitHub Packages](https://docs.github.com/en/packages). You need to authenticate with GitHub
using a token with `read:packages` permission. See the official documentation for more information on how to
authenticate on GitHub Packages for
[Maven](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry)
or for
[Gradle](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry).

Then you can add the KDL4j dependency. Maven:

```xml

<dependencies>
<dependency>
<groupId>kdl</groupId>
<artifactId>kdl4j</artifactId>
<version>0.3.0</version>
</dependency>
</dependencies>
```

Gradle:

```groovy
dependencies {
implementation 'kdl:kdl4j:0.3.0'
}
```

Alternatively, you can use the packages [hosted by JitPack](https://jitpack.io/#kdl-org/kdl4j). In this case, make sure
you use the `com.github.kdl-org` groupId.

### Parsing

```java
final KDLParser parser = new KDLParser();

final KDLDocument documentFromString = parser.parse("node_name \"arg\"")
final KDLDocument documentFromString = parser.parse("node_name \"arg\"");
// OR
final KDLDocument documentFromReader = parser.parse(new FileReader("some/file.kdl"))
final KDLDocument documentFromReader = parser.parse(new FileReader("some/file.kdl"));
```

`KDLDocument` objects, and all descendants of `KDLObject`, are immutable and threadsafe, though that is not true of their
`Builder` objects. If you need to make changes to a `KDLDocument`, use the `filter()` and `mutate()` functions explained below.
`KDLDocument` objects, and all descendants of `KDLObject`, are immutable and threadsafe, though that is not true of
their `Builder` objects. If you need to make changes to a `KDLDocument`, use the `filter()` and `mutate()` functions
explained below.

### Searching and Mutating Documents

Expand All @@ -35,19 +68,20 @@ the document differs. There are three search types:
Each provides four methods for searching or mutating documents:

* `anyMatch(document)` - Returns true if any node matches the search, false otherwise
* `filter(document, trim)` - Removes all nodes from the tree not on a branch that matches the predicates of the search. if
`trim` is set, removes all their non-matching children
* `filter(document, trim)` - Removes all nodes from the tree not on a branch that matches the predicates of the search.
if `trim` is set, removes all their non-matching children
* `list(document, trim)` - Produces a new document with all matching nodes at the root. If `trim` is set, removes all
their non-matching children
* `mutate(document, mutation)` - Applies a provided `Mutation` to every matching node in the tree, depth first.

There are 3 types of `Mutations` provided, and users may provide custom mutations. Provided are `AddMutation`,
`SubtractMutation`, and `SetMutation`. Each performs functions hinted at by the name. See individual javadocs for details.
There are 3 types of `Mutations` provided, and users may provide custom mutations. Provided are `AddMutation`,
`SubtractMutation`, and `SetMutation`. Each performs functions hinted at by the name. See individual javadocs for
details.

### Printing

By default, calling `document.toKDL()` or `document.writeKDL(writer)` will print the structure with:

* 4 space indents
* No semicolons
* Printable ASCII characters which can be escaped, escaped
Expand All @@ -62,6 +96,6 @@ on PrintConfig for more information.

Please read the Code of Conduct before opening any issues or pull requests.

Besides code fixes, the easiest way to contribute is by generating test cases. Check out
[the test cases directory](https://github.com/hkolbeck/kdl4j/tree/trunk/src/test/resources/test_cases) to see the existing ones.
See the README there for more details.
Besides code fixes, the easiest way to contribute is by generating test cases. Check out
[the test cases directory](https://github.com/hkolbeck/kdl4j/tree/trunk/src/test/resources/test_cases) to see the
existing ones. See the README there for more details.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.3.0-RC2
version=0.3.0

0 comments on commit e055109

Please sign in to comment.