The Wayback Machine - https://web.archive.org/web/20210419012749/https://github.com/bytecodealliance/wasmtime/issues/1272
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filling out missing Introductory Documentation #1272

Open
alexcrichton opened this issue Mar 10, 2020 · 7 comments
Open

Filling out missing Introductory Documentation #1272

alexcrichton opened this issue Mar 10, 2020 · 7 comments

Comments

@alexcrichton
Copy link
Member

@alexcrichton alexcrichton commented Mar 10, 2020

I'd like to use this issue as a tracking issue for filling out gaps in wasmtime's introductory documentation. This includes our book (rendered), API documentation (rendered), and examples. (or anything else others can think of as well!)

Below I'm gonna fill out a bunch of checkmarks and checkboxes for what is currently missing at this time. If you'd like to help in and document things, please feel free to do so! If you leave a comment on this issue along with what you'd like to help fill in, we'll edit your name into the description here to know that it's claimed. Any and all help here is greatly appreciated!

Book Documentation

As a precursor I'll say that this is organized largely page-by-page in the book. The current organization of the book was an initial proposal from awhile ago and thinking back on it some of it may be a little redundant. Please feel free to also discuss the layout of the book and what documentation would best go where!

API Documentation

  • The crate documentation feels lacking and could use a broad example to introduce the crate.
  • The Module type should have at least one example somewhere.
  • The Instance type should have at least one example.
  • The Store type needs more documentation about what it is, although this is somewhat up for debate in other issues as well.
  • The Memory type needs examples of safe usage, and double-checks on wording about unsafe usage.
  • The Func type could use an example on the get family of methods.
  • Types which correspond to the wasm specification should link there where possible.

Examples

I think we want an overhaul of how our examples work. Here's my proposal for what we need to do:

  • Move Rust examples to a top-level examples directory - @alexcrichton
  • Move C examples to the top-level examples directory too - @alexcrichton
  • Every example has a comment at the top of the file of how to build and run it - @alexcrichton
    • Rust is typically cargo run --example foo
    • C is gcc examples/foo.c -I crates/c-api/include -o foo && ./foo (ish)
  • Wasm files are never checked in for examples - @alexcrichton
    • Either wasm is written inline as a *.wat string
    • Or example is structured as examples/name/main.rs with a corresponding examples/name/wasm/Cargo.toml which is a Rust project compiled to wasm. (or examples/name/wasm.c if we want to show off a C-compiled wasm example)
  • Every example is available in both Rust and C - @alexcrichton
    • For examples/foo.rs we have a corresponding examples/foo.c
    • For examples/foo/main.rs we have a corresponding examples/foo/main.c
  • Example showing how to link in the WASI functions
  • Example of reading a string from a wasm module
  • Example of a string processor, for example a markdown renderer
  • All examples are compiled and run on CI, regardless of language, on our three main platforms. - @alexcrichton
@ifennna
Copy link
Contributor

@ifennna ifennna commented Mar 10, 2020

I could take a stab at this: "Step-by-step tutorial to create and run hello-world.wasm"

@alexcrichton
Copy link
Member Author

@alexcrichton alexcrichton commented Mar 10, 2020

I'm working on a number of the examples bullets, mostly around organizing them and bringing C on par with Rust. Also CI!

@sunfishcode
Copy link
Member

@sunfishcode sunfishcode commented Mar 11, 2020

I'll write some content for the Sandboxing section.

alexcrichton added a commit to alexcrichton/wasmtime that referenced this issue Mar 12, 2020
alexcrichton added a commit that referenced this issue Mar 12, 2020
* Fill out API docs on `wasmtime::Module`

Part of #1272

* Apply suggestions from code review

Co-Authored-By: Nick Fitzgerald <fitzgen@gmail.com>

Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
@jjsullivan5196
Copy link
Contributor

@jjsullivan5196 jjsullivan5196 commented Mar 13, 2020

I can work on getting the python examples illustrated in the documentation. I think the demo video on the wasmtime home page is pretty comprehensive, so I'll probably just add some more details for project setup with pipenv and the like https://youtu.be/Qn_4F3foB3Q @alexcrichton do you think this is a good approach?

Also just saw #677, do you think I can still document the python support as of v0.12.0, or should I wait until interface types are more stable? The issue makes it seem like the interface shouldn't change much for module users.

@alexcrichton
Copy link
Member Author

@alexcrichton alexcrichton commented Mar 13, 2020

@jjsullivan5196 sounds great to me! I do think we should still at least document what we have which should work well for integers and such, but yeah the exact video won't work any more because strings are no longer supported.

@humancalico
Copy link

@humancalico humancalico commented Mar 15, 2020

@alexcrichton I'll write the markdown parser for the book

abrown added a commit to abrown/wasmtime that referenced this issue Mar 18, 2020
* Bitcast vectors immediately before a return

* Bitcast vectors immediately before a block end

* Use helper function for bitcasting arguments

* Add FuncTranslationState::peekn_mut; allows mutating of peeked values

* Bitcast values in place, avoiding an allocation

Also, retrieves the correct EBB header types for bitcasting on Operator::End.

* Bitcast values of a function with no explicit Wasm return instruction

* Add Signature::return_types method

This eliminates some duplicate code and avoids extra `use`s of `Vec`.

* Add Signature::param_types method; only collect normal parameters in both this and Signature::return_types

* Move normal_args to Signature::num_normal_params method

This matches the organization of the other Signature::num_*_params methods.

* Bitcast values of Operator::Call and Operator::CallIndirect

* Add DataFlowGraph::ebb_param_types

* Bitcast values of Operator::Br and Operator::BrIf

* Bitcast values of Operator::BrTable
alexcrichton added a commit to alexcrichton/wasmtime that referenced this issue Mar 18, 2020
Try to thoroughly document unsafety of `Memory` and how it can be used
safely.

cc bytecodealliance#1272
alexcrichton added a commit to alexcrichton/wasmtime that referenced this issue Mar 18, 2020
Try to thoroughly document unsafety of `Memory` and how it can be used
safely.

cc bytecodealliance#1272
alexcrichton added a commit that referenced this issue Mar 18, 2020
Try to thoroughly document unsafety of `Memory` and how it can be used
safely.

cc #1272
alexcrichton added a commit to alexcrichton/wasmtime that referenced this issue Mar 20, 2020
This commit adds two example programs, one for linking two modules
together and one for instantiating WASI. The linkage example
additionally uses WASI to get some meaningful output at this time.

cc bytecodealliance#1272
alexcrichton added a commit to alexcrichton/wasmtime that referenced this issue Mar 20, 2020
This commit adds two example programs, one for linking two modules
together and one for instantiating WASI. The linkage example
additionally uses WASI to get some meaningful output at this time.

cc bytecodealliance#1272
alexcrichton added a commit that referenced this issue Mar 20, 2020
* Add examples of linking and WASI

This commit adds two example programs, one for linking two modules
together and one for instantiating WASI. The linkage example
additionally uses WASI to get some meaningful output at this time.

cc #1272

* Add examples to the book as well

* More links!

* Ignore examples from rustdoc testsing

* More example updates

* More ignored
@Hyperion101010
Copy link

@Hyperion101010 Hyperion101010 commented Apr 17, 2020

Hi there Shivam here. I can try on working "Documentation of using wasm from Rust" @alexcrichton .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment