[#140] Add a test that the documentation links resolve - #141
Merged
Merged
Conversation
Nothing checked the documentation links, so broken ones accumulated: the schema docs cleanup in #120 turned up nine pre-existing breakages, including source paths that had moved, anchors left behind when the per-command pages were split out, and a link missing its URL scheme. These matter more since #118 put Documentation/ in the release zip, where a reader cannot fall back to searching GitHub. The test walks the repository's markdown, resolves every relative target and every anchor, and fails with the full list. It needs no CI changes because test.yml already runs dotnet test on Linux, macOS and Windows, and it doubles as the local tool via --filter DocumentationLinks. Internal links only. External URLs need the network and produce false failures from rate limits and bot blocking, which must not block a merge. Paths are compared against the real directory entries rather than with File.Exists, so a wrong-case link is caught on Windows and macOS too instead of only breaking for Linux users. Anchors follow GitHub's slug rules, including the -1/-2 suffixes for repeated headings (command-archive.md has five "Example" headings) and the one-for-one space-to-hyphen conversion that makes "dangling_refs / dangling_refs_view" anchor as "dangling_refs--dangling_refs_view". Those rules are pinned by unit tests, since they are the fiddly part.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #140.
Nothing checked the documentation links, so broken ones accumulated. Cleaning up the schema docs in
#120 turned up nine pre-existing breakages: source paths that had moved (
SQLite/SQLiteWriter.cs,SQLite/Handler/MeshHandler.cs,Parsers/Models/BuildLayout.cs), a link to anIWriterinterfacethat no longer exists, anchors left behind when the per-command pages were split out
(
unitydatatool.md#dump), three links with the wrong relative depth, and one missing its URL scheme.Those matter more since #118 put
Documentation/in the release zip: someone reading the docs offlinefrom the zip cannot fall back to searching GitHub when a link dies.
This adds a test that walks the repository's markdown, resolves every relative target and every
anchor, and fails with the full list.
A test rather than a new workflow or a third-party action, because
test.ymlalready runsdotnet teston Linux, macOS and Windows for every PR — so this needs no CI changes at all — andbecause it doubles as the local tool via
dotnet test --filter DocumentationLinks.AGENTS.mdalready instructs agents to run the test suite, so agents get the check without being told about it.
The repo has no
package.jsonor lint infrastructure, and introducing a Node or Rust toolchain forone check would be disproportionate.
Internal links only. 345 of the repo's 426 links are internal, and all nine breakages above were
internal, so this covers the whole observed failure mode while staying deterministic and offline.
External URLs need the network and produce false failures from rate limits and bot blocking, which
must never stand between a change and a merge. External link rot can be handled later by a scheduled
job if it becomes a problem.
Changes
One new file,
UnityDataTool.Tests/DocumentationLinkTests.cs. No production code and no CI changes.AllInternalLinksResolvewalks every*.mdin the repo exceptbin,obj,.gitandLibrary(Unity's package cache, which is third-party markdown we do not maintain), and reports every
unresolved target and anchor as
file:line missing target|anchor <link>.not mistaken for links.
File.Exists, which iscase-insensitive on Windows and macOS. A wrong-case link like
../Analyzer/resources/Init.sqlpasses locally and breaks only for Linux users; this catches it everywhere.
-1/-2suffixes.command-archive.mdalready has fiveQuick Referenceand fiveExampleheadings, so a naive implementation would reject a legitimate#example-2.## dangling_refs / dangling_refs_viewanchors as#dangling_refs--dangling_refs_view— ananchor this repo genuinely used, and the evidence that settled the rule.
UnityDataTools.slnand reportsinconclusive rather than failing if it cannot, so a run from a packaged location does not break.
Testing
dotnet build -c Release— clean, 0 warnings.dotnet format whitespace --verify-no-changesreports nothing for the new file.
dotnet test -c Release— full suite green: 802 passed, 0 failed. The 13 new tests areAllInternalLinksResolve, 11 slug cases and the repeated-heading case; the link walk takes ~90 ms.a temporary fixture page it detected exactly the five breakage classes from Analyzer: Init.sql schema comments never reach the produced database #120 — stale relative
path, dead anchor, wrong relative depth, missing URL scheme, and case mismatch (caught on Windows)
— while correctly accepting a valid path, a valid anchor, a
#example-2dedup anchor, a link to adirectory, and an unreachable external URL, and while ignoring links inside inline code and fenced
blocks. The fixture was removed afterwards.
computing slugs dropped the code text, so
## How \analyze` represents thisslugged ashow-represents-this`. The slug unit tests exist because of that.🤖 Generated with Claude Code