Skip to content

Fix 404 links to rule pages in tspd-generated linter reference#10501

Open
Copilot wants to merge 4 commits intomainfrom
copilot/fix-linter-rules-link-404
Open

Fix 404 links to rule pages in tspd-generated linter reference#10501
Copilot wants to merge 4 commits intomainfrom
copilot/fix-linter-rules-link-404

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 27, 2026

Auto-generated linter reference pages (e.g. /docs/libraries/http/reference/linter) 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}.tslinterRuleLink now returns a relative .md link of the form ../<folder>/<name>.md. The folder and slug are derived from the rule URL's last two path segments (via new URL(url).pathname) rather than being hardcoded, so libraries that organize rule pages under a different folder name continue to work. 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.
  • 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.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 27, 2026

Open in StackBlitz

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

commit: 34ccbe2

@azure-sdk
Copy link
Copy Markdown
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Comment thread website/src/content/docs/docs/libraries/http/reference/linter.md Outdated
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 28, 2026

@tadelesh Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: a1576a6a-c555-486a-9ec1-b65eeb42505f

Sorry for the inconvenience!

@github-actions
Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/tspd
Show changes

@typespec/tspd - fix ✏️

Fix broken (404) links to linter rule pages on auto-generated linter reference pages. The links no longer drop the website base path.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 28, 2026

@tadelesh Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: a1576a6a-c555-486a-9ec1-b65eeb42505f

Sorry for the inconvenience!

2 similar comments
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 28, 2026

@tadelesh Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: a1576a6a-c555-486a-9ec1-b65eeb42505f

Sorry for the inconvenience!

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 28, 2026

@tadelesh Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: a1576a6a-c555-486a-9ec1-b65eeb42505f

Sorry for the inconvenience!

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 28, 2026

@tadelesh Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: a1576a6a-c555-486a-9ec1-b65eeb42505f

Sorry for the inconvenience!

1 similar comment
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 28, 2026

@tadelesh Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: a1576a6a-c555-486a-9ec1-b65eeb42505f

Sorry for the inconvenience!

@tadelesh tadelesh requested a review from timotheeguerin April 28, 2026 07:22
// last two path segments (so we don't hardcode the folder name) and
// emit a relative `.md` link which Docusaurus rewrites into a proper
// site link.
const segments = new URL(url).pathname.split("/").filter(Boolean);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wait actually, I think we might be overthinking this, tspd decide the folder structure, it should just resolve the filename that way instead, that way we also don't need the docusaurusWebsite property which is not ideal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta:website TypeSpec.io updates tspd Issues for the tspd tool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants