Skip to content

feat(tspd): add --rules-dir option to control rule reference page location#11316

Merged
timotheeguerin merged 1 commit into
mainfrom
tspd-doc-rules-dir
Jul 20, 2026
Merged

feat(tspd): add --rules-dir option to control rule reference page location#11316
timotheeguerin merged 1 commit into
mainfrom
tspd-doc-rules-dir

Conversation

@timotheeguerin

Copy link
Copy Markdown
Member

Summary

Adds a --rules-dir option (and matching rulesDir API option) to tspd doc to control the directory where the per-rule reference pages are written.

Since the tspd change that auto-generates one reference page per linter rule, those pages are always emitted under <output-dir>/rules/. Some consumers (e.g. typespec-azure) generate their reference docs into a reference/ output dir but want the rule pages to keep their historical location one level up (libraries/<lib>/rules/<name>), so that existing rule URLs stay stable.

This adds a small, backwards-compatible knob to control that location.

Details

  • New CLI flag --rules-dir <dir> on tspd doc.
  • New rulesDir option on GenerateLibraryDocsOptions and RenderToStarlightMarkdownOptions.
  • Defaults to "rules" (relative to --output-dir) — no change to existing behavior.
  • Can be set to a path that escapes the output dir (e.g. "../rules") to place rule pages outside the generated reference folder.
  • The StarlightRenderer.linterRuleLink (used by linter.md) honors the configured dir so cross-links resolve correctly.

Example

# default (unchanged): pages at <output-dir>/rules/<name>.md
tspd doc . --enable-experimental --output-dir ./reference

# keep rule pages outside the reference folder: <output-dir>/../rules/<name>.md
tspd doc . --enable-experimental --output-dir ./reference --rules-dir ../rules

…ation

Add a `--rules-dir` CLI option (and `rulesDir` API option) to `tspd doc` to control the directory where per-rule reference pages are written. Defaults to `rules` (relative to --output-dir); can be set to a path escaping the output dir (e.g. `../rules`) to keep rule pages outside the generated reference folder.
@timotheeguerin
timotheeguerin marked this pull request as ready for review July 20, 2026 18:27
@microsoft-github-policy-service microsoft-github-policy-service Bot added the tspd Issues for the tspd tool label Jul 20, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/tspd@11316

commit: 4a590d3

@timotheeguerin
timotheeguerin enabled auto-merge July 20, 2026 18:28
@github-actions

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/tspd
Show changes

@typespec/tspd - feature ✏️

Add a --rules-dir option (and rulesDir API option) to tspd doc to control where per-rule reference pages are written. Defaults to rules (relative to --output-dir); can be set to a path escaping the output dir (e.g. ../rules) to keep rule pages outside the generated reference folder.

@azure-sdk-automation

azure-sdk-automation Bot commented Jul 20, 2026

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@timotheeguerin
timotheeguerin added this pull request to the merge queue Jul 20, 2026
Merged via the queue into main with commit e0248a1 Jul 20, 2026
33 checks passed
@timotheeguerin
timotheeguerin deleted the tspd-doc-rules-dir branch July 20, 2026 19:25
timotheeguerin pushed a commit to Azure/typespec-azure that referenced this pull request Jul 21, 2026
The core bump pulls in tspd's per-rule reference page generation. Rather
than let it orphan Azure's rich hand-written rule pages at a new location,
this migrates each rule to the tspd `docs` field (rich content now lives in
`packages/*/src/rules/*.md`) and passes `--rules-dir ../rules` so generated
pages stay at the existing `libraries/<lib>/rules/<name>` URLs (net-zero URL
change).

