Skip to content

Web site Table of content for each page as right side panel #20514

Closed

Description

@smita1078

As suggested in #20467 (review) :

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.).

Image

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.

Examples:
https://docs.oracle.com/en/java/javase/11/javadoc/javadoc-command.html

Activity

  1. stoyanK7 commented on Jul 1, 2026

    @stoyanK7
    Collaborator

    @romani Are you okay with such proposal/investigation? I am ok.

  2. romani commented on Jul 1, 2026

    @romani
    Member

    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

  3. smita1078 commented on Jul 2, 2026

    @smita1078
    MemberAuthor

    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

  4. stoyanK7 commented on Jul 2, 2026

    @stoyanK7
    Collaborator

    We have mobile view also, keep in mind. Not sure how it will be rendered

    We have to see how others do it. I believe they put it like Table of Contents at the top of page.

  5. smita1078 commented on Jul 2, 2026

    @smita1078
    MemberAuthor

    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:


    Option 2 — Doxia built-in toc macro (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 .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.


    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.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.

  6. stoyanK7 commented on Jul 3, 2026

    @stoyanK7
    Collaborator

    If we want to stay plain HTML (and some CSS, obviously), Option 4 seems most reasonable to me.

  7. added a commit that references this issue on Jul 6, 2026
  8. added 7 commits that reference this issue on Jul 18, 2026
  9. 34 remaining items

  10. added 9 commits that reference this issue on Aug 8, 2026
  11. added 2 commits that reference this issue on Aug 9, 2026
  12. added this to the 13.10.0 milestone on Aug 9, 2026
  13. romani commented on Aug 9, 2026

    @romani
    Member

    main fix is merged, all polishing will be in separate ticket.

  14. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

approvedmiscellaneouswebsite

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions