Skip to content

Commit f56d2cb

Browse files
authored
Merge pull request #237 from bytecodealliance/ydnar/tidy
all: tidy up documentation
2 parents 80d210d + befe787 commit f56d2cb

File tree

7 files changed

+50
-46
lines changed

7 files changed

+50
-46
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ Developing and testing this package requires an up-to-date installation of [Go](
1010

1111
Tests are supported under both Go and TinyGo, on Linux, macOS, and WebAssembly.
1212

13-
```sh
13+
```console
1414
go test ./...
1515
tinygo test ./...
1616
```
1717

1818
Testing with WebAssembly (`wasip1`) requires an installation of [`go_wasip1_wasm32_exec`](https://go.dev/blog/wasi) and [Wasmtime](https://wasmtime.dev). WASI 0.2 `wasip2` is supported under TinyGo version 0.33.0 or later.
1919

20-
```sh
20+
```console
2121
GOARCH=wasm GOOS=wasip1 go test ./...
2222
GOARCH=wasm GOOS=wasip1 tinygo test ./...
2323
tinygo test -target=wasip2 ./... # requires TinyGo 0.33.0 or later

README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
# go.bytecodealliance.org
22

3-
[![pkg.go.dev](https://img.shields.io/badge/docs-pkg.go.dev-blue.svg)](https://pkg.go.dev/go.bytecodealliance.org) [![build status](https://img.shields.io/github/actions/workflow/status/bytecodealliance/go-modules/test.yaml?branch=main)](https://github.com/bytecodealliance/go-modules/actions)
4-
3+
[WebAssembly](https://webassembly.org), [WASI](https://wasi.dev), and [Component Model](https://component-model.bytecodealliance.org/) modules for [Go](https://go.dev) and [TinyGo](https://tinygo.org).
54

6-
A monorepo of [WebAssembly](https://webassembly.org), [WASI](https://wasi.dev), and [Component Model](https://component-model.bytecodealliance.org/) modules for [Go](https://go.dev) and [TinyGo](https://tinygo.org).
5+
[![pkg.go.dev](https://img.shields.io/badge/docs-pkg.go.dev-blue.svg)](https://pkg.go.dev/go.bytecodealliance.org) [![build status](https://img.shields.io/github/actions/workflow/status/bytecodealliance/go-modules/test.yaml?branch=main)](https://github.com/bytecodealliance/go-modules/actions)
76

87
## About
98

10-
This repository contains code to generate Go bindings for [Component Model](https://component-model.bytecodealliance.org/) interfaces defined in [WIT](https://component-model.bytecodealliance.org/design/wit.html) (WebAssembly Interface Type) files. A goal of this project is to accelerate adoption of the Component Model and development of [WASI 0.2+](https://bytecodealliance.org/articles/WASI-0.2) in Go.
9+
Package `wit/bindgen` contains code to generate Go bindings for [Component Model](https://component-model.bytecodealliance.org/) interfaces defined in [WIT](https://component-model.bytecodealliance.org/design/wit.html) (WebAssembly Interface Type) files. A goal of this project is to accelerate adoption of the Component Model and development of [WASI 0.2+](https://bytecodealliance.org/articles/WASI-0.2) in Go.
1110

1211
### Component Model
1312

14-
Package [cm](./cm) contains helper types and functions used by generated packages, such as `option<t>`, `result<ok, err>`, `variant`, `list`, and `resource`. These are intended for use by generated [Component Model](https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md#type-definitions) bindings, where the caller converts to a Go equivalent. It attempts to map WIT semantics to their equivalent in Go where possible.
13+
Package `cm` contains helper types and functions used by generated packages, such as `option<t>`, `result<ok, err>`, `variant`, `list`, and `resource`. These are intended for use by generated [Component Model](https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md#type-definitions) bindings, where the caller converts to a Go equivalent. It attempts to map WIT semantics to their equivalent in Go where possible.
1514

1615
#### Note on Memory Safety
1716

@@ -23,41 +22,41 @@ Package `cm` and generated bindings from `wit-bindgen-go` may have compatibility
2322

2423
The `wit-bindgen-go` tool can generate Go bindings for WIT interfaces and worlds. If [`wasm-tools`](https://crates.io/crates/wasm-tools) is installed and in `$PATH`, then `wit-bindgen-go` can load WIT directly.
2524

26-
```sh
25+
```console
2726
wit-bindgen-go generate ../wasi-cli/wit
2827
```
2928

3029
Otherwise, pass the JSON representation of a fully-resolved WIT package:
3130

32-
```sh
31+
```console
3332
wit-bindgen-go generate wasi-cli.wit.json
3433
```
3534

3635
Or pipe via `stdin`:
3736

38-
```sh
37+
```console
3938
wasm-tools component wit -j --all-features ../wasi-cli/wit | wit-bindgen-go generate
4039
```
4140

4241
### JSON → WIT
4342

4443
For debugging purposes, `wit-bindgen-go` can also convert a JSON representation back into WIT. This is useful for validating that the intermediate representation faithfully represents the original WIT source.
4544

46-
```sh
45+
```console
4746
wit-bindgen-go wit example.wit.json
4847
```
4948

5049
### WIT → JSON
5150

52-
The [wit](./wit) package can decode a JSON representation of a fully-resolved WIT file. Serializing WIT into JSON requires [wasm-tools](https://crates.io/crates/wasm-tools) v1.210.0 or higher. To convert a WIT file into JSON, run `wasm-tools` with the `-j` argument:
51+
Package `wit` can decode a JSON representation of a fully-resolved WIT file. Serializing WIT into JSON requires [wasm-tools](https://crates.io/crates/wasm-tools) v1.210.0 or higher. To convert a WIT file into JSON, run `wasm-tools` with the `-j` argument:
5352

54-
```sh
53+
```console
5554
wasm-tools component wit -j --all-features example.wit
5655
```
5756

5857
This will emit JSON on `stdout`, which can be piped to a file or another program.
5958

60-
```sh
59+
```console
6160
wasm-tools component wit -j --all-features example.wit > example.wit.json
6261
```
6362

RELEASE.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22

33
This document describes the steps to release a new version of the `wit-bindgen-go` CLI.
44

5-
## 1. Update the [CHANGELOG.md](./CHANGELOG.md)
5+
## 1. Update [CHANGELOG.md](./CHANGELOG.md)
66

7-
* Add the latest changes to CHANGELOG.md.
8-
* Rename the Unreleased section to reflect the new version number.
9-
* Update the links to new version tag in the footer of CHANGELOG.md
10-
* Submit a pull request (PR) with these updates.
7+
1. Add the latest changes to [CHANGELOG.md](./CHANGELOG.md).
8+
1. Rename the Unreleased section to reflect the new version number.
9+
1. Update the links to new version tag in the footer of CHANGELOG.md
10+
1. Add today’s date (YYYY-MM-DD) after an em dash (—).
11+
1. Submit a [GitHub Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) with these updates.
1112

1213
## 2. Create a new release
1314

1415
Once the PR is merged, tag the new version in Git and push the tag to GitHub.
1516

1617
For example, to tag version `v0.3.0`:
1718

18-
```sh
19+
```console
1920
git tag v0.3.0
2021
git push origin v0.3.0
2122
```

cm/docs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Package cm contains types and functions for interfacing with the WebAssembly Component Model.
1+
// Package cm provides types and functions for interfacing with the WebAssembly Component Model.
22
//
33
// The types in this package (such as [List], [Option], [Result], and [Variant]) are designed to match the memory layout
44
// of [Component Model] types as specified in the [Canonical ABI].

wit/docs.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
// Package wit contains a Go representation of the WIT ([WebAssembly Interface Type])
2-
// specification as defined in the [WebAssembly Component Model].
1+
// Package wit contains a Go representation of the WIT (WebAssembly Interface Type) specification.
2+
//
3+
// # WIT
4+
//
5+
// WIT ([WebAssembly Interface Type]) is an interface definition language with rich types, functions, and methods,
6+
// used to define the interface of a [Component].
7+
//
8+
// Note: this package depends on the [wasm-tools] exectuable to parse WIT into an intermediary JSON representation.
39
//
410
// # Structure
511
//
@@ -29,9 +35,9 @@
2935
//
3036
// // Do something with res
3137
//
32-
// [WebAssembly Interface Type]: https://component-model.bytecodealliance.org/design/wit.html
33-
// [WebAssembly Component Model]: https://component-model.bytecodealliance.org/introduction.html
3438
// [wit-parser]: https://docs.rs/wit-parser/latest/wit_parser/
3539
// [source]: https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wit-parser
3640
// [wasm-tools]: https://crates.io/crates/wasm-tools
41+
// [WebAssembly Interface Type]: https://component-model.bytecodealliance.org/design/wit.html
42+
// [Component]: https://component-model.bytecodealliance.org/introduction.html
3743
package wit

x/cabi/README.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

x/cabi/docs.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Package cabi contains a single WebAssembly function exported as cabi_realloc.
2+
//
3+
// To use, import this package with _:
4+
//
5+
// import _ "go.bytecodealliance.org/x/cabi"
6+
//
7+
// Function realloc is a WebAssembly [core function] that is validated to have the following core function type:
8+
//
9+
// (func (param $originalPtr i32)
10+
// (param $originalSize i32)
11+
// (param $alignment i32)
12+
// (param $newSize i32)
13+
// (result i32))
14+
//
15+
// The [Canonical ABI] will use realloc both to allocate (passing 0 for the first two parameters) and reallocate. If the Canonical ABI needs realloc, validation requires this option to be present (there is no default).
16+
//
17+
// [core function]: https://www.w3.org/TR/wasm-core-2/syntax/modules.html#functions
18+
// [Canonical ABI]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md
19+
package cabi

0 commit comments

Comments
 (0)