Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for KDL 2.0 #24

Merged
merged 37 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8692567
test: update tests submodule
larsgw Jan 4, 2025
59ed754
fix(parser): add whitespace escapes to quoted strings
larsgw Jan 4, 2025
fab0f3c
fix(parser): add vertical tab (0x0B) as newline
larsgw Jan 4, 2025
3226239
fix(parser): update escaped characters for quoted strings
larsgw Jan 4, 2025
8fea358
fix(parser): un-reserve ",", "<", and ">" from identifier strings
larsgw Jan 4, 2025
2035981
fix(parser): disallow some literal code points
larsgw Jan 4, 2025
972c49c
fix(parser): remove raw string prefix
larsgw Jan 4, 2025
6de575c
fix(parser): fix escline behavior
larsgw Jan 4, 2025
4559c86
fix(parser): remove '#' as identifier character
larsgw Jan 4, 2025
2903356
fix(parser): update boolean/null literals
larsgw Jan 4, 2025
b38231b
fix(parser): allow bare identifier strings
larsgw Jan 4, 2025
9ce2805
fix(parser): implement float keywords
larsgw Jan 4, 2025
fb4db0d
fix(parser): disallow more numeric-like bare identifiers
larsgw Jan 4, 2025
45839cc
fix(parser): disallow banned identifier values
larsgw Jan 4, 2025
9c7d629
fix(parser): disallow escaped unicode scalar values
larsgw Jan 4, 2025
fb5ee41
fix(parser): disallow more literal code points
larsgw Jan 4, 2025
64ef565
fix(parser): only allow U+FEFF at start of file
larsgw Jan 4, 2025
ba220cb
fix(parser): implement bare identifier strings
larsgw Jan 4, 2025
c6a4111
fix(parser): fix slashdash behavior
larsgw Jan 4, 2025
97cf99c
fix(parser): update optional whitespace limitations
larsgw Jan 4, 2025
5f0ac6e
chore(ci): update dev dependencies
larsgw Jan 4, 2025
ff3e8ba
style(parser): add exceptions to eslint rules
larsgw Jan 4, 2025
bf7dc2a
fix(parser): implement multiline strings
larsgw Jan 5, 2025
7a19541
fix(formatter): update to KDL 2.0
larsgw Jan 5, 2025
8eaf8d2
fix(parser): fix slashdash behavior
larsgw Jan 5, 2025
0355a70
fix(parser): fix disallowed code point regexes
larsgw Jan 5, 2025
71a3473
fix(parser): fix unterminated nodes at the end of children blocks
larsgw Jan 5, 2025
48a7b35
fix(parser): fix parsing of multiline strings
larsgw Jan 5, 2025
e3c6925
fix(parser): fix handling of surrogate pairs
larsgw Jan 5, 2025
73b22a6
fix(query): update KQL to 2.0
larsgw Jan 5, 2025
3cd06a3
docs(readme): validate examples
larsgw Jan 5, 2025
7ea4e27
style(parser): remove unused code
larsgw Jan 5, 2025
b8095f3
chore: bump development dependencies
larsgw Jan 5, 2025
0b1d787
refactor: change to ESM
larsgw Jan 5, 2025
f0d0598
fix(types): update to KDL 2.0
larsgw Jan 5, 2025
62b7d27
docs(parser): fix jsdoc annotations
larsgw Jan 5, 2025
62e9443
chore(jsdoc): update jsdoc configuration
larsgw Jan 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ on:
workflow_dispatch:
push:
tags:
- '*'
- '*'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is why we don't like yaml

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBF I think it worked regardless, it just didn't match the rest of the file (nor my expectations)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂


jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v2.1.2
uses: actions/setup-node@v4
with:
node-version: '18.x'
node-version: '20.x'

- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
Expand All @@ -16,14 +13,14 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "test/kdl4j"]
path = test/kdl4j
url = https://github.com/hkolbeck/kdl4j
[submodule "test/kdl-official"]
path = test/kdl-official
url = https://github.com/kdl-org/kdl
31 changes: 0 additions & 31 deletions .jsdoc.js

This file was deleted.

28 changes: 28 additions & 0 deletions .jsdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"plugins": ["plugins/markdown"],
"markdown": {
"idInHeadings": true
},
"tags": {
"allowUnknownTags": true,
"dictionaries": ["jsdoc", "closure"]
},
"source": {
"include": [
"src",
"src/parser"
]
},
"opts": {
"destination": "./docs/0.2/",
"encoding": "utf8",
"readme": "./README.md"
},
"templates": {
"default": {
"includeDate": true
},
"cleverLinks": false,
"monospaceLinks": false
}
}
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@
# [0.1.0-rc.0](https://github.com/kdl-org/kdljs/compare/v0.0.3...v0.1.0-rc.0) (2021-08-31)


