@daml-tools/daml-fmt 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -4
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -55,8 +55,9 @@ The workspace documentation is organized under
|
|
|
55
55
|
|
|
56
56
|
## Build & install
|
|
57
57
|
|
|
58
|
-
daml-fmt depends only on the [`daml-parser`](https://crates.io/crates/daml-parser)
|
|
59
|
-
|
|
58
|
+
daml-fmt depends only on the [`daml-parser`](https://crates.io/crates/daml-parser) and
|
|
59
|
+
[`daml-syntax`](https://crates.io/crates/daml-syntax) crates (the shared lexer, layout,
|
|
60
|
+
and source-map pipeline), never on `daml-lint`. Both live in the
|
|
60
61
|
[daml-tools](https://github.com/stevennevins/daml-tools) workspace, so a normal
|
|
61
62
|
workspace checkout has everything it needs.
|
|
62
63
|
|
|
@@ -93,10 +94,15 @@ Exit codes: 0 ok, 1 `--check` found unformatted files, 2 error.
|
|
|
93
94
|
## Library API
|
|
94
95
|
|
|
95
96
|
`daml-fmt` is also a Rust library. The primary entry points are
|
|
96
|
-
`format_source` (defaults) and `format_source_with_options`.
|
|
97
|
+
`format_source` (defaults) and `format_source_with_options`. Use
|
|
98
|
+
`try_format_source` / `try_format_source_with_options` when callers need a typed
|
|
99
|
+
[`FormatError`] instead of a byte-faithful passthrough on malformed input.
|
|
100
|
+
`source_diagnostics` and `lex_diagnostics` return typed [`FormatDiagnostic`] values.
|
|
97
101
|
|
|
98
102
|
```rust
|
|
99
|
-
use daml_fmt::{
|
|
103
|
+
use daml_fmt::{
|
|
104
|
+
format_source, format_source_with_options, try_format_source, FormatOptions, ImportOrder,
|
|
105
|
+
};
|
|
100
106
|
|
|
101
107
|
let formatted = format_source("module M where\nfoo : Int\nfoo = 1\n");
|
|
102
108
|
|
|
@@ -104,6 +110,9 @@ let preserved = format_source_with_options(
|
|
|
104
110
|
"module M where\nimport DA.List\nimport DA.Optional\n\nx = []\n",
|
|
105
111
|
FormatOptions::new().with_import_order(ImportOrder::Preserve),
|
|
106
112
|
);
|
|
113
|
+
|
|
114
|
+
let checked = try_format_source("module M where\nfoo: Int\nfoo = 1\n").expect("valid source");
|
|
115
|
+
assert_eq!(checked, formatted);
|
|
107
116
|
```
|
|
108
117
|
|
|
109
118
|
`ImportOrder` is `#[non_exhaustive]` for forward-compatible `match` arms.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@daml-tools/daml-fmt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "A canonical code formatter for the Daml smart-contract language, built on daml-parser",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"daml",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"node": ">=18"
|
|
24
24
|
},
|
|
25
25
|
"optionalDependencies": {
|
|
26
|
-
"@daml-tools/daml-fmt-darwin-arm64": "0.
|
|
27
|
-
"@daml-tools/daml-fmt-linux-arm64": "0.
|
|
28
|
-
"@daml-tools/daml-fmt-linux-x64": "0.
|
|
29
|
-
"@daml-tools/daml-fmt-win32-x64": "0.
|
|
26
|
+
"@daml-tools/daml-fmt-darwin-arm64": "0.6.0",
|
|
27
|
+
"@daml-tools/daml-fmt-linux-arm64": "0.6.0",
|
|
28
|
+
"@daml-tools/daml-fmt-linux-x64": "0.6.0",
|
|
29
|
+
"@daml-tools/daml-fmt-win32-x64": "0.6.0"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|