feat(doc): support JSDoc @event, @fires, @emits, @listens#34688
Open
divybot wants to merge 1 commit into
Open
Conversation
Adds support for the JSDoc event-documentation tags so that classes which fire events (e.g. `EventTarget` subclasses) can be documented with `deno doc` and on JSR: - `@event <name>` — declares an event a class can emit - `@fires <name>` / `@emits <name>` — documents which events a method or function fires - `@listens <name>` — documents which events a symbol listens for The new variants are parsed by `deno_doc` and surfaced both in the terminal output and in the `deno doc --json` output (under the new `event` / `fires` / `listens` tag kinds). Pulls the matching change in `deno_doc` (denoland/deno_doc#800) via a temporary `[patch.crates-io]` so the new spec test can verify end to end. The patch will be removed and `deno_doc` bumped once that upstream PR is merged and released. Closes #26697 Co-Authored-By: Divy Srivastava <me@littledivy.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for the JSDoc event-documentation tags so that classes which fire events (e.g.
EventTargetsubclasses) can be documented withdeno docand on JSR:@event <name>— declares an event a class can emit@fires <name>(alias@emits <name>) — documents which events a method or function fires@listens <name>— documents which events a symbol listens forNames follow the JSDoc convention (e.g.
Hurl#snowball,module:hurler~snowball) and an optional trailing description is captured.The new tags are surfaced both in the terminal output of
deno docand indeno doc --json(under the newevent/fires/listenstag kinds), making the metadata available to JSR's doc renderer.Example
Implementation
The actual JSDoc-tag parsing lives in
deno_doc. The matching change is proposed there as denoland/deno_doc#800 and is consumed here via a temporary[patch.crates-io]so the new spec test can verify end-to-end behaviour. Once the upstream PR is merged and released, the patch should be dropped anddeno_docbumped inCargo.toml.Upstream: denoland/deno_doc#800
Test plan
tests/specs/doc/jsdoc_event/exercises terminal output and--jsonoutput for@event,@fires, and@listenson a class.deno_docPR adds unit tests for parsing and serialization of each new tag.Refs #26697
Closes denoland/divybot#402