- core: bump submodule to latest main (includes merged tspd `--rules-dir`
  change, microsoft/typespec#11316)
- 86 rules: add `docs: fileRef.fromPackageRoot("src/rules/<name>.md")`
- 3 package.json regen-docs scripts: pass `--rules-dir ../rules`
- astro.config: 5 redirects for rules whose historical slug != rule name
- gitignore the generated `libraries/*/rules/` pages (regenerated by build:web)
- pnpm-lock: add @typespec/events / @typespec/sse workspace links (http-specs)
msyyc pushed a commit to JennyPng/typespec that referenced this pull request Jul 21, 2026
…t#11320)

## Problem

The tspd change that auto-generates one reference page per linter rule
(microsoft#11221) moved the `@typespec/http` linter rule page from its historical
location:

- **Before:**
`https://typespec.io/docs/libraries/http/rules/op-reference-container-route`
- **After:**
`https://typespec.io/docs/libraries/http/reference/rules/op-reference-container-route`

This is a breaking change to the public documentation URL. The rule's
own `url` field, external links, and the diagnostic "see documentation"
link all still point at the historical `libraries/http/rules/<name>`
location, which now 404s.

## Fix

Use the `--rules-dir ../rules` option (added in microsoft#11316) in http's
`regen-docs` script so the per-rule reference pages are written back to
`libraries/http/rules/<name>`, restoring the original URL.

- `packages/http/package.json` — add `--rules-dir ../rules` to
`regen-docs`.
- Regenerated docs: the rule page moves back to
`libraries/http/rules/op-reference-container-route.md` (100% rename) and
`linter.md` links back to `../rules/...`.
- `current-sidebar.ts` — re-enable the http "Rules" sidebar group
(`hasLinterRules: true`), which autogenerates from
`libraries/http/rules`.

`@typespec/http` is the only library in this repo that ships linter
rules, so no other library is affected.

## Validation

- `regen-docs` is stable (running it twice produces no diff).
- The restored page URL
`libraries/http/rules/op-reference-container-route` matches the rule's
hardcoded `url` again.
- `chronus verify` passes.

Co-authored-by: tadelesh <chenjieshi@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
msyyc pushed a commit to msyyc/typespec-azure that referenced this pull request Jul 21, 2026
…Azure#4968)

Bumps the `core` submodule to latest main, which pulls in tspd's
per-rule reference page generation (microsoft/typespec#11221). Left
as-is, that would orphan Azure's rich hand-written rule pages by
emitting barebones pages at a new location.

Instead, this migrates each rule to the tspd `docs` field and keeps the
generated pages at their existing URLs (net-zero URL change).

## Changes

- **core**: bump submodule to latest main — includes the merged tspd
`--rules-dir` change (microsoft/typespec#11316)
- **86 rules**: add `docs:
fileRef.fromPackageRoot("src/rules/<name>.md")`; rich content now lives
in `packages/*/src/rules/*.md`
- **3 `package.json`** regen-docs scripts: pass `--rules-dir ../rules`
so generated pages stay at `libraries/<lib>/rules/<name>`
- **astro.config**: 5 redirects for rules whose historical slug differs
from the rule name (e.g. `prevent-format` → `no-format`)
- **.gitignore**: ignore the generated `libraries/*/rules/` pages
(regenerated during `build:web`)
- **pnpm-lock**: add `@typespec/events` / `@typespec/sse` workspace
links (new `http-specs` peer deps from the bump)
- **eng/feeds e2e**: adapt `init-templates.e2e.ts` to the compiler's new
`TemplateSource` scaffold API — `ScaffoldingConfig.baseUri` was replaced
by `source?: TemplateSource` (microsoft/typespec#11303). Supersedes
Azure#4965.
- Contributing guide, `create-linter-rule` skill + scaffolder updated to
the `docs`-field workflow

## Validation

- `typespec-azure-core`, `typespec-azure-resource-manager`,
`typespec-client-generator-core` tests pass
- `oxlint` clean
- `pnpm install --frozen-lockfile` passes
- `pnpm regen-docs` clean (no drift)
- init-templates e2e: scaffolding tests pass via the new
`TemplateSource` path (the 2 `validate` tests that `npm install` an
unpublished `@azure-tools/typespec-autorest` version fail only on
registry resolution, unrelated to this change)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tspd Issues for the tspd tool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants