Skip to content

feat(doc): support JSDoc @event, @fires, @emits, @listens#34688

Open
divybot wants to merge 1 commit into
mainfrom
orch/divybot-402
Open

feat(doc): support JSDoc @event, @fires, @emits, @listens#34688
divybot wants to merge 1 commit into
mainfrom
orch/divybot-402

Conversation

@divybot

@divybot divybot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Summary

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> (alias @emits <name>) — documents which events a method or function fires
  • @listens <name> — documents which events a symbol listens for

Names 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 doc and in deno doc --json (under the new event / fires / listens tag kinds), making the metadata available to JSR's doc renderer.

Example

/**
 * A connection that fires events when its state changes.
 *
 * @event open - Fired when the connection opens.
 * @event close - Fired when the connection closes.
 */
export class Conn extends EventTarget {
  /**
   * Open the connection.
   *
   * @fires Conn#open
   */
  open(): void {}
}
class Conn extends EventTarget
  A connection that fires events when its state changes.

  @event open
      Fired when the connection opens.

  @event close
      Fired when the connection closes.

  open(): void
    Open the connection.

    @fires Conn#open

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 and deno_doc bumped in Cargo.toml.

Upstream: denoland/deno_doc#800

Test plan

  • New spec test tests/specs/doc/jsdoc_event/ exercises terminal output and --json output for @event, @fires, and @listens on a class.
  • Upstream deno_doc PR adds unit tests for parsing and serialization of each new tag.

Refs #26697
Closes denoland/divybot#402

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>
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.

1 participant