feat(markdown): render inline {@link Target} references as links#181
feat(markdown): render inline {@link Target} references as links#181Kiarokh wants to merge 3 commits into
Conversation
When an inline `<code>` element already sits inside an `<a>` (for example, from a markdown link like `[label `Foo`](url)`), the typeLinks pass would wrap the type token in another anchor and produce a nested `<a>`, which is invalid HTML and confuses navigation. Generalises the existing `<pre><code>` skip-set into a more general "skippable code" set that also captures `<code>` inside any anchor ancestor, and leaves those code elements untouched. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
JSDoc/TSDoc `{@link Target}` references in component descriptions
previously surfaced in the generated docs as literal text. Adds a remark
plugin that rewrites them into mdast link nodes during the markdown
pipeline, supporting the standard syntactic forms:
{@link Target}
{@link Target Display text}
{@link Target | Display text}
{@link https://example.com | Display text}
Targets are resolved against the project's known types and component
tags (a new component registry mirrors the existing type registry).
Bare-identifier references — those without an explicit display label —
are wrapped in `<code>` so they visually match how type names render
elsewhere in the docs. Unresolved targets still render as inline code
rather than dangling syntax, and absolute URLs link directly.
References inside inline code (``{@link Foo}``) and fenced code blocks
are intentionally left untouched so the syntax itself can be documented.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds a dedicated `kompendium-example-inline-links` example component
attached to `kompendium-markdown` so the rendered docs page shows each
inline `{@link …}` syntactic form alongside its source. The integration
test renders the example against the actual built `kompendium.json`
registry to keep the showcase honest as the docs build evolves.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthroughThis PR adds TSDoc/JSDoc ChangesInline
Sequence DiagramsequenceDiagram
participant App as App.fetchData()
participant Registry as markdown-types
participant MarkdownTsx as Markdown.renderMarkdown()
participant Pipeline as markdownToHtml()
participant Normalize as normalizeInlineLinkUrls()
participant Resolver as createLinkResolver()
participant InlineLinks as inlineLinks()
participant TypeLinks as typeLinks()
participant HTML as HTML Output
App->>Registry: setTypes(typeNames)
App->>Registry: setComponents(componentTags)
MarkdownTsx->>MarkdownTsx: types = getTypes()
MarkdownTsx->>MarkdownTsx: components = getComponents()
MarkdownTsx->>Pipeline: markdownToHtml(text, types, components)
Pipeline->>Normalize: normalizeInlineLinkUrls(text)
Normalize->>Pipeline: markdown with [label](url) links
Pipeline->>Resolver: createLinkResolver(types, components)
Resolver->>Pipeline: resolver: (target) => url | null
Pipeline->>InlineLinks: inlineLinks({resolve})
InlineLinks->>InlineLinks: walk mdast text nodes
InlineLinks->>Resolver: resolve(target)
Resolver->>InlineLinks: `#/type/X` or `#/component/Y/`
InlineLinks->>Pipeline: mdast link nodes
Pipeline->>TypeLinks: typeLinks() transformer
TypeLinks->>TypeLinks: collect skippable code (inside pre or anchor)
TypeLinks->>Pipeline: avoid wrapping types in links
Pipeline->>HTML: final HTML with resolved links
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
JSDoc/TSDoc
{@link Target}references inside component descriptionspreviously surfaced in the generated docs as literal text — readers saw
{@link Rule}verbatim with nothing clickable. This PR teaches themarkdown pipeline to rewrite those references into proper links, the
same way IDEs interpret them for cmd-click navigation.
The change is split into three atomic commits:
fix(markdown): skip type-linking inside anchor ancestors— Aprerequisite bug fix in
typeLinks. Without it, a<code>elementinside an existing
<a>would get its type token wrapped in asecond
<a>, producing invalid nested anchors. Generalises theexisting
<pre><code>skip-set into a broader "skippable code" setthat also captures code inside any anchor ancestor.
feat(markdown): render inline {@link Target} references as links— Adds a remark plugin that walks mdast text nodes for{@link …}syntax and emits link nodes. Supports the three TSDocforms (
{@link Target},{@link Target Display},{@link Target | Display}) plus absolute URLs. Targets are resolvedagainst the project's known types and component tags via a new
component registry that mirrors the existing type registry. Bare
identifiers are wrapped in
<code>so they match how type namesrender elsewhere; unresolved targets still render as inline code
instead of bare prose; references inside inline and fenced code are
intentionally left untouched.
docs(markdown): add example demonstrating inline @link references— Addskompendium-example-inline-linksso therendered
kompendium-markdownpage shows each syntactic formalongside its source. An integration test pins the rendered HTML
against the actual built
kompendium.jsonregistry to keep theshowcase honest.
Behaviour matrix
{@link MenuItem}(known type)<a href="#/type/MenuItem"><code>MenuItem</code></a>{@link kompendium-markdown}(known component)<a href="#/component/kompendium-markdown/"><code>kompendium-markdown</code></a>{@link MenuItem | the menu item}(free-form label)<a href="#/type/MenuItem">the menu item</a>{@link https://example.com | docs}(absolute URL)<a href="https://example.com">docs</a>{@link Unknown}(unresolved bare identifier)<code>Unknown</code>`{@link Foo}`(inside inline code){@link Foo}inside```fenced blockTest plan
(
markdown-inline-links.spec.ts)forms, inline-code passthrough, fenced-code passthrough, and URL
targets (
markdown.spec.ts)Kompendium's own built registry (
markdown-example-integration.spec.ts)npm run buildcleannpm run lint:srccleannpm test— 115 passing, 5 pre-existing skipsnpm start→ navigate tokompendium-markdown→visually verify the new "Inline @link references" example
Notes
contain no
{@link …}references are unaffected.(nested
<a>is invalid HTML) and is a hard prerequisite for thefeature: without it,
{@link KnownType}would produce nested anchors.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
{@link...}syntax support for creating clickable documentation links to components, types, and external URLsTests