Add language tools package
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
# decodal-language-tools
|
||||
|
||||
Source-level language tooling for Decodal.
|
||||
|
||||
This package is generated from the Rust crate in `crates/decodal-language-tools` with `wasm-pack`.
|
||||
It currently exposes a comment-preserving formatter that is shared by the official playground and future editor/LSP tooling.
|
||||
|
||||
Use `decodal-codemirror` separately when you need CodeMirror 6 language support.
|
||||
Use `decodal-wasm` separately when you need to evaluate Decodal in a browser.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install decodal-language-tools
|
||||
```
|
||||
|
||||
JSR:
|
||||
|
||||
```sh
|
||||
deno add jsr:@hare/decodal-language-tools
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import init, { formatSource } from 'decodal-language-tools';
|
||||
|
||||
await init();
|
||||
|
||||
const result = JSON.parse(formatSource('Server={# host\nhost=String default "localhost";};'));
|
||||
|
||||
if (result.ok) {
|
||||
console.log(result.source);
|
||||
} else {
|
||||
console.error(result.error);
|
||||
}
|
||||
```
|
||||
|
||||
The exported functions return JSON strings so callers can handle diagnostics without depending on Rust data structures.
|
||||
Reference in New Issue
Block a user