Skip to content

Commit

Permalink
fix: code style inconsistency (#10)
Browse files Browse the repository at this point in the history
- Fix a problem causing code collapsible not rendering code in spec.md.
- Update tab width to be equal to 4 from 8 in custom.css.
- Fix a tab-space mix up problem in usage.md.
- Removed redundant API spec in watm.md where all the content can be found on go.dev.

Signed-off-by: Gaukas Wang <[email protected]>
  • Loading branch information
gaukas authored Mar 13, 2024
1 parent 49cf319 commit 32f1773
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 60 deletions.
7 changes: 7 additions & 0 deletions _sass/custom/custom.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// custom SCSS (or CSS) goes here
pre
{
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
}
2 changes: 1 addition & 1 deletion runtime/go/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ as well.

```go
import (
"github.com/refraction-networking/water"
"github.com/refraction-networking/water"
_ "github.com/refraction-networking/water/transport/v0" // import the v0 transport module spec
)
```
Expand Down
43 changes: 0 additions & 43 deletions transport-module/go/watm.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,49 +20,6 @@ Currently, `watm` is still under active development and supports only TinyGo as

The `tinygo/v0` package provides a set of helper functions to build WATM with spec version 0 from WebAssembly-agnostic Go code. It is designed to be used with TinyGo.

<!-- TODO: Add documentations to API Reference? -->
<details>
<summary>API Reference</summary>

```go
type RelayWrapSelection bool

const (
RelayWrapRemote RelayWrapSelection = false
RelayWrapSource RelayWrapSelection = true
)

type ConfigurableTransport interface {
Configure([]byte) error
}

type DialingTransport interface {
SetDialer(dialer func(network, address string) (v0net.Conn, error))
Dial(network, address string) (v0net.Conn, error)
}


type ListeningTransport interface {
SetListener(listener v0net.Listener)
Accept() (v0net.Conn, error)
}

type WrappingTransport interface {
Wrap(v0net.Conn) (v0net.Conn, error)
}

func BuildDialerWithDialingTransport(DialingTransport)
func BuildDialerWithWrappingTransport(WrappingTransport)

func BuildListenerWithListeningTransport(ListeningTransport)
func BuildListenerWithWrappingTransport(WrappingTransport)

func BuildRelayWithListeningDialingTransport(ListeningTransport, DialingTransport)
func BuildRelayWithWrappingTransport(WrappingTransport, RelayWrapSelection)
```

</details>

### `tinygo/v0/net` package

[![Go Reference](https://pkg.go.dev/badge/github.com/refraction-networking/watm.svg)](https://pkg.go.dev/github.com/refraction-networking/watm/tinygo/v0/net)
Expand Down
49 changes: 33 additions & 16 deletions transport-module/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ To help developers understand the API, we provide the following representations

<details>
<summary>Imports</summary>

```go
//go:wasmimport env host_dial

<div class="highlighter-rouge">
<div class="highlight">
<pre class="highlight">
<code>//go:wasmimport env host_dial
//go:noescape
func _import_host_dial() (fd int32)

Expand All @@ -62,15 +64,19 @@ func _import_pull_config() (fd int32)

//go:wasmimport env host_defer
//go:noescape
func _import_host_defer()
```
func _import_host_defer()</code>
</pre>
</div>
</div>
</details>

<details>
<summary>Exports</summary>

```go
//export _water_v0
<div class="highlighter-rouge">
<div class="highlight">
<pre class="highlight">
<code>//export _water_v0
func _water_v0()

//export _water_init
Expand All @@ -89,8 +95,10 @@ func _water_accept(internalFd int32) (networkFd int32)
func _water_associate() int32

//export _water_worker
func _water_worker() int32
```
func _water_worker() int32</code>
</pre>
</div>
</div>
</details>

### Rust representation
Expand All @@ -104,8 +112,10 @@ _Note that the following is a simplified example and may not strictly follow the
<details>
<summary>Imports</summary>

```wit
// imports.wit
<div class="highlighter-rouge">
<div class="highlight">
<pre class="highlight">
<code>// imports.wit
package env;

interface host {
Expand All @@ -117,14 +127,19 @@ interface host {

world host-world {
import host;
}
```
}</code>
</pre>
</div>
</div>
</details>

<details>
<summary>Exports</summary>

```wit
<div class="highlighter-rouge">
<div class="highlight">
<pre class="highlight">
<code>
// exports.wit
interface wasm {
_water_v0: func(); // version 0 identifier
Expand All @@ -138,6 +153,8 @@ interface wasm {

world wasm-world {
export wasm;
}
```
}</code>
</pre>
</div>
</div>
</details>

0 comments on commit 32f1773

Please sign in to comment.