You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Web site Table of content for each page as right side panel #20514
We add some navigation somewhere, as lots of documentation websites do.
This way I can easily see and navigate to the use case that fits me.
Many documentation websites display an "In this article" style panel listing the major sections of the current page, allowing users to quickly jump to the section relevant to them without scrolling through the entire page.
We should investigate adding something similar to checkstyle.org documentation pages, especially check pages which can be long and contain multiple sections (Description, Examples, Properties, etc.).
What to investigate
Whether the current Maven Fluido Skin (2.0.1) supports an in-page TOC out of the box, or via configuration.
If not, whether it can be added via custom JavaScript/CSS in the existing checkstyle.js or a new script included via site.xml's block.
What sections to include — at minimum the top-level and elements already present in each XDoc page.
Whether the solution works consistently across both check pages and general documentation pages (writingchecks, config, etc.).
Acceptance criteria
An "In this article" (or equivalent) panel is visible on documentation pages,
listing the major sections of that page.
Clicking a section link scrolls/navigates to that section.
The active section is highlighted as the user scrolls.
I would avoid custom js. Better to stay plain html, to work everywhere, and has no maintenance updates.
We have mobile view also, keep in mind. Not sure how it will be rendered
I would avoid custom js. Better to stay plain html, to work everywhere, and has no maintenance updates. We have mobile view also, keep in mind. Not sure how it will be rendered
Okay 👍 , we can have a macro inject the html to .xml pages
Investigated all available options for adding in-page section navigation.
Option 1 — JavaScript-based dynamic TOC
How it works: A JS library scans the rendered page for headings at runtime and builds the TOC panel automatically. Highlights the active section as you scroll.
How it works: Apache Doxia has a built-in TOC macro that reads sections from the document and generates anchor links. In APT format it looks like %{toc section=2 fromdepth=2 todepth=3}. In XDoc format it would be <macro name="toc">.
Who uses it: Apache Maven's own docs use it in .apt files.
Why it doesn't work for checkstyle: I tested it. The built-in Doxia toc macro only works in APT format (.apt files). Checkstyle's pages are in XDoc format (.xml / .xml.template). When <macro name="toc"> is placed in an XDoc file, Doxia simply ignores it and produces no output , nothing renders. This is a known Doxia limitation: the TOC macro is APT-only. There is no equivalent built-in macro for XDoc.
Option 3 — Plain HTML <div> with anchor links directly in each .xml file
How it works: A hardcoded <ul> of <a href="#anchor"> links placed at the top of the page section. Pure HTML, no JS, no dependencies, works everywhere including mobile.
Sites that use this approach: Wikipedia (https://en.wikipedia.org) — every article has a plain HTML "Contents" box with anchor links generated at render time from headings. No JS required for basic navigation.
Downside : Must be manually added to and maintained in every .xml file. If a subsection is renamed or removed, the link silently breaks.
How it works: A new Java class extending Doxia's AbstractMacro, registered as <macro name="toc">. Called from .xml.template files with the sections list as a parameter. Outputs the same plain HTML <ul> as Option 4, but generated at build time — so it's consistent, maintainable, and follows the exact same pattern already used by checkstyle's existing macros (since, properties, description, parent-module, violation-messages).
No external sites needed , this is the checkstyle-native approach following existing patterns already in the codebase.
changed the title [-]Investigate adding in-page section navigation to documentation pages[/-][+]Web site Table of content for each page as right side panel[/+]on Aug 9, 2026
Activity
stoyanK7 commentedon Jul 1, 2026
@romani Are you okay with such proposal/investigation? I am ok.
romani commentedon Jul 1, 2026
I would avoid custom js. Better to stay plain html, to work everywhere, and has no maintenance updates.
We have mobile view also, keep in mind. Not sure how it will be rendered
smita1078 commentedon Jul 2, 2026
Okay 👍 , we can have a macro inject the html to .xml pages
stoyanK7 commentedon Jul 2, 2026
We have to see how others do it. I believe they put it like Table of Contents at the top of page.
smita1078 commentedon Jul 2, 2026
Investigated all available options for adding in-page section navigation.
Option 1 — JavaScript-based dynamic TOC
How it works: A JS library scans the rendered page for headings at runtime and builds the TOC panel automatically. Highlights the active section as you scroll.
Sites that use it:
<h2>headings on every page renderjs/tocbot/) to generate the sidebar TOC dynamicallyOption 2 — Doxia built-in
tocmacro (investigated and ruled out)How it works: Apache Doxia has a built-in TOC macro that reads sections from the document and generates anchor links. In APT format it looks like
%{toc section=2 fromdepth=2 todepth=3}. In XDoc format it would be<macro name="toc">.Who uses it: Apache Maven's own docs use it in
.aptfiles.Why it doesn't work for checkstyle: I tested it. The built-in Doxia
tocmacro only works in APT format (.aptfiles). Checkstyle's pages are in XDoc format (.xml/.xml.template). When<macro name="toc">is placed in an XDoc file, Doxia simply ignores it and produces no output , nothing renders. This is a known Doxia limitation: the TOC macro is APT-only. There is no equivalent built-in macro for XDoc.Option 3 — Plain HTML
<div>with anchor links directly in each.xmlfileHow it works: A hardcoded
<ul>of<a href="#anchor">links placed at the top of the page section. Pure HTML, no JS, no dependencies, works everywhere including mobile.Sites that use this approach: Wikipedia (https://en.wikipedia.org) — every article has a plain HTML "Contents" box with anchor links generated at render time from headings. No JS required for basic navigation.
Downside : Must be manually added to and maintained in every
.xmlfile. If a subsection is renamed or removed, the link silently breaks.Option 4 — Custom
TocMacro.java(Doxia custom macro)How it works: A new Java class extending Doxia's
AbstractMacro, registered as<macro name="toc">. Called from.xml.templatefiles with the sections list as a parameter. Outputs the same plain HTML<ul>as Option 4, but generated at build time — so it's consistent, maintainable, and follows the exact same pattern already used by checkstyle's existing macros (since,properties,description,parent-module,violation-messages).No external sites needed , this is the checkstyle-native approach following existing patterns already in the codebase.
stoyanK7 commentedon Jul 3, 2026
If we want to stay plain HTML (and some CSS, obviously), Option 4 seems most reasonable to me.
Issue checkstyle#20514: Adding Table of Content to Website
Issue checkstyle#20514: Added Table on content to website
Issue checkstyle#20514: Added Table on content to website
Issue checkstyle#20514: Added Table on content to website
Issue checkstyle#20514: Added Table on content to website
Issue checkstyle#20514: Added Table on content to website
Issue checkstyle#20514: Added Table on content to website
Issue checkstyle#20514: Added Table on content to website
34 remaining items
Issue checkstyle#20514: Code changes for enabling toc in website
Issue checkstyle#20514: Added xml and xml template toc changes
Issue checkstyle#20514: Code changes for enabling toc in website
Issue checkstyle#20514: Added xml and xml template toc changes
Issue checkstyle#20514: Code changes for enabling toc in website
Issue checkstyle#20514: Added xml and xml template toc changes
Issue checkstyle#20514: Code changes for enabling toc in website
Issue checkstyle#20514: Added xml and xml template toc changes
Issue checkstyle#20514: Code changes for enabling toc in website
Issue #20514: Added xml and xml template toc changes
Issue #20514: Code changes for enabling toc in website
romani commentedon Aug 9, 2026
main fix is merged, all polishing will be in separate ticket.
[-]Investigate adding in-page section navigation to documentation pages[/-][+]Web site Table of content for each page as right side panel[/+]