@daml-tools/daml-fmt 0.4.2 → 0.5.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 +30 -7
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -41,15 +41,16 @@ 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
|
|
@@ -89,6 +90,28 @@ cat Foo.daml | daml-fmt # stdin -> stdout
|
|
|
89
90
|
|
|
90
91
|
Exit codes: 0 ok, 1 `--check` found unformatted files, 2 error.
|
|
91
92
|
|
|
93
|
+
## Library API
|
|
94
|
+
|
|
95
|
+
`daml-fmt` is also a Rust library. The primary entry points are
|
|
96
|
+
`format_source` (defaults) and `format_source_with_options`.
|
|
97
|
+
|
|
98
|
+
```rust
|
|
99
|
+
use daml_fmt::{FormatOptions, ImportOrder, format_source, format_source_with_options};
|
|
100
|
+
|
|
101
|
+
let formatted = format_source("module M where\nfoo : Int\nfoo = 1\n");
|
|
102
|
+
|
|
103
|
+
let preserved = format_source_with_options(
|
|
104
|
+
"module M where\nimport DA.List\nimport DA.Optional\n\nx = []\n",
|
|
105
|
+
FormatOptions::new().with_import_order(ImportOrder::Preserve),
|
|
106
|
+
);
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`ImportOrder` is `#[non_exhaustive]` for forward-compatible `match` arms.
|
|
110
|
+
`FormatOptions` uses private fields: construct options with `Default`/`new()` and
|
|
111
|
+
`with_*` helpers so new switches can ship with defaults without breaking callers.
|
|
112
|
+
|
|
113
|
+
See [crate reference](https://github.com/stevennevins/daml-tools/blob/main/docs/reference/crates.md) for the full public API.
|
|
114
|
+
|
|
92
115
|
## Workspace-Only Tests
|
|
93
116
|
|
|
94
117
|
These commands require a full repository checkout. The published crate excludes
|
|
@@ -120,7 +143,7 @@ Review-oriented full-corpus audit packets:
|
|
|
120
143
|
npm run audit # writes target/daml-fmt-audit
|
|
121
144
|
```
|
|
122
145
|
|
|
123
|
-
See
|
|
146
|
+
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
147
|
|
|
125
148
|
The structural candidate metric (edit candidates over modeled constructs):
|
|
126
149
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@daml-tools/daml-fmt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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.5.0",
|
|
27
|
+
"@daml-tools/daml-fmt-linux-arm64": "0.5.0",
|
|
28
|
+
"@daml-tools/daml-fmt-linux-x64": "0.5.0",
|
|
29
|
+
"@daml-tools/daml-fmt-win32-x64": "0.5.0"
|
|
29
30
|
},
|
|
30
31
|
"publishConfig": {
|
|
31
32
|
"access": "public"
|