Skip to content

Fix dead search-index links in single HTML layout#16

Open
Reefact wants to merge 1 commit into
mainfrom
claude/search-index-single-layout-u3cizj
Open

Fix dead search-index links in single HTML layout#16
Reefact wants to merge 1 commit into
mainfrom
claude/search-index-single-layout-u3cizj

Conversation

@Reefact

@Reefact Reefact commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Problem

HtmlErrorDocumentationRenderer.Render emits assets/search-index.json for both layouts, but BuildSearchIndex hard-coded every entry's href as errors/{FileName}.

In the single layout, no per-error page is produced — RenderSingle emits a single index.html, and errors live there as #err-… anchors (<article id="err-…">). The search index, documented as being for external tooling, therefore pointed at errors/*.html pages that don't exist → dead links.

Fix

  • Pass the layout down to BuildSearchIndex.
  • Emit index.html#err-{Anchor} in single, keep errors/{FileName} in split.

The anchor stem is code-derived (SafeStem → only [A-Za-z0-9._-]), so it needs no percent- or HTML-encoding; it goes through JsonString like the other fields for consistency.

Tests

Added to HtmlErrorDocumentationRendererTests:

  • split: the index links each error to its own errors/*.html page.
  • single: the index links each error to its index.html#err-… anchor, contains no errors/ href, and the referenced anchors actually exist in the rendered page.

Note

I couldn't run the test suite in this sandbox — the .NET 10 SDK isn't installed and the network policy blocks Microsoft's download hosts (builds.dotnet.microsoft.com → 403). The existing CI workflow (analyzers.yml) only builds/tests the Analyzers project, so it won't exercise these GenDoc tests either. The change is small and was reviewed manually; please run dotnet test FirstClassErrors.GenDoc.UnitTests to confirm.

🤖 Generated with Claude Code


Generated by Claude Code

BuildSearchIndex hard-coded every href as errors/{FileName}, but in the
single layout no per-error page is emitted — errors are #err-… anchors
inside index.html. The search-index.json (meant for external tooling)
therefore pointed at pages that do not exist.

Pass the layout down and emit index.html#err-{Anchor} in single,
keeping errors/{FileName} in split. Adds tests covering the href for
both layouts and asserting the single anchors actually exist in the page.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VM8CCnaRUkkzeRQum4Bgfe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants