@codama/renderers-rust 1.2.8 → 2.0.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 +15 -13
- package/dist/index.node.cjs +460 -268
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +380 -212
- package/dist/index.node.mjs.map +1 -1
- package/dist/types/ImportMap.d.ts +4 -1
- package/dist/types/ImportMap.d.ts.map +1 -1
- package/dist/types/getRenderMapVisitor.d.ts +3 -4
- package/dist/types/getRenderMapVisitor.d.ts.map +1 -1
- package/dist/types/renderVisitor.d.ts +3 -2
- package/dist/types/renderVisitor.d.ts.map +1 -1
- package/dist/types/utils/cargoToml.d.ts +51 -0
- package/dist/types/utils/cargoToml.d.ts.map +1 -0
- package/dist/types/utils/fragment.d.ts +6 -0
- package/dist/types/utils/fragment.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/package.json +12 -9
package/README.md
CHANGED
|
@@ -17,14 +17,14 @@ pnpm install @codama/renderers-rust
|
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
19
19
|
|
|
20
|
-
Add the following script to your Codama configuration file.
|
|
20
|
+
Add the following script to your Codama configuration file. The first argument is the crate folder (where `Cargo.toml` lives) and the generated code will be output to `src/generated` within that folder by default.
|
|
21
21
|
|
|
22
22
|
```json
|
|
23
23
|
{
|
|
24
24
|
"scripts": {
|
|
25
25
|
"rust": {
|
|
26
26
|
"from": "@codama/renderers-rust",
|
|
27
|
-
"args": ["clients/rust
|
|
27
|
+
"args": ["clients/rust"]
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -36,17 +36,19 @@ An object can be passed as a second argument to further configure the renderer.
|
|
|
36
36
|
|
|
37
37
|
The `renderVisitor` accepts the following options.
|
|
38
38
|
|
|
39
|
-
| Name | Type | Default | Description
|
|
40
|
-
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ----------------------- |
|
|
41
|
-
| `deleteFolderBeforeRendering` | `boolean` | `true` | Whether the base directory should be cleaned before generating new files.
|
|
42
|
-
| `formatCode` | `boolean` | `false` | Whether we should use `cargo fmt` to format the generated code.
|
|
43
|
-
| `
|
|
44
|
-
| `
|
|
45
|
-
| `linkOverrides` | `Record<'accounts' \| 'definedTypes' \| 'instructions' \| 'pdas' \| 'programs' \| 'resolvers', Record<string, string>>` | `{}` | A object that overrides the import path of link nodes. For instance, `{ definedTypes: { counter: 'hooked' } }` uses the `hooked` folder to import any link node referring to the `counter` type.
|
|
46
|
-
| `dependencyMap` | `Record<string, string>` | `{}` | A mapping between import aliases and their actual crate name or path in Rust.
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
49
|
-
| `
|
|
39
|
+
| Name | Type | Default | Description |
|
|
40
|
+
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
41
|
+
| `deleteFolderBeforeRendering` | `boolean` | `true` | Whether the base directory should be cleaned before generating new files. |
|
|
42
|
+
| `formatCode` | `boolean` | `false` | Whether we should use `cargo fmt` to format the generated code. |
|
|
43
|
+
| `generatedFolder` | `string` | `'src/generated'` | The path to the generated folder, relative to the crate folder provided as the first argument. |
|
|
44
|
+
| `toolchain` | `string` | `"+stable"` | The toolchain to use when formatting the generated code. |
|
|
45
|
+
| `linkOverrides` | `Record<'accounts' \| 'definedTypes' \| 'instructions' \| 'pdas' \| 'programs' \| 'resolvers', Record<string, string>>` | `{}` | A object that overrides the import path of link nodes. For instance, `{ definedTypes: { counter: 'hooked' } }` uses the `hooked` folder to import any link node referring to the `counter` type. |
|
|
46
|
+
| `dependencyMap` | `Record<string, string>` | `{}` | A mapping between import aliases and their actual crate name or path in Rust. |
|
|
47
|
+
| `dependencyVersions` | `Record<string, CargoDependency>` | `{}` | A mapping between external crates — e.g. `solana-pubkey` — and the version range we should use for them — e.g. `^3.0` or the equivalent dependency object — e.g. `{ version: "^3.0" }`. The renderer offers default values for all external dependencies it relies on but this option may be used to override some of these values or add new ones. |
|
|
48
|
+
| `renderParentInstructions` | `boolean` | `false` | When using nested instructions, whether the parent instructions should also be rendered. When set to `false` (default), only the instruction leaves are being rendered. |
|
|
49
|
+
| `traitOptions` | [`TraitOptions`](#trait-options) | `DEFAULT_TRAIT_OPTIONS` | A set of options that can be used to configure how traits are rendered for every Rust types. See [documentation below](#trait-options) for more information. |
|
|
50
|
+
| `anchorTraits` | `boolean` | `true` | Whether to generate Anchor traits `impl` for account types. |
|
|
51
|
+
| `syncCargoToml` | `boolean` | `false` | Whether to update the dependencies of the existing `Cargo.toml` — or create a new `Cargo.toml` when missing — at the crate folder provided as the first argument. |
|
|
50
52
|
|
|
51
53
|
## Trait Options
|
|
52
54
|
|