Fix 404 links to rule pages in tspd-generated linter reference#10501
Fix 404 links to rule pages in tspd-generated linter reference#10501
Conversation
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/065aa946-6a06-4d58-8e8b-b67e7f1c19cd Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
commit: |
|
You can try these changes here
|
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/dcfef4b8-1477-473c-ae97-ae6d3412456e Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/a4da7814-1671-4aa7-b6b2-290c55b664a7 Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
|
@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: Sorry for the inconvenience! |
|
All changed packages have been documented.
Show changes
|
|
@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: Sorry for the inconvenience! |
2 similar comments
|
@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: Sorry for the inconvenience! |
|
@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: Sorry for the inconvenience! |
|
@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: Sorry for the inconvenience! |
1 similar comment
|
@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: Sorry for the inconvenience! |
| // 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); |
There was a problem hiding this comment.
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
Auto-generated linter reference pages (e.g.
/docs/libraries/http/reference/linter) contained broken links to individual rule pages.Root cause
linterRuleLinkin tspd's Starlight (and Docusaurus) emitters stripped the package'sdocusaurusWebsiteprefix 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 tohttps://typespec.io/libraries/...and 404.Changes
packages/tspd/src/ref-doc/emitters/{starlight,docusaurus}.ts—linterRuleLinknow returns a relative.mdlink of the form../<folder>/<name>.md. The folder and slug are derived from the rule URL's last two path segments (vianew URL(url).pathname) rather than being hardcoded, so libraries that organize rule pages under a different folder name continue to work. Both Astro/Starlight (viarehypeAstroRelativeMarkdownLinks) and Docusaurus rewrite relative.mdlinks 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 viapnpm regen-docs; the table cell now links to../rules/op-reference-container-route.md.fixentry for@typespec/tspd.