Skip to content

docs: link manpage cross-references in HTML output#4246

Open
grandixximo wants to merge 4 commits into
LinuxCNC:masterfrom
grandixximo:feat/man-xref-links
Open

docs: link manpage cross-references in HTML output#4246
grandixximo wants to merge 4 commits into
LinuxCNC:masterfrom
grandixximo:feat/man-xref-links

Conversation

@grandixximo

@grandixximo grandixximo commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Addresses #4244.

What

Adds an asciidoctor postprocessor (docs/src/extensions/man_xref.rb) that turns name(section) manpage references (halcmd(1), stepgen(9), ...) into clickable links to the corresponding HTML page. Applied to both:

  • the generated HTML manpages (sibling links under man/), and
  • the narrative manuals (User/HAL/Integrator), which cite man pages in the same form and now link across into ../man/manN/.

Wired into both HTML rules in docs/src/Submakefile. Per-page manxref-root (troff tree) and manxref-linkbase (depth-adjusted path) attributes drive it; absent => no-op.

How it stays correct

Index-gated: a token links only when a real page name.section exists in that language's troff tree. Common false positives resolve to nothing and stay plain, with no skip list:

  • enum values, e.g. feed(2)/arc(3) in motion(9)
  • external pages, e.g. open(2), printf(3), udev(8)
  • value literals in prose, e.g. TRUE(1), time.sleep(1)
  • typo'd or renamed names

Also: never self-links; skips <a> <code> <pre> <script> <style> <head> <title> <h1> (code, attributes, existing links untouched); case-insensitive match with verbatim visible text.

Verification

  • Manpages: 279 links, 89 targets, 0 broken, 0 self-links.
  • Narrative (English): 6 links, all resolve; second build a clean no-op.
  • Per-language: index-gating links only man pages translated in that language (e.g. a German narrative page links the German man page, into de/man/).
  • A full BUILD_DOCS_TRANSLATED=yes build currently cannot complete due to a pre-existing po4a NAME-drift issue (a stray space in a German man page NAME yields a dangling .so alias), tracked in docs: pin manpage troff filename to the make target #4193 / CI: Check html links for doc #4178. Unrelated to this change; the links themselves render correctly per language.

Also included

Source refs the linker surfaced as broken, fixed to the real pages:

  • motion(1) => motion(9) in hal_manualtoolchange(1)
  • hal_thread_new(3) => hal_create_thread(3) in hal_add_funct_to_thread(3)
  • stegen(9) => stepgen(9) in the hostmot2 driver docs

Notes

  • Pre-existing explicit link: refs (e.g. SSERIAL(9), debounce(9)) are left untouched: the postprocessor skips anything already inside an <a>.
  • hm2_uart_setup_chan(3) in hostmot2(9) names no existing page; left as-is. @pcw-mesa stale/renamed name, or a missing page?

Add an asciidoctor postprocessor that turns name(section) references in the
HTML manpages into clickable links to the sibling page. Index-gated against
the rendered troff tree so false positives (enum values, external and
misspelled pages) stay plain text; self-links, code spans and existing
links are left untouched. Wired into the manpage HTML rule via manxref-root.
motion(1) and hal_thread_new(3) name pages that do not exist. Point them at
the actual pages motion(9) and hal_create_thread(3).
Extend the man_xref postprocessor to the User/HAL/Integrator HTML
manuals, which cite man pages in the same name(section) form. A
per-page manxref-linkbase attribute carries the depth-adjusted path to
the language's man/man<N>/ tree; manpages keep the sibling default.
Index-gated as before, so only real pages link and prose like TRUE(1)
stays plain.
@grandixximo
grandixximo force-pushed the feat/man-xref-links branch from 1be89ba to 653e6cf Compare July 17, 2026 03:45
@grandixximo
grandixximo requested a review from BsAtHome July 17, 2026 04:29
@BsAtHome

Copy link
Copy Markdown
Contributor

Some parts of the manual pages are a bit stale and needs cleaning up. In fact, I was doing exactly that for the hal_*(3) set of pages and adding a lot of them when this issue of linking caught my attention.

@grandixximo

Copy link
Copy Markdown
Contributor Author

Should I drop the doc fixes then? just have the script?

@BsAtHome

Copy link
Copy Markdown
Contributor

Should I drop the doc fixes then? just have the script?

No, your fixes are just fine.

The "other" fixes is to read them all from start to end, fix inconsistencies, add missing, remove obsolete and reformat them to become uniform. But that is a different affair of incremental changes over a longer period.

@BsAtHome

Copy link
Copy Markdown
Contributor

One thing though, maybe add to lcnc-overrides.css:

.man-xref {
  font-family: monospace;
  font-size: 90%;
}

We'll tackle the spurious bolds, italics and splits (*name*(sect)) is a cleanup session to make things consistent.

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