Skip to content

Mount API pages in the navigation of isolated builds - #4718

Merged
Mpdreamz merged 9 commits into
mainfrom
feature/floating-sections-api
Nov 5, 2026
Merged

Mpdreamz merged 9 commits into
mainfrom
feature/floating-sections-api

Conversation

@Mpdreamz

@Mpdreamz Mpdreamz commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

A - api: <key> toc entry now mounts that API's pages in the navigation of an isolated build: the sidebar links the API, and every version of it is part of the navigation tree. A failed or skipped API stays out of the sidebar, and no docset uses the entry yet, so existing builds are unchanged.

Affects: Navigation, API reference, Isolated builds

Prompt summary: Make API pages part of the navigation tree in isolated and assembler builds, because the sitemap, links.json and llms.txt all read that tree. The API is the first floating section of the design in RFC: Floating sections in the navigation tree, with the root created up front and its details filled in later.

Why

API pages are built by OpenApiGenerator after the Markdown build and never join the navigation tree (docs-eng-team#825). The floating section mechanism in the first PR has no provider yet, so nothing can use it.

What

The API section

ApiFloatingSectionProvider resolves an api: toc value to a section. The section root exists when the toc is read, with its landing URL and the product name, so layout code can link to it. When the docset resolves its tree, the section fills the root with one tree per version. Only the main tree is visible, so older versions stay out of the sitemap and first-level walks.

One build of the trees

OpenApiGenerator now builds the version trees of each API once, in TreesFor, and renders from the same trees. Mounting a section adds no second fetch and no second build. The extraction changes no rendered output: the API Explorer tests pass unchanged.

A failed or skipped API

A spec that fails to build no longer stops the Markdown build. The generator reports the error once, and the section hides. The section also hides when no main version resolved, and a build run with --skip-api never attaches a generator, so its sections stay empty and hidden. A hidden section is left out of the sidebar, so no link points at a page that was not built.

Incremental builds

The generation state records --skip-api, so toggling it over unchanged pages triggers a full build. The sidebar links change with the flag, and a stale incremental build would keep the old ones.

Isolated build and docs

IsolatedBuildService registers the provider before the docset is built and attaches the generator once it exists. docs/data/openapi/api-explorer.md documents the api: toc entry and says that only isolated builds accept it.

Stack: 2 of 5, on top of #4716.

Out of scope: the assembler build, serve, navigation.yml mounting, API pages in links.json, the sitemap, and llms.txt. A docset that declares APIs but has no api: toc entry is unchanged.

Verify

mise run test
dotnet test --project tests/Elastic.ApiExplorer.Tests --treenode-filter "/*/*/OpenApiGeneratorMultiVersionTests/FloatingSection*"

To see it, add - api: elasticsearch to the toc: of docs/_docset.yml and run an isolated build. The docs sidebar then links the API, and the build reports no errors. serve does not mount api: entries yet.

dotnet run --project src/tooling/docs-builder -- --path docs --output .artifacts/api-toc-check

🤖 Generated with Claude Code

Mpdreamz and others added 7 commits November 5, 2026 12:02
A toc entry such as `api: elasticsearch` now mounts a floating section: a set of pages that owns its URL root and sidebar and is not made of Markdown files. A provider resolves the section before navigation is built, and it renders as an island. `CreateLinkReference()` skips these nodes instead of casting them to `MarkdownFile`. No provider is registered yet, so a build that uses the entry reports an error.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…entries

The site assembler dropped every root child of a mounted docset and warned
that it was undeclared, so an `api:` entry vanished from the assembled
navigation. Floating section roots now carry a marker interface and the
assembler keeps them. An `api:` entry that also sets `children:`, `file:` or
other keys now reports an error instead of silently dropping them.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A floating section root now exists as soon as the toc mounts it, with its landing URL and title, so layout code can link to it. The children come later from `ResolveAsync`, which `DocumentationSet.ResolveFloatingSectionsAsync` runs before generation. The children keep their own numbering, so filling them never renumbers the surrounding navigation.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The narrative root copied only leaf items into the site tree, so an
`- api: <key>` entry in its toc resolved and then vanished. The root now
keeps floating section roots next to its leaves.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ResolveDirectoryTree now fills floating sections, so DocumentationGenerator, the assembler and the codex build see their pages without a separate call. The test goes through ResolveDirectoryTree and checks resolution runs once.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
An `api: <key>` toc entry now resolves to an API section. Its root exists when the toc is read, and `ResolveAsync` fills it with the version trees before generation. The generator builds each API's trees once and renders from them, so mounting a section adds no second fetch or build. Only the current version is visible.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The docset now fills floating sections itself, so a build run with `--skip-api` resolves an `api:` entry without a generator. The section stays empty and hidden instead of failing.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Mpdreamz
Mpdreamz requested a review from a team as a code owner November 5, 2026 11:28
@Mpdreamz
Mpdreamz requested a review from reakaleek November 5, 2026 11:28
Comment thread docs/data/openapi/api-explorer.md Resolved
…ip-api

A spec that fails to build no longer stops the Markdown build: the section reports the error and hides. The section also hides when no main version resolved, and a hidden API no longer appears in the section dropdown. The generation state records --skip-api, so toggling it triggers a full build. The docs now say that only the isolated build accepts api: entries.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Comment on lines +507 to +510
if (Context.SkipOpenApi != generationState.SkipOpenApi)
{
_logger.LogInformation("Full compilation: --skip-api differs from the previous build, so the API navigation links change");
return CompilationMode.Full;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: P3 (Low)

Add a regression test that builds into the same output twice with unchanged Markdown and toggles --skip-api in both directions. No test exercises the new persisted flag or compilation-mode check, so the cache-invalidation fix is unprotected; the provider-only tests cannot detect a broken state round-trip or missing settings propagation. Verify that unchanged pages gain or lose the API navigation link on the second build.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

The floating section no longer emits its own error when tree building fails, because the generator awaits the same cached task and already reports it with the stack trace. The no-main test now makes main unreadable without throwing, so it proves released versions loaded. A new build-twice test covers toggling --skip-api over unchanged pages.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Base automatically changed from feature/floating-sections to main November 5, 2026 14:23
@Mpdreamz
Mpdreamz enabled auto-merge (squash) November 5, 2026 19:03
@Mpdreamz
Mpdreamz disabled auto-merge November 5, 2026 19:12
@Mpdreamz
Mpdreamz merged commit efbe1a5 into main Nov 5, 2026
32 checks passed
@Mpdreamz
Mpdreamz deleted the feature/floating-sections-api branch November 5, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant