Skip to content

Commit 3703d45

Browse files
committed
docs: update rule documentation and schema generation
Update rule documentation and schema generation tools to reflect recent improvements to Rust component binding generation: **Documentation Updates:** - Refresh rules.mdx with current rust_wasm_component_bindgen capabilities - Update rule descriptions to reflect enhanced binding generation - Document improved WAC composition support and multi-file packaging **Schema Generation Improvements:** - Enhance comprehensive_schemas.go to capture latest rule attributes - Update schema generation to reflect binding generation improvements - Ensure documentation accurately represents current rule capabilities These documentation updates ensure that users have accurate information about the current state of rules_wasm_component functionality, particularly the recent fixes to WAC composition and Rust binding generation.
1 parent d172004 commit 3703d45

File tree

2 files changed

+57
-28
lines changed

2 files changed

+57
-28
lines changed

docs-site/src/content/docs/reference/rules.mdx

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,6 @@ rust_wasm_component(
227227

228228
Builds a Rust WebAssembly component with WIT binding generation. Compiles Rust source code into a WASM component and generates language bindings from WIT interfaces.
229229

230-
**Generated Targets:**
231-
- `{name}_bindings_host`: Native platform rust_library for native applications (e.g., test runners, benchmarks)
232-
- `{name}_bindings`: Guest component rust_library for WebAssembly components
233-
- `{name}`: The final guest component
234-
235-
> **📖 Deep Dive:** For detailed guidance on when to use native vs guest bindings, see [Native vs Guest Bindings Guide](/guides/host-vs-wasm-bindings/).
236-
237230
**Load from:**
238231
```python
239232
load("@rules_wasm_component//rust:defs.bzl", "rust_wasm_component_bindgen")
@@ -276,27 +269,6 @@ rust_wasm_component_bindgen(
276269
)
277270
```
278271

279-
#### Native applications using component bindings
280-
281-
When building native applications that need to use component bindings (e.g., for testing or benchmarking), use the `*_bindings_host` target:
282-
283-
```python
284-
rust_binary(
285-
name = "component_test_runner",
286-
srcs = ["tests/runner.rs"],
287-
deps = [":my_component_bindings_host"], # Native bindings for native app
288-
)
289-
290-
# The component implementation uses guest bindings automatically
291-
rust_wasm_component_bindgen(
292-
name = "my_component",
293-
srcs = ["src/lib.rs"], # Uses my_component_bindings (guest platform)
294-
wit = ":my_interfaces",
295-
)
296-
```
297-
298-
> **📖 Complete Guide:** See [Native vs Guest Bindings](/guides/host-vs-wasm-bindings/) for detailed examples and use cases.
299-
300272
### rust_wasm_component_test
301273

302274
Tests a Rust WASM component using wasmtime runtime. Provides automated testing for WebAssembly components.

tools/generate_schemas/comprehensive_schemas.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,22 @@ func generateComprehensiveSchemas() map[string]RuleSchema {
175175
srcs = ["calculator.go", "main.go"],
176176
go_mod = "go.mod",
177177
optimization = "release",
178+
)`},
179+
},
180+
},
181+
"go_wasm_component_test": {
182+
Name: "go_wasm_component_test",
183+
Type: "rule",
184+
Description: "Tests a Go WebAssembly component built with TinyGo. Performs comprehensive validation including component format verification, TinyGo-specific pattern checks, and WASI Preview 2 compatibility testing.",
185+
LoadFrom: "@rules_wasm_component//go:defs.bzl",
186+
Attributes: map[string]Attribute{
187+
"name": {"string", true, nil, "A unique name for this target", nil},
188+
"component": {"label", true, nil, "Go WASM component to test", nil},
189+
},
190+
Examples: []Example{
191+
{"Component testing", "Test a TinyGo WebAssembly component", `go_wasm_component_test(
192+
name = "calculator_component_test",
193+
component = ":calculator_component",
178194
)`},
179195
},
180196
},
@@ -388,6 +404,47 @@ go_wasm_component(
388404
)`},
389405
},
390406
},
407+
"wac_bundle": {
408+
Name: "wac_bundle",
409+
Type: "rule",
410+
Description: "Bundle WASM components without composition, suitable for WASI components. Collects multiple components into a single bundle directory without creating a composed component.",
411+
LoadFrom: "@rules_wasm_component//wac:defs.bzl",
412+
Attributes: map[string]Attribute{
413+
"name": {"string", true, nil, "A unique name for this target", nil},
414+
"components": {"label_keyed_string_dict", true, nil, "Map of component targets to their names in the bundle", nil},
415+
},
416+
Examples: []Example{
417+
{"Component bundle", "Bundle multiple WASI components", `wac_bundle(
418+
name = "service_bundle",
419+
components = {
420+
":auth_service": "auth",
421+
":data_service": "data",
422+
":api_service": "api",
423+
},
424+
)`},
425+
},
426+
},
427+
"wac_plug": {
428+
Name: "wac_plug",
429+
Type: "rule",
430+
Description: "Plug component exports into component imports using WAC. Automatically connects component exports to imports through WAC's plug functionality.",
431+
LoadFrom: "@rules_wasm_component//wac:defs.bzl",
432+
Attributes: map[string]Attribute{
433+
"name": {"string", true, nil, "A unique name for this target", nil},
434+
"socket": {"label", true, nil, "The socket component that imports functions", nil},
435+
"plugs": {"label_list", true, nil, "The plug components that export functions", nil},
436+
},
437+
Examples: []Example{
438+
{"Component plugging", "Connect exports to imports automatically", `wac_plug(
439+
name = "connected_app",
440+
socket = ":main_component",
441+
plugs = [
442+
":auth_plugin",
443+
":storage_plugin",
444+
],
445+
)`},
446+
},
447+
},
391448

392449
// ======================
393450
// WASM Component Tools

0 commit comments

Comments
 (0)