Skip to content

Fix navigation: level-based chunking, nested toc.yml, discrete sections, navigation_title - #3833

Merged
Mpdreamz merged 1 commit into
feature/ascii-to-md-converterfrom
feature/md-conversion-navigation
Aug 14, 2026
Merged

Fix navigation: level-based chunking, nested toc.yml, discrete sections, navigation_title#3833
Mpdreamz merged 1 commit into
feature/ascii-to-md-converterfrom
feature/md-conversion-navigation

Conversation

@Mpdreamz

Copy link
Copy Markdown
Member

Summary

Stacked on #3802. Fixes the converted navigation so it matches the live elastic.co/guide sidebar exactly.

Root causes:

  • Every included file became a page (IsIncludeRoot-only rule), producing ~2065 flat pages with 27 slug collisions instead of the correct ~2085 hierarchically nested pages.
  • TocEntry had no Children and WriteTocYaml was non-recursive, so parent/child structure was never written to toc.yml.
  • Sections from separate includes (e.g. migration_intro.asciidoc + individual migrate_8_N.asciidoc files) were assembled flat in ProcessInclude, losing AsciiDoc's natural level-based nesting.

Fixes:

File Change
PageChunker.cs Complete rewrite: single Traverse pass producing a tree of PageOutput. IsPage = !IsDiscrete && (Level==0 ? IsIncludeRoot : Level <= chunkLevel+1). Book root detection (single L0 child → index.md). Duplicate slugs get _2/_3 suffixes.
SectionNode.cs Added IsDiscrete (from [discrete]/[float] block attribute).
AsciidocParser.cs Passes pendingBlockAttr into ParseSection for IsDiscrete. Added NestSectionsByLevel() at the end of ProcessInclude — sections at level N following a section at level < N in the flat result list are re-nested as children, replicating AsciiDoc's hierarchical nesting (fixes the Migration guide pattern).
MarkdownEmitter.cs Added HeadingLevelBase + UpdateHeadingBase so child headings rebase relative to the page root.
YamlWriter.cs TocEntry gains Children; WriteTocYaml is now recursive.
ConvertCommand.cs WritePages recurses page.Children; emits navigation_title frontmatter.
ChunkerTests.cs New: 9 tests covering discrete sections, deep-section inlining, auto-id, duplicate slug suffixing, navigation_title frontmatter, cross-include level nesting, and nested toc.yml output.

Results for ES 8.19 (chunk:1):

  • 2085 pages in a properly nested toc.yml (was 2065 flat with 27 collisions)
  • No duplicate toc entries
  • breaking-changes.md (= Migration guide) has migrating-8.0migrating-8.19 as children
  • getting-started.md has navigation_title: "Basics: Index and search using APIs"
  • quickstart.md has ## Requirements inline (discrete sections stay on-page)
  • targz.md contains ## Next steps inline (Level 3 rebased under Level 2 page)

Test plan

  • dotnet test tests/Elastic.LegacyDocs.Migration.Tests/ — 44 tests pass
  • ./build.sh unit-test — 314 tests pass
  • dotnet run --project src/tooling/docs-migrate -- convert --majors 1 --minors 1 --book en/elasticsearch/reference
  • grep -o 'file: .*' toc.yml | sort | uniq -d → empty (no duplicate entries)
  • Sidebar nesting matches https://www.elastic.co/guide/en/elasticsearch/reference/8.19/index.html

🤖 Generated with Claude Code

@Mpdreamz
Mpdreamz requested a review from a team as a code owner August 11, 2026 12:37
@Mpdreamz
Mpdreamz requested a review from reakaleek August 11, 2026 12:37
@Mpdreamz
Mpdreamz requested a review from a team as a code owner August 14, 2026 09:24
@Mpdreamz
Mpdreamz force-pushed the feature/md-conversion-navigation branch from 446fe88 to e8f2138 Compare August 14, 2026 09:52
…ectionsByLevel, HeadingLevelBase

- PageChunker: tree-shaped PageOutput with child pages, slug dedup, IsDiscrete support, AutoId replacing Slugify.Core
- AsciidocParser: IsDiscrete flag for [discrete]/[float] sections; NestSectionsByLevel post-processes flat include results
- MarkdownEmitter: HeadingLevelBase rebases heading levels per page root; LF-only newlines
- YamlWriter: Island and Children on TocEntry; nested toc entries with island: true
- ConvertCommand: Island=true per version toc entry; WritePages recursion into child pages; navigation_title frontmatter; island: true per book in docset.yml
- FeatureFlags: GuideNavEnabled property
- Paths/GitResolveFileSystem: DEBUG escape hatch for .slnx root; .artifacts in allowed hidden folders
- docs-migrate ServeCommand: use Paths.WorkingDirectoryRoot instead of CWD
- docs-migrate.csproj: add Elastic.Documentation.Tooling project reference
- docs-builder ServeCommand: remove unused System.IO.Abstractions using
- ChunkerTests: 391-line test suite for new chunker behaviour

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Mpdreamz
Mpdreamz force-pushed the feature/md-conversion-navigation branch from e8f2138 to fb92799 Compare August 14, 2026 09:55
@Mpdreamz
Mpdreamz merged commit c3a35b4 into main Aug 14, 2026
25 checks passed
@Mpdreamz
Mpdreamz deleted the feature/md-conversion-navigation branch August 14, 2026 10:36
yetanothertw pushed a commit that referenced this pull request Aug 14, 2026
…ectionsByLevel, HeadingLevelBase (#3833)

- PageChunker: tree-shaped PageOutput with child pages, slug dedup, IsDiscrete support, AutoId replacing Slugify.Core
- AsciidocParser: IsDiscrete flag for [discrete]/[float] sections; NestSectionsByLevel post-processes flat include results
- MarkdownEmitter: HeadingLevelBase rebases heading levels per page root; LF-only newlines
- YamlWriter: Island and Children on TocEntry; nested toc entries with island: true
- ConvertCommand: Island=true per version toc entry; WritePages recursion into child pages; navigation_title frontmatter; island: true per book in docset.yml
- FeatureFlags: GuideNavEnabled property
- Paths/GitResolveFileSystem: DEBUG escape hatch for .slnx root; .artifacts in allowed hidden folders
- docs-migrate ServeCommand: use Paths.WorkingDirectoryRoot instead of CWD
- docs-migrate.csproj: add Elastic.Documentation.Tooling project reference
- docs-builder ServeCommand: remove unused System.IO.Abstractions using
- ChunkerTests: 391-line test suite for new chunker behaviour

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants