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

Add a skip_jsdoc attribute. #3338

Merged
merged 7 commits into from
Mar 10, 2023
Merged

Add a skip_jsdoc attribute. #3338

merged 7 commits into from
Mar 10, 2023

Conversation

jneem
Copy link
Contributor

@jneem jneem commented Mar 2, 2023

This adds a skip_jsdoc attribute to suppress the generation of jsdoc @param and @returns comments.

This was motivated by #1847, but I ended up going a different route because I found it awkward to put long descriptions in attributes. The idea is that if you can skip the auto-generated jsdoc, you can comment the parameters and return values yourself:

/// @param {string} world - The world.
#[wasm_bindgen(skip_jsdoc)]
fn hello(world: &str) {}

It's a little sad that this approach doesn't keep the type information in sync, but I still think it's nicer than an alternative like

#[wasm_bindgen(param(world = "The world."))]
fn hello(world: &str) {}

(especially if the description is longer)

@jneem
Copy link
Contributor Author

jneem commented Mar 3, 2023

I'm not sure I did the schema-bumping correctly, but I tried to do what's in line with past practice: I bumped the schema version but not the crate versions, which seems to usually happen right when releasing.

Copy link
Collaborator

@Liamolucko Liamolucko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! The code looks good, but could you add a page about this to the guide?

The source Markdown is at guide/src, and this should specifically go in guide/src/reference/attributes/on-rust-exports.

You also have to add an entry to guide/src/SUMMARY.md, otherwise the page won't show up in the table of contents.

Also, yes, you bumped the schema version properly.

@jneem
Copy link
Contributor Author

jneem commented Mar 9, 2023

Thanks for the pointers! I've added a guide entry.

Copy link
Collaborator

@Liamolucko Liamolucko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Liamolucko Liamolucko merged commit 5bb3520 into rustwasm:main Mar 10, 2023
@qtnx
Copy link

qtnx commented Apr 16, 2023

Looks like it's not working on the latest version 0.2.84

error: unknown attribute
   --> wasm/src/lib.rs:198:20
    |
198 |     #[wasm_bindgen(skip_jsdoc)]
    |                    ^^^^^^^^^^

@jneem
Copy link
Contributor Author

jneem commented Apr 16, 2023

Yes: 0.2.84 was release in February and this was only merged in March.

@qtnx
Copy link

qtnx commented Apr 17, 2023

Yes: 0.2.84 was release in February and this was only merged in March.

Hmm, so it shouldn't be in the official documentation. Hopefully, a new version will be released soon, it's already April.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants