@daml-tools/daml-fmt 0.4.2 → 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 +41 -9
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -41,21 +41,23 @@ imports; use `--preserve-import-order` when package identity stability matters.
|
|
|
41
41
|
|
|
42
42
|
## Documentation
|
|
43
43
|
|
|
44
|
-
The workspace
|
|
44
|
+
The workspace documentation is organized under
|
|
45
|
+
[`docs`](https://github.com/stevennevins/daml-tools/blob/main/docs/README.md):
|
|
45
46
|
|
|
46
|
-
- [Format Daml source](
|
|
47
|
-
- [Verify a formatter change](
|
|
47
|
+
- [Format Daml source](https://github.com/stevennevins/daml-tools/blob/main/docs/how-to/format-daml.md) for CLI usage patterns
|
|
48
|
+
- [Verify a formatter change](https://github.com/stevennevins/daml-tools/blob/main/docs/how-to/verify-formatter-change.md) for
|
|
48
49
|
corpus, baseline, and audit commands
|
|
49
|
-
- [CLI reference](
|
|
50
|
-
- [Crate reference](
|
|
50
|
+
- [CLI reference](https://github.com/stevennevins/daml-tools/blob/main/docs/reference/cli.md) for options and exit codes
|
|
51
|
+
- [Crate reference](https://github.com/stevennevins/daml-tools/blob/main/docs/reference/crates.md) for features, binaries, and
|
|
51
52
|
public API
|
|
52
|
-
- [Formatter verification model](
|
|
53
|
+
- [Formatter verification model](https://github.com/stevennevins/daml-tools/blob/main/docs/explanation/formatter-verification.md)
|
|
53
54
|
for the token/desugar/idempotence safety story
|
|
54
55
|
|
|
55
56
|
## Build & install
|
|
56
57
|
|
|
57
|
-
daml-fmt depends only on the [`daml-parser`](https://crates.io/crates/daml-parser)
|
|
58
|
-
|
|
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
|
|
59
61
|
[daml-tools](https://github.com/stevennevins/daml-tools) workspace, so a normal
|
|
60
62
|
workspace checkout has everything it needs.
|
|
61
63
|
|
|
@@ -89,6 +91,36 @@ cat Foo.daml | daml-fmt # stdin -> stdout
|
|
|
89
91
|
|
|
90
92
|
Exit codes: 0 ok, 1 `--check` found unformatted files, 2 error.
|
|
91
93
|
|
|
94
|
+
## Library API
|
|
95
|
+
|
|
96
|
+
`daml-fmt` is also a Rust library. The primary entry points are
|
|
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.
|
|
101
|
+
|
|
102
|
+
```rust
|
|
103
|
+
use daml_fmt::{
|
|
104
|
+
format_source, format_source_with_options, try_format_source, FormatOptions, ImportOrder,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
let formatted = format_source("module M where\nfoo : Int\nfoo = 1\n");
|
|
108
|
+
|
|
109
|
+
let preserved = format_source_with_options(
|
|
110
|
+
"module M where\nimport DA.List\nimport DA.Optional\n\nx = []\n",
|
|
111
|
+
FormatOptions::new().with_import_order(ImportOrder::Preserve),
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
let checked = try_format_source("module M where\nfoo: Int\nfoo = 1\n").expect("valid source");
|
|
115
|
+
assert_eq!(checked, formatted);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
`ImportOrder` is `#[non_exhaustive]` for forward-compatible `match` arms.
|
|
119
|
+
`FormatOptions` uses private fields: construct options with `Default`/`new()` and
|
|
120
|
+
`with_*` helpers so new switches can ship with defaults without breaking callers.
|
|
121
|
+
|
|
122
|
+
See [crate reference](https://github.com/stevennevins/daml-tools/blob/main/docs/reference/crates.md) for the full public API.
|
|
123
|
+
|
|
92
124
|
## Workspace-Only Tests
|
|
93
125
|
|
|
94
126
|
These commands require a full repository checkout. The published crate excludes
|
|
@@ -120,7 +152,7 @@ Review-oriented full-corpus audit packets:
|
|
|
120
152
|
npm run audit # writes target/daml-fmt-audit
|
|
121
153
|
```
|
|
122
154
|
|
|
123
|
-
See
|
|
155
|
+
See [audit workflow](https://github.com/stevennevins/daml-tools/blob/main/crates/daml-fmt/docs/audit-workflow.md) for the 25-sample subagent review workflow.
|
|
124
156
|
|
|
125
157
|
The structural candidate metric (edit candidates over modeled constructs):
|
|
126
158
|
|
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",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"code-formatter",
|
|
10
10
|
"smart-contracts"
|
|
11
11
|
],
|
|
12
|
+
"homepage": "https://github.com/stevennevins/daml-tools",
|
|
12
13
|
"license": "AGPL-3.0-only",
|
|
13
14
|
"author": "Steven Nevins",
|
|
14
15
|
"repository": {
|
|
@@ -22,10 +23,10 @@
|
|
|
22
23
|
"node": ">=18"
|
|
23
24
|
},
|
|
24
25
|
"optionalDependencies": {
|
|
25
|
-
"@daml-tools/daml-fmt-darwin-arm64": "0.
|
|
26
|
-
"@daml-tools/daml-fmt-linux-arm64": "0.
|
|
27
|
-
"@daml-tools/daml-fmt-linux-x64": "0.
|
|
28
|
-
"@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"
|
|
29
30
|
},
|
|
30
31
|
"publishConfig": {
|
|
31
32
|
"access": "public"
|