Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a deps directory example.
Add an example dependency using a `deps` directory. And rename some
things for clarity.
  • Loading branch information
sunfishcode committed Feb 18, 2023
commit 7a310790a0f5350ab6347f91490d0c8e722128f4
30 changes: 21 additions & 9 deletions wasi-proposal-template.md → example-world.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
<h1><a name="wasi_proposal_template">World wasi-proposal-template</a></h1>
<h1><a name="example_world">World example-world</a></h1>
<ul>
<li>Imports:
<ul>
<li>interface <a href="#proposal_interface_name"><code>proposal-interface-name</code></a></li>
<li>interface <a href="#example_dep_interface"><code>example-dep-interface</code></a></li>
<li>interface <a href="#example_interface"><code>example-interface</code></a></li>
</ul>
</li>
</ul>
<h2><a name="proposal_interface_name">Import interface proposal-interface-name</a></h2>
<h2><a name="example_dep_interface">Import interface example-dep-interface</a></h2>
<hr />
<h3>Types</h3>
<h4><a name="example_dep_type"><code>type example-dep-type</code></a></h4>
<p><code>u32</code></p>
<p>
## <a name="example_interface">Import interface example-interface</a>
<p>Short interface description.</p>
<p>Explanation for developers using the interface API. It should include an
overview of the API as a whole as well as call out notable items in it,
for example <a href="#example_api_type"><code>example-api-type</code></a> and <a href="#example_api_function"><code>example-api-function</code></a>.</p>
<hr />
<h3>Types</h3>
<h4><a name="example_api_type"><code>record example-api-type</code></a></h4>
<h4><a name="example_dep_type"><code>type example-dep-type</code></a></h4>
<p><a href="#example_dep_type"><a href="#example_dep_type"><code>example-dep-type</code></a></a></p>
<p>
#### <a name="example_api_type">`record example-api-type`</a>
<p>Short type description</p>
<p>Explanation for developers using this type. It may be useful to give
some examples of places in the API where the type is used, such as in
Expand All @@ -28,20 +38,21 @@ of precise behavior here.
<h5>Record Fields</h5>
<ul>
<li>
<p><a name="example_api_type.property0"><code>property0</code></a>: <code>u64</code></p>
<p>A description of a property.
<p><a name="example_api_type.field0"><code>field0</code></a>: <code>u64</code></p>
<p>A description of a field.
</li>
<li>
<p><a name="example_api_type.property1"><code>property1</code></a>: <code>string</code></p>
<p>A description of another property.
<p><a name="example_api_type.field1"><code>field1</code></a>: <code>string</code></p>
<p>A description of another field.
</li>
</ul>
<hr />
<h3>Functions</h3>
<h4><a name="example_api_function"><code>example-api-function: func</code></a></h4>
<p>Short function description</p>
<p>Explanation for developers using the API. This should describe the
arguments which in this function are <code>arg0</code> and <code>arg1</code> and the return value.</p>
arguments which in this function are <code>arg0</code>, <code>arg1</code>, and <code>arg2</code>, and the
return value.</p>
<details>
<summary>Detailed specification</summary>
Similar to the details section above, this is meant for more rigorous
Expand All @@ -53,6 +64,7 @@ later call, for example.
<ul>
<li><a name="example_api_function.arg0"><code>arg0</code></a>: <a href="#example_api_type"><a href="#example_api_type"><code>example-api-type</code></a></a></li>
<li><a name="example_api_function.arg1"><code>arg1</code></a>: <code>string</code></li>
<li><a name="example_api_function.arg2"><code>arg2</code></a>: <a href="#example_dep_type"><a href="#example_dep_type"><code>example-dep-type</code></a></a></li>
</ul>
<h5>Return values</h5>
<ul>
Expand Down
6 changes: 6 additions & 0 deletions wit/deps/example-dep/example-api.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// An example dependency, showing how these look. Actual proposals should
// delete this file and add their actual dependencies in the `deps` directory.

interface example-dep-interface {
type example-dep-type = u32
}
21 changes: 14 additions & 7 deletions wit/wasi-proposal-template.wit → wit/example.wit
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
/// Explanation for developers using the interface API. It should include an
/// overview of the API as a whole as well as call out notable items in it,
/// for example `example-api-type` and `example-api-function`.
default interface proposal-interface-name {
default interface example-interface {
use example-dep.example-api.example-dep-interface.{example-dep-type}

/// Short type description
///
/// Explanation for developers using this type. It may be useful to give
Expand All @@ -30,16 +32,17 @@ default interface proposal-interface-name {
/// of precise behavior here.
/// </details>
record example-api-type {
/// A description of a property.
property0: u64,
/// A description of another property.
property1: string,
/// A description of a field.
field0: u64,
/// A description of another field.
field1: string,
}

/// Short function description
///
/// Explanation for developers using the API. This should describe the
/// arguments which in this function are `arg0` and `arg1` and the return value.
/// arguments which in this function are `arg0`, `arg1`, and `arg2`, and the
/// return value.
///
/// <details>
/// <summary>Detailed specification</summary>
Expand All @@ -48,5 +51,9 @@ default interface proposal-interface-name {
/// implementation MUST do, such as never returning an earlier result from a
/// later call, for example.
/// </details>
example-api-function: func(arg0: example-api-type, arg1: string) -> result<example-api-type>
example-api-function: func(
arg0: example-api-type,
arg1: string,
arg2: example-dep-type,
) -> result<example-api-type>
}
4 changes: 2 additions & 2 deletions wit/world.wit
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
// Proposals should remove these `//` commments, and edit the `world` name and
// imports below to pull in their own `interface`s.

default world wasi-proposal-template {
import proposal-interface-name: pkg.wasi-proposal-template.proposal-interface-name
default world example-world {
import example-interface: pkg.example.example-interface
}