Commit 2143f3d
Fix 404 links to rule pages in tspd-generated linter reference (#10501)
Auto-generated linter reference pages (e.g. <a
href="https://typespec.io/docs/libraries/http/reference/linter">`/docs/libraries/http/reference/linter`</a>)
contained broken links to individual rule pages.
### Root cause
`linterRuleLink` in tspd's Starlight (and Docusaurus) emitters stripped
the package's `docusaurusWebsite` prefix from each rule URL and appended
`.md`, producing browser-absolute paths like
`/libraries/http/rules/op-reference-container-route.md`. Because
typespec.io is served under a `/docs/` base path, those links resolve to
`https://typespec.io/libraries/...` and 404.
### Changes
- **`packages/tspd/src/ref-doc/emitters/{starlight,docusaurus}.ts`** —
`linterRuleLink` now takes the `LinterRuleRefDoc` (instead of a URL
string) and the Starlight/Docusaurus emitters simply return
`../rules/${rule.rule.name}.md`. tspd owns the folder structure for
generated rule pages, so the filename can be resolved directly without
parsing URLs or relying on package metadata. Both Astro/Starlight (via
`rehypeAstroRelativeMarkdownLinks`) and Docusaurus rewrite relative
`.md` links into proper site URLs honoring the active base path / host,
so links work in production, local dev, and PR previews. The
`markdown.ts` emitter logic is unchanged.
- **`website/.../http/reference/linter.md`** — regenerated via `pnpm
regen-docs`; the table cell now links to
`../rules/op-reference-container-route.md`.
- **Changelog** — added a `fix` entry for `@typespec/tspd`.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
Co-authored-by: Chenjie Shi <tadelesh.shi@live.cn>1 parent c3d1f00 commit 2143f3d
5 files changed
Lines changed: 20 additions & 22 deletions
File tree
- .chronus/changes
- packages/tspd/src/ref-doc/emitters
- website/src/content/docs/docs/libraries/http/reference
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
286 | 287 | | |
287 | 288 | | |
288 | 289 | | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
| 290 | + | |
| 291 | + | |
297 | 292 | | |
298 | 293 | | |
299 | 294 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
438 | 438 | | |
439 | 439 | | |
440 | 440 | | |
441 | | - | |
| 441 | + | |
| 442 | + | |
442 | 443 | | |
443 | 444 | | |
444 | 445 | | |
445 | 446 | | |
446 | 447 | | |
447 | | - | |
448 | | - | |
| 448 | + | |
| 449 | + | |
449 | 450 | | |
450 | 451 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
311 | 312 | | |
312 | 313 | | |
313 | 314 | | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
| 315 | + | |
| 316 | + | |
322 | 317 | | |
323 | 318 | | |
324 | 319 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
0 commit comments