* feat(formatter)!: support KDL serialization ([4c4c94e](https://github.com/kdl-org/kdljs/commit/4c4c94edb14c2867f539288033f0edca97a15410))


### Bug Fixes

* **parser:** allow raw strings as identifiers ([8cea257](https://github.com/kdl-org/kdljs/commit/8cea257261caaf9313303b2f2b1bf0e166ece08b))
Expand All @@ -131,9 +134,6 @@
* **ts:** update types ([3049abe](https://github.com/kdl-org/kdljs/commit/3049abe46343cea4f2c091ef9426573d75771668))


* feat(formatter)!: support KDL serialization ([4c4c94e](https://github.com/kdl-org/kdljs/commit/4c4c94edb14c2867f539288033f0edca97a15410))


### Features

* **formatter:** support same output options as kdl4j ([d37df28](https://github.com/kdl-org/kdljs/commit/d37df287cf99a9628e37a14f8e6c35cb7cac5632))
Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ smile "😁"
parse(`
// Instead of anonymous nodes, nodes and properties can be wrapped
// in "" for arbitrary node names.
"!@#$@$%Q#$%~@!40" "1.2.3" "!!!!!"=true
"!@#$@$%Q#$%~@!40" "1.2.3" "!!!!!"=#true
`)

// [
Expand All @@ -73,15 +73,15 @@ parse(`

parse(`
// The following is a legal bare identifier:
foo123~!@#$%^&*.:'|/?+ "weeee"
foo123~!@$%^&*.:'|?+ "weeee"

// And you can also use unicode!
ノード お名前"☜(゚ヮ゚☜)"
ノード お名前="☜(゚ヮ゚☜)"
`)

// [
// {
// name: "foo123~!@#$%^&*.:'|/?+",
// name: "foo123~!@$%^&*.:'|?+",
// properties: {},
// values: [ 'weeee' ],
// children: [],
Expand All @@ -107,7 +107,7 @@ foo123~!@#$%^&*.:'|/?+ "weeee"
parse(`
// kdl specifically allows properties and values to be
// interspersed with each other, much like CLI commands.
foo bar=true "baz" quux=false 1 2 3
foo bar=#true "baz" quux=#false 1 2 3
`)

// [
Expand All @@ -131,6 +131,7 @@ package {
(author)person contact=(email)"example@example.org"
(contributor)person homepage=(url)"https://example.org/example"
}
`)

// [
// {
Expand Down Expand Up @@ -160,10 +161,10 @@ package {
// values: []
// }
// }
// ]
// ],
// tags: { name: undefined, properties: {}, values: [] }
// }
// ]
`)
```

### Querying
Expand All @@ -178,12 +179,12 @@ const { output: document } = parse(`package {
winapi "1.0.0" path="./crates/my-winapi-fork"
}
dependencies {
miette "2.0.0" dev=true
miette "2.0.0" dev=#true
}
}`)

query(document, 'package name') // or
query(document, 'top() > package name')
query(document, 'package >> name') // or
query(document, 'top() > package >> name')

// [
// {
Expand Down Expand Up @@ -238,7 +239,7 @@ query(document, 'dependencies > []')
// MAP OPERATOR
// ============

query(document, 'package name => val()')
query(document, 'package >> name => val()')
// ['foo'].

query(document, 'dependencies[platform] => platform')
Expand Down
5 changes: 3 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export type Value = string | number | boolean | null;
*/
export interface NodeTypeAnnotations {
/** The type annotation of the Node */
name: string;
name: string|undefined;
/** The type annotations of the {@link https://github.com/kdl-org/kdl/blob/main/SPEC.md#argument|Arguments} */
values: string[];
values: Array<string|undefined>;
/** The type annotations of the {@link https://github.com/kdl-org/kdl/blob/main/SPEC.md#property|Properties} */
properties: Record<string, string>;
}
Expand Down Expand Up @@ -64,6 +64,7 @@ export interface FormattingOptions {
indent?: number;
indentChar?: string;
exponentChar?: string;
preferIdentifierString?: boolean;
printEmptyChildren?: boolean;
printNullArgs?: boolean;
printNullProps?: boolean;
Expand Down
Loading
Loading