Skip to content

feat(tspd): auto-generate linter rule and diagnostic reference pages#11221

Draft
tadelesh wants to merge 1 commit into
mainfrom
tadelesh/auto-gen-rule-diagnostic-docs
Draft

feat(tspd): auto-generate linter rule and diagnostic reference pages#11221
tadelesh wants to merge 1 commit into
mainfrom
tadelesh/auto-gen-rule-diagnostic-docs

Conversation

@tadelesh

@tadelesh tadelesh commented Jul 9, 2026

Copy link
Copy Markdown
Member

Fixes #11141

Auto-generate a reference documentation page per linter rule and per diagnostic, so these pages stop being hand-written and drift-prone.

What's included

  • @typespec/tspd: tspd doc now renders
    • one page per rule -> reference/rules/<name>.md
    • one page per diagnostic -> reference/diagnostics/<code>.md + a diagnostics index
    • and reports a documentation-missing warning for rules/diagnostics without docs (only for libraries that have started documenting, to avoid noise).
  • Pilots (migrated the hand-written pages into the new system and deleted them):
    • @typespec/httpop-reference-container-route rule.
    • @typespec/openapi3 — 6 diagnostics (path-query, duplicate-header, inline-cycle, invalid-schema, invalid-server-variable, union-null).
    • @typespec/openapi — 2 diagnostics (duplicate-type-name, invalid-extension-key) that were previously (mis-)documented on the openapi3 page.

How docs are authored

Extended docs are authored as a co-located markdown file, read from source by tspd at doc-generation time using a precise per-item convention:

  • rules -> src/rules/<rule-name>.md
  • diagnostics -> src/diagnostics/<code>.md

tspd reads exactly that one file per rule/diagnostic (no src/**/*.md glob), so a stray .md in src is never picked up. The library itself never loads the file at runtime, so nothing extra ends up in the browser/playground bundle. A library only gets a generated diagnostics index/pages once it has at least one documented item.

Validation

  • Built compiler, tspd, http, openapi, openapi3; regen is stable (running it twice produces no diff).
  • regen-ing libraries with no documented diagnostics (e.g. json-schema) produces no new files.
  • lint green for the touched packages; op-reference-container-route rule tests pass; openapi api-extractor passes ($lib re-exported as @internal so tspd can enumerate diagnostics).

@microsoft-github-policy-service microsoft-github-policy-service Bot added compiler:core Issues for @typespec/compiler lib:http lib:openapi meta:website TypeSpec.io updates tspd Issues for the tspd tool emitter:openapi3 Issues for @typespec/openapi3 emitter labels Jul 9, 2026
@tadelesh tadelesh marked this pull request as draft July 9, 2026 12:50
@pkg-pr-new

pkg-pr-new Bot commented Jul 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http@11221
npm i https://pkg.pr.new/@typespec/openapi@11221
npm i https://pkg.pr.new/@typespec/openapi3@11221
npm i https://pkg.pr.new/@typespec/tspd@11221

commit: 1a02a89

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/http
  • @typespec/openapi
  • @typespec/openapi3
  • @typespec/tspd
Show changes

@typespec/openapi - internal ✏️

Provide extended documentation for the duplicate-type-name and invalid-extension-key diagnostics via co-located markdown files.

@typespec/openapi3 - internal ✏️

Provide extended documentation for several diagnostics (path-query, duplicate-header, inline-cycle, invalid-schema, invalid-server-variable, union-null) via co-located markdown files.

@typespec/tspd - feature ✏️

tspd doc now generates a documentation page per linter rule (reference/rules/<name>.md) and per diagnostic (reference/diagnostics/<code>.md) plus a diagnostics index, sourced from the docs field on the definitions. A documentation-missing warning is now also reported for linter rules and diagnostics without documentation.

@typespec/http - internal ✏️

Provide extended documentation for the op-reference-container-route linter rule via a co-located markdown file.

@azure-sdk-automation

azure-sdk-automation Bot commented Jul 9, 2026

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@tadelesh tadelesh force-pushed the tadelesh/auto-gen-rule-diagnostic-docs branch 2 times, most recently from 717ed80 to 9b20068 Compare July 10, 2026 06:42
Add an optional docs field (raw markdown, loaded from a co-located .md file) to linter rule (createRule) and diagnostic (createTypeSpecLibrary) definitions. tspd renders a page per rule (reference/rules/<name>.md) and per diagnostic (reference/diagnostics/<code>.md) plus a diagnostics index, and reports documentation-missing for undocumented rules/diagnostics. Migrates @typespec/http op-reference-container-route and @typespec/openapi3 path-query as pilots.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tadelesh tadelesh force-pushed the tadelesh/auto-gen-rule-diagnostic-docs branch from 9b20068 to 1a02a89 Compare July 10, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler:core Issues for @typespec/compiler emitter:openapi3 Issues for @typespec/openapi3 emitter lib:http lib:openapi meta:website TypeSpec.io updates tspd Issues for the tspd tool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant