Skip to content

docs: document the available JSDoc annotations - #2564

Open
Labu1 wants to merge 2 commits into
vega:nextfrom
Labu1:repodestek/issue-2045
Open

Labu1 wants to merge 2 commits into
vega:nextfrom
Labu1:repodestek/issue-2045

Conversation

@Labu1

@Labu1 Labu1 commented Nov 23, 2026

Copy link
Copy Markdown

What

Adds an Annotations section to the README that documents all JSDoc tags the generator supports, as requested in #2045 (see also #1819).

The section covers:

  • How --jsDoc (none / basic / extended) controls which tags are read.
  • Keyword tags from BasicAnnotationsReader: text tags (@title, @description, @id, @comment, @ref, @format, @pattern, @contentMediaType, @contentEncoding) and value tags (@minimum, @maximum, @exclusiveMinimum, @exclusiveMaximum, @multipleOf, @minLength, @maxLength, @minItems, @maxItems, @uniqueItems, @minProperties, @maxProperties, @propertyNames, @contains, @const, @examples, @default, @required, @if/@then/@else, @readOnly, @writeOnly, @deprecated). It notes the $ prefix for $id/$comment/$ref, JSON5 parsing, and that a value tag with no text becomes true.
  • Custom tags through --validation-keywords / extraTags.
  • Extended-only tags from ExtendedAnnotationsReader: @example, @nullable, @asType, plus the --markdown-description and --full-description output.
  • @hidden and @internal, which change what gets generated.
  • @discriminator with an example, the default if/then output and the discriminatorType: "open-api" alternative.

This is a documentation-only change; no code was modified.

Fixes #2045

Testing

Ran npm test in a clean Linux container: passed.


This PR was prepared with AI assistance (Claude) and reviewed by me before submitting.

Add an "Annotations" section to the README listing every JSDoc tag
the generator understands: the JSON Schema keyword tags read by
BasicAnnotationsReader, the extended-only tags (@example, @nullable,
@astype), the tags that change what is generated (@hidden, @internal)
and @Discriminator with its json-schema and open-api output styles.
It also explains how the --jsDoc mode and --validation-keywords
affect which tags are read.

Fixes vega#2045.

@arthurfiorette arthurfiorette left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Writing pass. Content reads well; the comments below are wording fixes and one overlap with #2565.

Comment thread README.md Outdated

### Keyword tags

These tags map straight to the JSON Schema keyword of the same name.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

"Of the same name" is contradicted by the table right below (@id -> $id, @comment -> $comment, @ref -> $ref).

Suggested change
These tags map straight to the JSON Schema keyword of the same name.
Each tag becomes a JSON Schema keyword, named after the tag unless the table says otherwise.

Comment thread README.md Outdated
| `@ref` | `$ref` (replaces the type) |
| `@format` | `format` |
| `@pattern` | `pattern` |
| `@contentMediaType`, `@contentEncoding` | `contentMediaType`, `contentEncoding` |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Column widths are off on these rows (and in the value tags table). Run prettier on the file.

Comment thread README.md Outdated
| `@readOnly`, `@writeOnly` | `@readOnly` |
| `@deprecated` | `@deprecated` |

Other tags are ignored unless you list them with `--validation-keywords` (`extraTags` in the config). Listed tags are parsed like value tags and copied into the schema under the tag name.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

#2565 documents the same --validation-keywords / extraTags behavior in its own section. Keep it in one place and link to it from the other, otherwise the two will drift.

Suggested change
Other tags are ignored unless you list them with `--validation-keywords` (`extraTags` in the config). Listed tags are parsed like value tags and copied into the schema under the tag name.
Other tags are ignored unless you list them with `--validation-keywords` (`extraTags` in the config). They are parsed like value tags and copied into the schema under the tag name.

Comment thread README.md Outdated

### Discriminated unions

`@discriminator <property>` on a union type tells the generator which property tells the union members apart:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

"tells" twice in one sentence.

Suggested change
`@discriminator <property>` on a union type tells the generator which property tells the union members apart:
`@discriminator <property>` on a union type names the property that distinguishes the union members:

@domoritz

Copy link
Copy Markdown
Member

Can this be shorter? It's a pretty long addition that will be hard to maintain. Maybe we can link to code?

Replace the tag tables with a short summary and point to
BasicAnnotationsReader/ExtendedAnnotationsReader for the full lists.
Also fix wording raised in review.
@Labu1

Labu1 commented Nov 23, 2026

Copy link
Copy Markdown
Author

Thanks @domoritz and @arthurfiorette!

  • @domoritz: I made the section much shorter. The tag tables are gone. A short paragraph per group now names the common tags and links to textTags/jsonTags in src/AnnotationsReader/BasicAnnotationsReader.ts and to ExtendedAnnotationsReader.ts for the full lists, so the README won't need updating when a tag is added. What's left: the --jsDoc levels, one example, @hidden/@internal in one sentence, and the @discriminator example.
  • @arthurfiorette ("of the same name"): the text now says most keywords use a tag of the same name, and calls out the $-prefixed ones (@id, @comment, @ref).
  • @arthurfiorette (column widths): there are no tables left in this section, so the alignment problem is gone.
  • @arthurfiorette (--validation-keywords overlap with docs: document custom JSDoc tags as an escape hatch for arbitrary schema keywords #2565): I used your suggested wording, so it's one sentence now. docs: document custom JSDoc tags as an escape hatch for arbitrary schema keywords #2565 isn't on this branch yet, so I can't link to its section here. Whichever PR merges second can turn this sentence into a link (or drop it). Let me know if you'd rather I remove it now.
  • @arthurfiorette ("tells" twice): applied your suggestion.

Ran npm test in a clean Linux container: passed.

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.

Document the available annotations

3 participants