Skip to content

Commit 4ba08c3

Browse files
authored
Merge pull request #149 from rajsite/consistent-note-format
Switch to a consistent note format and code snippet indentation level
2 parents 2fc277b + a9ae52a commit 4ba08c3

File tree

13 files changed

+215
-211
lines changed

13 files changed

+215
-211
lines changed

component-model/src/advanced/canonical-abi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ An ABI is an **application binary interface** - an agreement on how to pass data
44

55
The component model defines a **canonical ABI** - an ABI to which all [components](../design/components.md) adhere. This guarantees that components can talk to each other without confusion, even if they are built in different languages. Internally, a C component might represent strings in a quite different way from a Rust component, but the canonical ABI provides a format for them to pass strings across the boundary between them.
66

7-
> For a more formal definition of what the Canonical ABI is, take a look at the [Canonical ABI explainer](https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md).
7+
> For a more formal definition of what the Canonical ABI is, take a look at the [Canonical ABI explainer](https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md).

component-model/src/design/components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
The external interface of a component - its imports and exports - corresponds to a [world](./worlds.md). The component, however, internally defines how that world is implemented.
88

9-
> For a more formal definition of what a component is, take a look at the [Component Model specification](https://github.com/WebAssembly/component-model).
9+
> For a more formal definition of what a component is, take a look at the [Component Model specification](https://github.com/WebAssembly/component-model).

component-model/src/design/interfaces.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ An **interface** describes a single-focus, composable contract, through which co
77

88
Interfaces are defined using [the WIT language](./wit.md).
99

10-
> For a more formal definition of what an interface is, take a look at the [WIT specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md).
10+
> For a more formal definition of what an interface is, take a look at the [WIT specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md).

component-model/src/design/packages.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ A WIT package is not a [world](./worlds.md). It's a way of grouping related inte
66

77
* The WebAssembly System Interface (WASI) defines a number of packages, including one named `wasi:clocks`. Our HTTP proxy world could import the `wall-clock` interface from the `wasi:clocks` package, rather than having to define a custom clock interface.
88

9-
> For a more formal definition of what a WIT package is, take a look at the [WIT specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md).
9+
> For a more formal definition of what a WIT package is, take a look at the [WIT specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md).

component-model/src/design/why-component-model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ Moreover, a component interacts with a runtime or other components _only_ by cal
1616

1717
Now that you have a better idea about how the component model can help you, take a look at [how to build components](../language-support.md) in your favorite language!
1818

19-
> For more background on why the component model was created, take a look at the specification's [goals](https://github.com/WebAssembly/component-model/blob/main/design/high-level/Goals.md), [use cases](https://github.com/WebAssembly/component-model/blob/main/design/high-level/UseCases.md) and [design choices](https://github.com/WebAssembly/component-model/blob/main/design/high-level/Choices.md).
19+
> For more background on why the component model was created, take a look at the specification's [goals](https://github.com/WebAssembly/component-model/blob/main/design/high-level/Goals.md), [use cases](https://github.com/WebAssembly/component-model/blob/main/design/high-level/UseCases.md) and [design choices](https://github.com/WebAssembly/component-model/blob/main/design/high-level/Choices.md).

component-model/src/design/wit.md

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -91,29 +91,29 @@ WIT defines the following primitive types:
9191

9292
| Identifier | Description |
9393
|----------------------------|-------------|
94-
| `bool` | Boolean value - true or false. |
95-
| `s8`, `s16`, `s32`, `s64` | Signed integers of the appropriate width. For example, `s32` is a 32-bit integer. |
96-
| `u8`, `u16`, `u32`, `u64` | Unsigned integers of the appropriate width. For example, `u32` is a 32-bit integer. |
97-
| `f32`, `f64` | Floating-point numbers of the appropriate width. For example, `f64` is a 64-bit (double precision) floating-point number. See the note on NaNs below. |
94+
| `bool` | Boolean value `true` or `false`. |
95+
| `s8`, `s16`, `s32`, `s64` | Signed integers of the appropriate width. For example, `s32` is a signed 32-bit integer. |
96+
| `u8`, `u16`, `u32`, `u64` | Unsigned integers of the appropriate width. For example, `u32` is an unsigned 32-bit integer. |
97+
| `f32`, `f64` | Floating-point numbers of the appropriate width. For example, `f64` is a 64-bit (double precision) floating-point number. See the note on `NaN`s below. |
9898
| `char` | Unicode character. (Specifically, a [Unicode scalar value](https://unicode.org/glossary/#unicode_scalar_value).) |
9999
| `string` | A Unicode string - that is, a finite sequence of characters. |
100100

101-
The `f32` and `f64` types support the usual set of IEEE 754 single and double-precision values, except that they logically only have a single NaN value. The exact bit-level representation of a NaN is not guaranteed to be preserved when values pass through WIT interfaces.
101+
> The `f32` and `f64` types support the usual set of IEEE 754 single and double-precision values, except that they logically only have a single `nan` value. The exact bit-level representation of an IEEE 754 `NaN` is not guaranteed to be preserved when values pass through WIT interfaces as the singular WIT `nan` value.
102102
103103
### Lists
104104

105-
`list<T>` for any type T denotes an ordered sequence of values of type T. T can be any type, built-in or user-defined:
105+
`list<T>` for any type `T` denotes an ordered sequence of values of type `T`. `T` can be any type, built-in or user-defined:
106106

107107
```wit
108-
list<u8> // byte buffer
109-
list<customer> // a list of customers
108+
list<u8> // byte buffer
109+
list<customer> // a list of customers
110110
```
111111

112112
This is similar to Rust `Vec`, or Java `List`.
113113

114114
### Options
115115

116-
`option<T>` for any type T may contain a value of type T, or may contain no value. T can be any type, built-in or user-defined. For example, a lookup function might return an option, allowing for the possibility that the lookup key wasn't found:
116+
`option<T>` for any type `T` may contain a value of type `T`, or may contain no value. `T` can be any type, built-in or user-defined. For example, a lookup function might return an option, allowing for the possibility that the lookup key wasn't found:
117117

118118
```wit
119119
option<customer>
@@ -125,7 +125,7 @@ This is similar to Rust `Option`, C++ `std::optional`, or Haskell `Maybe`.
125125
126126
### Results
127127

128-
`result<T, E>` for any types T and E may contain a value of type T _or_ a value of type E (but not both). This is typically used for "value or error" situations; for example, a HTTP request function might return a result, with the success case (the T type) representing a HTTP response, and the error case (the E type) representing the various kinds of error that might occur:
128+
`result<T, E>` for any types `T` and `E `may contain a value of type `T` _or_ a value of type `E` (but not both). This is typically used for "value or error" situations; for example, a HTTP request function might return a result, with the success case (the `T` type) representing a HTTP response, and the error case (the `E` type) representing the various kinds of error that might occur:
129129

130130
```wit
131131
result<http-response, http-error>
@@ -145,11 +145,11 @@ result // no data associated with either case
145145

146146
### Tuples
147147

148-
A tuple type is an ordered _fixed length_ sequence of values of specified types. It is similar to a [_record_](#records), except that the fields are identified by their order instead of by names.
148+
A `tuple` type is an ordered _fixed length_ sequence of values of specified types. It is similar to a [_record_](#records), except that the fields are identified by their order instead of by names.
149149

150150
```wit
151-
tuple<u64, string> // An integer and a string
152-
tuple<u64, string, u64> // An integer, then a string, then an integer
151+
tuple<u64, string> // An integer and a string
152+
tuple<u64, string, u64> // An integer, then a string, then an integer
153153
```
154154

155155
This is similar to tuples in Rust or OCaml.
@@ -160,7 +160,7 @@ You can define your own types within an `interface` or `world`. WIT offers sever
160160

161161
### Records
162162

163-
A record type declares a set of named fields, each of the form `name: type`, separated by commas. A record instance contains a value for every field. Field types can be built-in or user-defined. The syntax is as follows:
163+
A `record` type declares a set of named fields, each of the form `name: type`, separated by commas. A record instance contains a value for every field. Field types can be built-in or user-defined. The syntax is as follows:
164164

165165
```wit
166166
record customer {
@@ -177,7 +177,7 @@ Records are similar to C or Rust `struct`s.
177177
178178
### Variants
179179

180-
A variant type declares one or more cases. Each case has a name and, optionally, a type of data associated with that case. A variant instance contains exactly one case. Cases are separated by commas. The syntax is as follows:
180+
A `variant` type declares one or more cases. Each case has a name and, optionally, a type of data associated with that case. A variant instance contains exactly one case. Cases are separated by commas. The syntax is as follows:
181181

182182
```wit
183183
variant allowed-destinations {
@@ -193,7 +193,7 @@ Variants are similar to Rust `enum`s or OCaml discriminated unions. The closest
193193
194194
### Enums
195195

196-
An enum type is a variant type where none of the cases have associated data:
196+
An `enum` type is a variant type where none of the cases have associated data:
197197

198198
```wit
199199
enum color {
@@ -203,7 +203,7 @@ enum color {
203203
}
204204
```
205205

206-
This can provide a simpler representation in languages without discriminated unions. For example, a WIT enum can translate directly to a C++ `enum`.
206+
This can provide a simpler representation in languages without discriminated unions. For example, a WIT `enum` can translate directly to a C++ `enum`.
207207

208208
### Resources
209209

@@ -248,18 +248,16 @@ blob-read: func(self: borrow<blob>, n: u32) -> list<u8>;
248248
blob-merge: static func(lhs: blob, rhs: blob) -> blob;
249249
```
250250

251-
When a resource type name is wrapped with `borrow<...>`, it stands for a
251+
When a `resource` type name is wrapped with `borrow<...>`, it stands for a
252252
"borrowed" resource. A borrowed resource represents a temporary loan of a resource from the
253253
caller to the callee for the duration of the call. In contrast, when the owner
254254
of an owned resource drops that resource, the resource is destroyed.
255255

256-
> Note: more precisely, these are borrowed or owned `handles` of the resource.
257-
> Learn more about `handles` in the [upstream component model
258-
> specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md#handles).
256+
> More precisely, these are borrowed or owned `handles` of the resource. Learn more about `handles` in the [upstream component model specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md#handles).
259257
260258
### Flags
261259

262-
A flags type is a set of named booleans. In an instance of the type, each flag will be either true or false.
260+
A `flags` type is a set of named booleans. In an instance of the type, each flag will be either `true` or `false`.
263261

264262
```wit
265263
flags allowed-methods {
@@ -270,7 +268,7 @@ flags allowed-methods {
270268
}
271269
```
272270

273-
> A flags type is logically equivalent to a record type where each field is of type `bool`, but it is represented more efficiently (as a bitfield) at the binary level.
271+
> A `flags` type is logically equivalent to a record type where each field is of type `bool`, but it is represented more efficiently (as a bitfield) at the binary level.
274272
275273
### Type aliases
276274

@@ -292,10 +290,10 @@ do-nothing: func();
292290
The function type is the word `func`, followed by a parenthesised, comma-separated list of parameters (names and types). If the function returns a value, this is expressed as an arrow symbol (`->`) followed by the return type:
293291

294292
```wit
295-
/// This function does not return a value
293+
// This function does not return a value
296294
print: func(message: string);
297295
298-
/// These functions return values
296+
// These functions return values
299297
add: func(a: u64, b: u64) -> u64;
300298
lookup: func(store: kv-store, key: string) -> option<string>;
301299
```
@@ -365,11 +363,13 @@ interface error-reporter {
365363
}
366364
367365
world multi-function-device {
368-
/// The component implements the `printer` interface
366+
// The component implements the `printer` interface
369367
export printer;
370-
/// The component implements the `scan` function
368+
369+
// The component implements the `scan` function
371370
export scan: func() -> list<u8>;
372-
/// The component needs to be supplied with an `error-reporter`
371+
372+
// The component needs to be supplied with an `error-reporter`
373373
import error-reporter;
374374
}
375375
```
@@ -407,8 +407,10 @@ You can `include` another world. This causes your world to export all that world
407407

408408
```wit
409409
world glow-in-the-dark-multi-function-device {
410-
// The component provides all the same exports, and depends on all the same imports, as a `multi-function-device`...
410+
// The component provides all the same exports, and depends on
411+
// all the same imports, as a `multi-function-device`...
411412
include multi-function-device;
413+
412414
// ...but also exports a function to make it glow in the dark
413415
export glow: func(brightness: u8);
414416
}
@@ -455,4 +457,4 @@ world proxy {
455457
}
456458
```
457459

458-
> For a more formal definition of the WIT language, take a look at the [WIT specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md).
460+
> For a more formal definition of the WIT language, take a look at the [WIT specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md).

component-model/src/design/worlds.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ For a component to run, its imports must be fulfilled, by a host or by other com
1717
* A (trivial) "HTTP proxy" world would export a "handle HTTP requests" interface, and import a "send HTTP requests" interface. A host, or another component, would call the exported "handle" interface, passing an HTTP request; the component would forward it on via the imported "send" interface. To be a _useful_ proxy, the component may also need to import interfaces such as I/O and clock time - without those imports the component could not perform, for example, on-disk caching.
1818
* A "regex parser" world would export a "parse regex" function, and would import nothing. This declares not only that the component implementing this world can parse regular expressions, but also that it calls no other APIs. A user of such a parser could know, without looking at the implementation, that is does not access the file system, or send the user's regexes to a network service.
1919

20-
> For a more formal definition of what a WIT world is, take a look at the [WIT world specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md#wit-worlds).
20+
> For a more formal definition of what a WIT world is, take a look at the [WIT world specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md#wit-worlds).

component-model/src/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The WebAssembly Component Model is a broad-reaching architecture for building in
2525
[Running]: ./creating-and-consuming/running.md
2626
[Distributing]: ./creating-and-consuming/distributing.md
2727

28-
> This documentation is aimed at _users_ of the component model: developers of libraries and applications. _Compiler and Wasm runtime developers_ can take a look at the [Component Model specification](https://github.com/WebAssembly/component-model) to see how to add support for the component model to their project.
28+
> This documentation is aimed at _users_ of the component model: developers of libraries and applications. _Compiler and Wasm runtime developers_ can take a look at the [Component Model specification](https://github.com/WebAssembly/component-model) to see how to add support for the component model to their project.
2929
3030
## Status
3131

component-model/src/language-support.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
WebAssembly can be targeted by the majority of top programming
44
languages; however, the level of
55
support varies. This document details the subset of languages that target WASI and support
6-
components. This is a living document, so if you are aware of advancements in a toolchain, please do
7-
not hesitate to [contribute documentation](https://github.com/bytecodealliance/component-docs/blob/main/CONTRIBUTING.md). You can find more information about the development of support for specific languages [here](https://github.com/bytecodealliance/governance/blob/main/SIGs/SIG-guest-languages/proposal.md). Each section covers how to build and
8-
run components for a given toolchain.
6+
components.
7+
8+
> This is a living document, so if you are aware of advancements in a toolchain, please do
9+
not hesitate to [contribute documentation](https://github.com/bytecodealliance/component-docs/blob/main/CONTRIBUTING.md). You can find more information about the development of support for specific languages in the [Guest Languages Special Interest Group Proposal](https://github.com/bytecodealliance/governance/blob/main/SIGs/SIG-guest-languages/proposal.md) document.
910

1011
One of the benefits of components is their portability across host runtimes. The runtime only needs
1112
to know what world the component is targeting in order to import or execute the component. This
@@ -16,6 +17,9 @@ toolchain section walks through creating a component of this world, which can be
1617
example host or from an application of that toolchain. This aims to provide a full story for using
1718
components within and among toolchains.
1819

20+
Each section covers how to build and
21+
run components for a given toolchain:
22+
1923
- [Wasm Language Support](#wasm-language-support)
2024
- [Language Agnostic Tooling](#language-agnostic-tooling)
2125
- [Building a Component with `wasm-tools`](#building-a-component-with-wasm-tools)

component-model/src/language-support/c.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Now, you can compile the function into a Wasm module via clang:
3535
clang add.c example.c example_component_type.o -o add-core.wasm -mexec-model=reactor
3636
```
3737

38-
> Note: Use the `clang` included in the WASI SDK installation, for example at `<WASI_SDK_PATH>/bin/clang`.
38+
> Use the `clang` included in the WASI SDK installation, for example at `<WASI_SDK_PATH>/bin/clang`.
3939
4040
Next, you need to transform the module into a component. For this example, you can use `wasm-tools component new`:
4141
```sh

0 commit comments

Comments
 (0)