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

Use triple-slash comments for documentation #286

Open
sunfishcode opened this issue Dec 16, 2023 · 6 comments
Open

Use triple-slash comments for documentation #286

sunfishcode opened this issue Dec 16, 2023 · 6 comments

Comments

@sunfishcode
Copy link
Member

sunfishcode commented Dec 16, 2023

I propose that the Wit format use /// comments, rather than //.

Wit itself no longer has non-documentation comments, however multiple projects are looking at using Wit as a base language that they can extend with more features. For such languages, it will be desirable to be able to have both documentation and regular comments, while remaining a superset of Wit.

Using /// for documentation and // for regular comments is a common convention, found in rustdoc, doxygen, C#, Swift, and others.

In the short term, the wit tooling can continue to accept both /// and // as documentation comments, until existing Wit files are migrated. In the long term, wit tooling could reject // comments to free up their space in the grammar for derived languages.

@peterhuene @lukewagner @esoterra

@esoterra
Copy link
Contributor

esoterra commented Dec 16, 2023

That's a good point, languages like claw will definitely want to
A. make a distinction between doc and normal comments,
B. choose to represent doc comments as /// to match common convention, and
C. keep its use of WIT syntax for type and interface definitions exactly compatible.

The best way to enable this is for WIT itself to use the prefix /// for doc comments.

@lukewagner
Copy link
Member

Yes, that's a good point. The high-order bit in #273 was removing a confusing choice by having only one form of comment, but this could be achieved just as well by having that form be ///, thereby reserving // for use in languages embedding WIT (which is popping up). So this change makes sense to me. I'm sorry I didn't spot this issue earlier to avoid the recent churn, but maybe this direction actually makes less churn overall (given that most WASI WITs have already been moved over to ///)? WDYT @alexcrichton?

@alexcrichton
Copy link
Collaborator

Setting aside churn for a moment, I'm not sure I understand fully how this would enable other languages to use //. It sounds like the goal is to make // not parse in a WIT file, but I also feel like I might be missing something.

As for the churn, I'd need to better understand the fate of //-in-WIT to better comment on that.

@esoterra
Copy link
Contributor

esoterra commented Jan 2, 2024

The idea is to normalize on /// only for WIT doc comments and remove //.

Then languages which extend or embed WIT would be able to use the // vs. /// convention to have doc and normal comments in a way where the embedded WIT doc comments continue to be treated as doc comments.

@sunfishcode
Copy link
Member Author

Concerning churn, all the Wit files I've seen are currently using /// for documentation, so the proposal here would result in less churn than converting them all to //.

@alexcrichton
Copy link
Collaborator

Ah ok I think I see better now. In that case the "churn" here would be that wit-parser would start to emit a warning to stdio whenever it encountered a // comment with a recommendation to use /// instead. All versions of wit-parser accept /// already so once the warning is in place for awhile we could remove parsing support.

That I do think will require some changes to be made but I think it's feasible to do.

sunfishcode added a commit to sunfishcode/wasm-tools that referenced this issue Jan 4, 2024
Per the discussion in WebAssembly/component-model#286, switch to `///`
for documentation comments in the Wit printer.

`//` comments are still accepted and interpreted as documentation
comments for now.
alexcrichton pushed a commit to bytecodealliance/wasm-tools that referenced this issue Jan 5, 2024
* Switch to `///` for printing documentation comments.

Per the discussion in WebAssembly/component-model#286, switch to `///`
for documentation comments in the Wit printer.

`//` comments are still accepted and interpreted as documentation
comments for now.

* Update to the latest wasi-http.

* Update a few more tests to `///` doc comments.
sunfishcode added a commit to sunfishcode/wasi-cli that referenced this issue Jan 9, 2024
Per the discussion in WebAssembly/component-model#286, remove some `//`
comments which had been intended as non-documentation comments to `///`
documentation comments.
sunfishcode added a commit to sunfishcode/wasi-sockets that referenced this issue Jan 9, 2024
Per the discussion in WebAssembly/component-model#273, the Wit format is
moving to only have documentation comments. A as of
WebAssembly/component-model#286, the syntax for documentation commments
is `///`.

This patch converts a few of the remaining `//` comments in network.wit
to `///` comments.
sunfishcode added a commit to WebAssembly/wasi-cli that referenced this issue Jan 12, 2024
* Switch to `///` comments.

Per the discussion in WebAssembly/component-model#286, remove some `//`
comments which had been intended as non-documentation comments to `///`
documentation comments.

* Update to the latest wasi-sockets and wasi-io.

Update to the latest wasi-sockets and wasi-io. The only changes are the
addition of some comments, and changing some comments from `//` to `///`.
sunfishcode added a commit to sunfishcode/component-docs that referenced this issue Mar 18, 2024
Wit [uses tripe-slash comments] for documentation; update a few example
code blocks accordingly.

[uses tripe-slash comments]: WebAssembly/component-model#286
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

No branches or pull requests

4 participants