Add support for documenting the C API (#1928)
This commit adds a bit of a skeleton of what it might look like to document the C API. Today the C API has virtually zero documentation because the upstream documentation does not exist and we haven't put a ton of effort into documenting our own extensions. Given that this is one of the main vectors we expect users to use Wasmtime, we should make sure it's thoroughly documented! I've never really done much documentation generation of C myself before, but I did a bit of searching and Doxygen seems reasonable proficient for doing this. This commit sets up what it might look like for Doxygen to be used for the C API. One nice feature of DOxygen is that we can document the items in `wasm.h` without actually modifying `wasm.h`. For those purposes a `doc-wasm.h` file was added here which is where we can put Wasmtime-specific documentation about `wasm.h`. There's quite a few functions in the C API so I didn't want to get them all done before getting consensus on this. I've started some skeletons of documentation for global types in `wasm.h` and also confirmed that documentation works for our own `wasmtime.h` and such header files. If this looks good to everyone and it runs reasonable well on CI then I can spend more time filling out the rest of the documentation.
This commit is contained in:
@@ -1,4 +1,13 @@
|
||||
// WebAssembly C API extension for Wasmtime
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Wasmtime-specific extensions to the WebAssembly C API.
|
||||
*
|
||||
* This file contains all of the Wasmtime-specific functions which will not be
|
||||
* present in other engines. The intention of this file is to augment the
|
||||
* functionality provided in `wasm.h`.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WASMTIME_API_H
|
||||
#define WASMTIME_API_H
|
||||
@@ -17,8 +26,23 @@ extern "C" {
|
||||
\
|
||||
WASM_API_EXTERN void wasmtime_##name##_delete(own wasmtime_##name##_t*);
|
||||
|
||||
/**
|
||||
* \brief Errors generated by Wasmtime.
|
||||
*
|
||||
* This opaque type represents an error that happened as part of one of the
|
||||
* functions below. Errors primarily have an error message associated with them
|
||||
* at this time, which you can acquire by calling #wasmtime_error_message.
|
||||
*/
|
||||
WASMTIME_DECLARE_OWN(error)
|
||||
|
||||
/**
|
||||
* \brief Returns the string description of this error.
|
||||
*
|
||||
* This will "render" the error to a string and then return the string
|
||||
* representation of the error to the caller. The `message` argument should be
|
||||
* uninitialized before this function is called and the caller is responsible
|
||||
* for deallocating it with #wasm_byte_vec_delete afterwards.
|
||||
*/
|
||||
WASM_API_EXTERN void wasmtime_error_message(
|
||||
const wasmtime_error_t *error,
|
||||
own wasm_name_t *message
|
||||
|
||||
Reference in New Issue
Block a user