Skip to content

Auto-generate linter rule and diagnostic documentation pages from structured definitions #11141

Description

@tadelesh

Problem

Today the per-item documentation pages on the website are maintained by hand and are disconnected from the code that defines them:

  • Linter rule pages (website/src/content/docs/docs/libraries/<lib>/rules/<name>.md) are hand-written. The rule definition (createRule) only carries name, severity, description, url, messages — none of the page body (rationale, how-to-fix, ✅/❌ examples) lives with the code.
  • Diagnostic pages (e.g. website/src/content/docs/docs/emitters/openapi3/diagnostics.md) are hand-written. Diagnostic definitions (createTypeSpecLibrary({ diagnostics })) only carry severity + messages (plus an optional, mostly-unused description/url). tspd does not extract diagnostics at all.
  • Only the linter summary page (reference/linter.md) is auto-generated by tspd; it just links to the hand-written rule pages. There is no generated index/page for diagnostics.

This causes documentation drift, duplicated effort, and inconsistent quality across libraries and downstream emitters.

Motivation

Two concrete asks motivate a general solution:

Both boil down to the same gap: there is no structured, code-colocated place to author extended documentation for rules/diagnostics, and no tooling to auto-generate the corresponding pages.

Goal

  1. Add structured documentation fields to linter-rule and diagnostic definitions so docs live with the code (and examples can be validated in CI).
  2. Extend tspd to extract these fields and auto-generate: per-rule pages, per-diagnostic pages, and their index pages.
  3. Migrate existing hand-written pages into the definitions. Generated output moves under each library's reference/ folder; old URLs breaking is acceptable.

A detailed design proposal follows in the comment below.

Fixes #10757.
Related: Azure/typespec-azure#4791.

Metadata

Metadata

Assignees

Labels

design:proposedProposal has been added and ready for discussiondocsImprovements or additions to documentationfeatureNew feature or requesttspdIssues for the tspd tool

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions