Skip to content

Render title headers at their final levels - #324

Merged
rich-iannone merged 23 commits into
posit-dev:mainfrom
has2k1:title-heading-rendering
Aug 19, 2026
Merged

Render title headers at their final levels#324
rich-iannone merged 23 commits into
posit-dev:mainfrom
has2k1:title-heading-rendering

Conversation

@has2k1

@has2k1 has2k1 commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

This PR corrects the heading structure of generated reference pages. Object pages previously rendered the title at h2, docstring sections at h4, and members at h5, and every page carried two h1 elements: the page title and the secondary navigation label. Two post-render transforms caused the shift, one of which also rewrote navigation and footer headings. Headings are now emitted at their final levels during rendering rather than corrected afterwards.

The PR also introduces doc-*-reference and doc-*-api-page classes to disambiguate the reference and api pages,

Page Emitted <body> classes
Python reference doc-reference doc-py-reference
MCP reference doc-reference doc-mcp-reference
CLI reference doc-reference doc-cli-reference
Python object page doc-api-page doc-py-api-page
MCP tool / resource / template / prompt doc-api-page doc-mcp-api-page
CLI command page doc-api-page doc-cli-api-page

Breaking Change

The title styling rule moves from h2.title to .doc-py-reference h1.title, because the title is now genuinely an h1. The renderer emits a new doc-py-reference body class on API reference pages so the rule can target them specifically instead of matching every h1.title on the site.

has2k1 added 23 commits August 19, 2026 16:05
Reference titles style object names through the doc-object-name span. Assert that span instead of the removed inline style attribute.
Five post-render rewrites cannot match current HTML: object names are wrapped in spans, the parenthesis rewrite has no effect, the targeted section-heading level is absent, title wrapping searches for markup produced later, and the inline font duplicates the stylesheet. Remove them. Rendered reference HTML changes only by losing the redundant inline style.
Two post-render transforms shifted object-page headings. The file-wide transform also changed navigation and footer headings, while the main-content transform demoted the title. Pages therefore rendered the title at h2, sections at h4, and members at h5.

Remove the file-wide transform. Keep the title at h1 and shift only its sections and members to h2 and h3. Scope the compact title style to API object pages.
Match the title class within any class list so Quarto's additional display classes cannot expose the title to the heading shift.

Add a Python-reference body class and scope the compact title rule to it. MCP pages share the general API page class but retain their standard title size. Extend the heading test to cover member headings.
Require every reference-index group heading to render at h2, directly below the h1 page title.
Reference, CLI and MCP pages rendered both the page title and the secondary navigation label as h1. Render the navigation label as h5 and target its styles and status icon by class rather than heading tag.

Use one helper to nest object-page and reference-index headings below their titles. Scope compact title sizing to Python object pages, excluding the reference index.
Count page-level sections and class members independently so a Parameters section cannot satisfy the member coverage guard. Add the mixed-docstring fixture, skip packages without members, and require the full fixture set to exercise the h3 assertion.

Restrict section checks to level2 so member-nested sections are excluded. Remove requirement identifiers from the test names.
Disable the site-wide heading shift on API object pages and the reference index. Render titles at h1, docstring sections at h2, and members at h3 without post-render compensation.

Update fallback docstring sections and member separators to use those final levels. Raise the table-of-contents depth to include members and subtitled index sections.
Bootstrap adds a top margin to the new h5 navigation label, moving it below the sidebar toggle. Override that margin with the same importance as Bootstrap's rule.
Extend the heading hierarchy test from main content to the complete document. Each object page must contain one h1 page title, while the secondary navigation label remains h5.
Keep subtitle-only reference sections in generated configuration instead of renaming them Untitled. They now render at h3 and appear in the sidebar and table of contents beside h2 titled sections.

Render fallback docstring sections at h4 inside h3 class members and at h2 for top-level objects. Add rendered fixtures and assertions for both paths.
Use a section's subtitle when its title is absent while generating llms.txt, the AI guide and the skill overview. Subtitle-only sections now retain their headings instead of merging into the preceding section.
Fallback translators process the same member in sequence. After the first emits an h4 section, the next must still recognise member context instead of returning to h2.

Treat any preceding heading at h3 or deeper as member context. Add a fixture whose method exercises field and bold-section fallbacks together.
Update the synthetic package metadata and README to describe four titled sections and one subtitled section.
Verify that subtitle-only sections keep their own headings in llms.txt, llms-full.txt and skill.md. Check the section body so an entry under the preceding heading cannot pass.

Verify that class pages contain one solid rule after the member summary and one dotted rule between each pair of members.
Quarto renders secondary navigation as a breadcrumb nav when breadcrumbs are enabled and as a bare h1 when they are disabled. Replace either form with the h5 navigation label and remove any duplicate breadcrumb in the title block.

Use the shared replacement for API, MCP and CLI pages. Add a site-wide no-breadcrumb fixture that requires one h1 page title and the h5 navigation label.
CLI command pages wrote a body title in addition to the front matter title. Remove the duplicate, disable heading shifts on CLI pages, and render body sections at h2.

MCP pages retain the site-wide shift, so write their body sections one level deeper. Add rendered coverage for CLI and MCP object pages and indexes.
CLI command titles wrap the command name in a span. Read the complete h1 text when building the navigation label instead of falling back to a filename-derived name.

Process nested command pages recursively. Update sidebar assertions for the labelled CLI index entry and verify labels on flat and nested pages.
Top-level docstring sections render at h2, while sections inside members render at h4. Target the shared section class instead of a heading tag so standard and warning styles apply at either depth.
Class member headings require a table-of-contents depth of 3. Read the merged depth from generated Quarto configuration or source site configuration, pass it to each page, and add an override only when the site setting is shallower.

Apply the same rule to subtitle headings on the reference index. Preserve user-configured depths above 3 and verify that class members appear in the rendered table of contents.
MCP pages retain the site-wide heading shift because disabling it prevents Quarto from hoisting the marked title and creates a duplicate title. Record why source sections start one level deeper than API reference sections.
When a reference section has no title, display its subtitle in great-docs scan --verbose instead of Untitled. This matches the rendered index and other generated outputs.
Every reference index and API page now carries a page-kind class plus that
class prefixed by its family: doc-reference with doc-py-reference,
doc-mcp-reference or doc-cli-reference, and doc-api-page with
doc-py-api-page, doc-mcp-api-page or doc-cli-api-page.

MCP object pages previously carried no family class, so a style could reach
them only by excluding the other families. Python object pages and the Python
reference index shared one class, which forced the compact title rule to match
on two classes and left the index carrying a class no rule used.

Drop doc-reference-index, which marked the same three pages as doc-reference
and nothing else. The copy-page widget now skips index pages by that class.
@has2k1 has2k1 changed the title Title heading rendering Render title headers at their final levels Aug 19, 2026
@rich-iannone
rich-iannone self-requested a review August 19, 2026 20:06

@rich-iannone rich-iannone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

@rich-iannone
rich-iannone merged commit 89826a8 into posit-dev:main Aug 19, 2026
8 checks passed
@has2k1
has2k1 deleted the title-heading-rendering branch August 19, 2026 22:31
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