JSDoc
The detailed JSDoc format guide. The essentials live in the jsdoc rule; reach here for the
full reference, including every @example format and documentation pattern in
references/examples.md.
@example format, in brief
- Short value: label on the
@example line, code as inline backtick on the next line.
- Multi-line code: a fenced
```ts ``` block immediately after @example, never bare lines.
- Multiple variants: separate
@example blocks, one concern each, never one example for every
case.
See references/examples.md for a worked example of each, plus the
property, enum, nested-property, and function documentation patterns.
Tags
Use frequently
| Tag |
Purpose |
Notes |
@default |
Default value |
Only when the default is non-obvious (omit for undefined) |
@example |
Usage example |
Prefer for complex or multi-variant APIs |
@note |
Important caveat |
Version info, breaking changes |
@deprecated |
Mark as deprecated |
Include a migration path |
Use sparingly
| Tag |
Purpose |
@see |
Reference external docs |
@internal |
Internal API |
@beta |
Experimental |
Avoid (TypeScript already provides these)
@param, @returns, @type, and @typedef duplicate the TypeScript signature; use the type,
return type, or a type/interface instead. Skip @default undefined too, since an optional
(?) property already implies it.
Guidelines
Do:
- Document what the property does, not its TypeScript type.
- Give every exported type, property, and function a JSDoc comment, always multi-line, with
concrete, full-sentence descriptions.
- Include
@default only when the default is non-obvious.
- Use multiple
@example blocks for different variants, with short, descriptive labels.
Do not:
- Write single-line
/** description */ or @default undefined.
- Put code directly on the
@example line, or use @param/@returns.
- Over-document trivial, self-explanatory properties.
Tag order
- Description (required)
- Bullet list of variants or behaviors (if applicable)
@default (if non-obvious)
@example (one or more)
@note (if needed)
@deprecated (if applicable)
@see (if providing references)
1---2name: jsdoc3description: Apply the TypeScript JSDoc format, examples, tags, and ordering.4---56# JSDoc78The detailed JSDoc format guide. The essentials live in the `jsdoc` rule; reach here for the9full reference, including every `@example` format and documentation pattern in10[references/examples.md](references/examples.md).1112## `@example` format, in brief1314- Short value: label on the `@example` line, code as inline backtick on the next line.15- Multi-line code: a fenced ` ```ts ``` ` block immediately after `@example`, never bare lines.16- Multiple variants: separate `@example` blocks, one concern each, never one example for every17 case.1819See [references/examples.md](references/examples.md) for a worked example of each, plus the20property, enum, nested-property, and function documentation patterns.2122## Tags2324### Use frequently2526| Tag | Purpose | Notes |27| ------------- | ------------------ | ----------------------------------------------------------- |28| `@default` | Default value | Only when the default is non-obvious (omit for `undefined`) |29| `@example` | Usage example | Prefer for complex or multi-variant APIs |30| `@note` | Important caveat | Version info, breaking changes |31| `@deprecated` | Mark as deprecated | Include a migration path |3233### Use sparingly3435| Tag | Purpose |36| ----------- | ----------------------- |37| `@see` | Reference external docs |38| `@internal` | Internal API |39| `@beta` | Experimental |4041### Avoid (TypeScript already provides these)4243`@param`, `@returns`, `@type`, and `@typedef` duplicate the TypeScript signature; use the type,44return type, or a `type`/`interface` instead. Skip `@default undefined` too, since an optional45(`?`) property already implies it.4647## Guidelines4849Do:5051- Document what the property does, not its TypeScript type.52- Give every exported type, property, and function a JSDoc comment, always multi-line, with53 concrete, full-sentence descriptions.54- Include `@default` only when the default is non-obvious.55- Use multiple `@example` blocks for different variants, with short, descriptive labels.5657Do not:5859- Write single-line `/** description */` or `@default undefined`.60- Put code directly on the `@example` line, or use `@param`/`@returns`.61- Over-document trivial, self-explanatory properties.6263## Tag order64651. Description (required)662. Bullet list of variants or behaviors (if applicable)673. `@default` (if non-obvious)684. `@example` (one or more)695. `@note` (if needed)706. `@deprecated` (if applicable)717. `@see` (if providing references)