ReviewOS

also looking at this

stacks/bunpress

fix: name the document a refused Markdown link was authored in

#94
Closed glennmichael123 wants to merge fix/name-the-document-a-refused-link-is-in into main
2 files +49 -2
7 days ago

Closes #92.

What changed

Both link failures in resolveLink named the destination and nothing else:

error: Markdown link has no documentation source: ./missing-one.md

The destination is the half the reader already knows, because it is the part that is missing. The file holding the link is what has to be edited, and it was not in the message, so acting on it meant grepping the repository for the string.

The throw site already had the answer. resolveLink reads page.sourceFile on the line above, to resolve the destination it then rejects, so nothing new is threaded through:

error: guides/start.md: Markdown link has no documentation source: ../adr/absent.md

Relative to the documentation root, because an absolute temporary path is noise in a build log. The same applies to Markdown link has no rendered page, which had the same shape.

Includes

Named file is the included one rather than its host. rewriteMarkdownSourceLinks hands resolveLink the innermost origin on its include stack, so page.sourceFile is already where the link was written. The two differ exactly when the message matters most, so there is a test for it.

Tests

Two, in test/markdown-source-links.test.ts beside the existing coverage for this area. Both were run against the unpatched source first and fail there:

Expected substring: "guides/start.md: Markdown link has no documentation source: ../adr/absent.md"
Received message: "Markdown link has no documentation source: ../adr/absent.md"

Full suite: 612 pass, 0 fail. Lint is unchanged at 3 pre-existing warnings in README.md and serve.ts, identical before and after. tsc --noEmit is clean.

Not in this change

#93, the build stopping at the first unresolvable link so N of them cost N builds. That one needs failures collected across the render and reported together, which is a larger change than this message fix and is better judged on its own.

🤖 Generated with Claude Code

2 changed files on the files tab, with 0 review threads.

Sign in to comment on this pull request.