Skip to content

Add the Antora xref text extension for spec repos - #261

Merged
Kersten Richter (kersten1) merged 1 commit into
mainfrom
add-xref-text-extension
Sep 23, 2026
Merged

Kersten Richter (kersten1) merged 1 commit into
mainfrom
add-xref-text-extension

Conversation

@wmat

Copy link
Copy Markdown
Collaborator

Adds antora-extensions/xref_text_extension.js, so specification repositories can use it in the Antora builds they run themselves.

Why

A cross-page reference written without link text:

<<chapter.adoc#some-id>>        xref:chapter.adoc#some-id[]

resolves to the right page in Antora, but the link text comes out as the raw target (chapter.adoc#some-id). Specs single-sourced for both the PDF and the site write their cross-chapter links this way, because the PDF build generates the text itself ("Section 2.3", "Table 5", "IRR4"). The extension supplies that text on the site, using the target's reftext or its section or table title.

The same extension already runs on the central dev site (riscv-admin/antora-dev.riscv.org#47). The central playbooks register their own copies, since a site build cannot load code from a content source. It lives here so that the builds a spec repo runs itself get the same treatment:

  • the local preview (npm run preview),
  • the pull-request preview from validate-content-source.yml,
  • the repo's GitHub Pages site.

Effect on repos consuming this submodule

None, unless a repo opts in. The file is inert until a repo registers it in its own antora-playbook.yml:

  • The common Antora component is unchanged: Antora publishes antora.yml and modules/ only, so a new top-level directory is invisible to the site build.
  • PDF builds are unchanged: they read global-config.adoc, themes/, fonts/ and images/ by path, and no existing file is touched.
  • Submodules are a single gitlink to a consuming repo's linters, so repo checks don't see it.

Dependabot will propose the usual submodule bump in consuming repos; merging it changes nothing by itself.

One ordering rule, in the README: a repo should register the extension only once its submodule points at a commit containing it, otherwise Antora fails with Cannot find module. Bump the submodule in the same PR as the registration. This is caught by a repo's own PR check, never on a published site.

Testing

With this branch checked out as the docs-resources submodule of riscv/riscv-high-assurance-cryptography (migrated to the current template), and registered in its antora-playbook.yml:

  • the component builds with 0 errors and the extension filled the link text for all 175 cross-chapter links, none left as a raw target;
  • scripts/gen-pages-playbook.js carries the registration into the generated GitHub Pages playbook unchanged;
  • the file is byte-identical to the copy merged in antora-dev.

🤖 Generated with Claude Code

A cross-page reference written without link text, e.g.
<<chapter.adoc#some-id>> or xref:chapter.adoc#some-id[], resolves in
Antora but renders its raw target as the link text. A specification
single-sourced for both the PDF and the site writes its cross-chapter
links that way, because the PDF build generates the text itself
("Section 2.3"). The extension supplies that text on the site from the
target's reftext, or its section or table title.

The same extension already runs on the central dev site
(riscv-admin/antora-dev.riscv.org#47). It lives here as well so each
spec repo can register it for the Antora builds it runs itself: the
local preview, the pull-request preview, and its GitHub Pages site,
none of which use the central playbook.

Nothing consumes it automatically: it applies only where a repo's
antora-playbook.yml registers it, as the README describes. The `common`
Antora component published from this repo is unaffected, since Antora
publishes antora.yml and modules/ only.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: Bill Traynor <wmat@riscv.org>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kersten1
Kersten Richter (kersten1) merged commit 3184f3f into main Sep 23, 2026
7 checks passed
@kersten1
Kersten Richter (kersten1) deleted the add-xref-text-extension branch September 23, 2026 00:35
mocenigo (mocenigo) pushed a commit to riscv/riscv-high-assurance-cryptography that referenced this pull request Sep 23, 2026
Antora renders a cross-chapter link written without link text, e.g.
<<Zkl-notation.adoc#KLEE-Notation>>, as its raw target. The PDF build
generates that text itself ("Section 1", "Table 5", "IRR4").

riscv/docs-resources#261 added the Antora extension that supplies the
text on the site, from the target's reftext or its section or table
title. Register it from the submodule, and bump docs-resources to the
commit that has it: Antora fails with "Cannot find module" if the
registration lands first.

This covers the Antora builds this repo runs itself: the local preview
and the pull-request preview, plus its GitHub Pages site once that is
set up. The central site registers its own copy.

The PDF is unchanged (text identical).

Signed-off-by: Bill Traynor <wmat@riscv.org>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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