Skip to content

fix: resolve more intra-repo doc links and add tests#16

Merged
dgaponov merged 7 commits into
mainfrom
feat/docs-link-rewrite-and-tests
Jul 15, 2026
Merged

fix: resolve more intra-repo doc links and add tests#16
dgaponov merged 7 commits into
mainfrom
feat/docs-link-rewrite-and-tests

Conversation

@dgaponov

Copy link
Copy Markdown
Contributor

Follow-up to #14, addressing review feedback on gravity-ui/uikit#2740.

Link rewriting (rewriteDocLinks)

Previously only links whose target contained README.md were rewritten; everything else shipped unchanged, which left dead links in the docs and contradicted the "no dead link remains" docstring. Now any repo-relative link is handled:

  • Bare-folder links[Portal](../Portal) resolves to the sibling doc ./Portal.md (READMEs are now keyed by their folder as well as their file path). Verified on uikit: ../Portal, ../Icon, ../Button all resolve; zero dead ../Name links remain.
  • Links to non-shipped files[actions](./types.ts#L9), unshipped legacy/, etc. are unwrapped to plain text (link text kept).
  • External URLs and in-page anchors (#section) are left untouched.

Other

  • Empty-name guard: a README.md sitting directly at a baseDir was silently emitting components/.md; such items are now skipped.
  • Tests: added node:test coverage (run in CI) —
    • cleanMarkdown drops SANDBOX/LANDING, keeps GITHUB_BLOCK content, strips badges;
    • extractSummary skips the import fence / is empty when a heading follows the title / unwraps links;
    • an integration test for buildDocs link rewriting (README-path, bare-folder, unwrap, external, legacy exclusion, index) against a small fixture package.
    • Adds tsx as a dev dependency and a test step to CI.

Not changed: reference-style link syntax and the extractSummary heuristic (Sourcery's notes) — the summary convention is intentional (empty when a README doesn't follow it), and no docs use reference-style links today; can revisit if that changes.

🤖 Generated with Claude Code

Address PR review on gravity-ui/uikit#2740:

- rewriteDocLinks now handles any repo-relative link, not just README.md
  targets: bare-folder links (../Portal) resolve to the sibling doc, and links
  to non-shipped files (../types.ts, unshipped legacy/) are unwrapped to plain
  text — keeping the "no dead link remains" promise. External URLs and in-page
  anchors are left untouched.
- Skip a README sitting directly at a baseDir (empty name → blank index entry).
- Add node:test coverage for cleanMarkdown/extractSummary/extractTitle and an
  integration test for buildDocs link rewriting, and run it in CI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
dgaponov and others added 6 commits July 14, 2026 18:27
buildDocs now lifts the package README's `For AI agents` section (cleaned)
to the top of the generated INDEX.md, and appends a `Documentation for AI
agents` pointer section to that README (idempotently) linking to the
generated tree. Adds `extractSection` helper and tests for both behaviors.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the hand-rolled README parsing used to form INDEX.md with
@gravity-ui/readme-validator, which parses on a real Markdown AST:

- component title/summary via parseComponentReadme
- package overview (For AI agents positioning + prose, Install, Usage)
  via parsePackageReadme

Drop the now-unused extractSummary/extractTitle (and their exports);
keep cleanMarkdown/extractSection for doc-body cleanup and pointer
idempotency. Add an ambient d.ts since the package ships no types, and
pin engines.node >=20.19 (readme-validator is ESM-only; CJS consumers
require() it).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1.2.3 ships a real CommonJS entry (plus matching types), so the CJS
build of gulp-utils can require() it — 1.2.2 was ESM-only and broke
CommonJS consumers (uikit's gulpfile). Drop the local ambient d.ts now
that the package bundles its own type declarations.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dgaponov
dgaponov requested a review from korvin89 July 15, 2026 13:42
@dgaponov
dgaponov merged commit ac4d753 into main Jul 15, 2026
2 checks passed
@dgaponov
dgaponov deleted the feat/docs-link-rewrite-and-tests branch July 15, 2026 13:46
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