| 1 |
# `skip_jsdoc` |
| 2 |
|
| 3 |
When attached to a function or a method, prevents `wasm-bindgen` from auto-generating JSDoc-style doc comments. |
| 4 |
By default, `wasm-bindgen` adds `@param` and `@returns` annotations to doc comments in the generated |
| 5 |
JS files. A `skip_jsdoc` annotation prevents this, allowing you to supply your own doc comments. |
| 6 |
|
| 7 |
The following rust uses `skip_jsdoc` to omit one of the auto-generated doc comments. |
| 8 |
|
| 9 |
```rust |
| 10 |
use wasm_bindgen::prelude::*; |
| 11 |
|
| 12 |
/// Autogenerated docs. |
| 13 |
#[wasm_bindgen] |
| 14 |
pub fn foo(arg: u32) -> u32 { arg + 1 } |
| 15 |
|
| 16 |
/// Manually written docs. |
| 17 |
/// |
| 18 |
/// @param {number} arg - A descriptive description. |
| 19 |
/// @returns {number} Something a bit bigger. |
| 20 |
#[wasm_bindgen(skip_jsdoc)] |
| 21 |
pub fn bar(arg: u32) -> u32 { arg + 2 } |
| 22 |
``` |
| 23 |
|
| 24 |
The `wasm-bindgen`-generated JS interface of the above code will look something like this: |
| 25 |
|
| 26 |
```js |
| 27 |
/** |
| 28 |
* Autogenerated docs. |
| 29 |
* |
| 30 |
* @param {number} arg |
| 31 |
* @returns {number} |
| 32 |
*/ |
| 33 |
export function foo(arg) { /* ... */ } |
| 34 |
|
| 35 |
/** |
| 36 |
* Manually written docs. |
| 37 |
* |
| 38 |
* @param {number} arg - A descriptive description. |
| 39 |
* @returns {number} Something a bit bigger. |
| 40 |
*/ |
| 41 |
export function bar(arg) { /* ... */ } |
| 42 |
``` |