Repository navigation
top_menu: address review of #2904 - #4
Merged
Merged
Conversation
* Document `top_menu` as an option of `Documenter.HTML` (guide and CHANGELOG), move the CHANGELOG entry to Unreleased and link JuliaDocs#2904. * Validate the shape of `pages`: every top-level entry must have a section title. * Respect `hide`: hidden sections are not shown in the top menu, and hidden pages are not listed in the dropdowns. * Keep the page of a section that is a page with sub-pages in the section's sidebar. * Keep the previous/next page links within each section. * Map pages to sections once, instead of scanning all sections for every rendered page; remove the unused `find_navnode_for_page`. * Drop the redirect `index.html` feature, to be discussed separately. * Use the icon font for the dropdown caret and add ARIA attributes. * Revert unrelated changes (DOM.jl, builder_pipeline.jl, documents.jl, docs/Project.toml) and fix the Biome formatting of sidebar.js. * Fix the tests: move the edge-case tests to unit tests in test/topmenu.jl, remove `warnonly` from the example build, and cover hidden sections, page + sub-pages sections and prev/next links. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Coverage Report for CI Build 36600101164Warning No base build found for commit Coverage: 56.143%Details
Uncovered Changes
Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses the review of the
top_menufeature (JuliaDocs/Documenter.jl#2904). It targetstop_menu_from_pages2(#3), so the diff only contains the review fixes. Once #3 and this PR are merged intotop_menu_from_pages, the changes will show up in JuliaDocs#2904.Blockers
top_menuis an option ofDocumenter.HTML, and the guide example usesformat = Documenter.HTML(top_menu = true).On the design question: I kept
top_menuonHTML. A top bar with dropdowns is an HTML presentation feature, and for other writers the current structure is already right: LaTeX renders the first layer ofpagesas parts/chapters, which is the same hierarchy. The guide now says explicitly that other writers ignore the option. If we want this at themakedocslevel later, it can be added without breakingHTML(top_menu = true).Loggingproblem is gone: the edge cases are now unit tests intest/topmenu.jl, and the duplicate-page warning is checked with@test_logs.top_menu-specific case. A build where every section is empty still hits the pre-existingBoundsErrorinrender_sidebar, which also happens onmasterwithouttop_menu. It is left for a separate fix.pages = ["index.md"]). That gets past the "is not an existing page" check and reaches the newtop_menuvalidation (item 5).prev_next_navnodes, which keeps the previous/next links within the page's section whentop_menuis on.NavNode.prev/.nextare not modified, so other writers are unaffected. The example build tests that the first page of "User Guide" has no«link and the last page of "Getting Started" has no»link.hide()was ignored.TopMenuSectionnow storesvisible. Sections hidden withhide("Title" => "page.md")are left out of the top bar, and hidden entries are left out of the dropdowns. In the reported example,hide("Sec B" => "other.md", ["hidden.md"]), the root stays visible (that is whathide(root, children)means), so "Sec B" is still in the top bar. Buthidden.mdis no longer listed in its dropdown; see also item 12.pagesshape was not validated. Every top-level entry must now have a title. A bare"index.md"(orhide("index.md")) throws an error saying that the entry must be a"Section Title" => pagespair."Title" => "page.md"is still accepted as a single-page section.sidebar.js;make check-jspasses.[#2904]and adds the link definition. It was also sitting inside the already-released v1.17.0 section after the master merges; it is now under "Unreleased".Should fix
master; the example and the full test suite pass without the change.find_navnode_for_pageis removed.build_top_menu_sectionsnow returns apage => section indexDict, stored inHTMLContext. The active-section lookup, the sidebar tree (get_section_navtree) and prev/next all use it throughtop_menu_section.index.htmlis removed, together with the suppression of the "src/index.md missing" warning and_find_first_index_page. Atop_menusite now needs a rootindex.md, like any other site. The example build moves its landing page tosrc.topmenu/index.md. The redirect can be proposed separately."Title" => [...]sections show their children directly. The example has ahide("Reference" => "reference/index.md", ["reference/extra.md"])section to cover this.builder_pipeline.jl,documents.jlanddocs/Project.tomlare reverted tomaster.warnonly = trueis removed from thehtml-topmenuexample build, which builds without errors.Minor
\f078) through CSS, as the sidebar does, and isaria-hidden. The top<nav>has anaria-label, and the active section link hasaria-current. Themes are recompiled.occursin("getting-started", ...)assertion is gone. The example tests now check the top menu<nav>and the sidebar<ul>separately, instead of searching the whole page.makedocsedge-case test usesmktempdir() do ... end, and the unusedimport Markdownis removed.Testing
Pkg.test(): alltop_menutests pass (unit tests intest/topmenu.jland theHTML: top_menuexample testset). The only failures are three tests that compare against theJuliaDocs/Documenter.jlgit remote (HTML: repo-*and two issue links inxrefs to Main), which fail in a checkout of a fork regardless of this change.make check-jspasses; Julia files are formatted with Runic.AI disclosure: this change was prepared with the help of Claude Code (Claude Opus 5.5), and reviewed by me.
🤖 Generated with Claude Code