fix(jsref): nest member sub-pages in the JS reference sidebar#728
Open
caugner wants to merge 15 commits into
Open
fix(jsref): nest member sub-pages in the JS reference sidebar#728caugner wants to merge 15 commits into
caugner wants to merge 15 commits into
Conversation
All `Proxy/*` pages now share one sidebar with handler traps listed under a new "Handler methods" group sourced from `Proxy/Proxy/*` sub-pages. Drops the broken `Proxy/Proxy/*` → `Proxy/handler` slug mapping (the page never existed) and the redundant `Proxy/handler` related-pages entry. Requires `Handler_methods` in `L10n-Common.json`.
This was referenced May 26, 2026
Contributor
|
dd20530 was deployed to: https://rari-pr728.review.mdn.allizom.net/ |
Rename the `pages` binding inside the `obj == "Proxy"` block to `handler_pages` so it does not shadow the outer `pages` from the generic sub-page fetch, making the scope obvious to readers.
Previously, any sub-page of `Proxy/Proxy` whose page type was not `JavascriptInstanceMethod` would be silently dropped from the sidebar. Emit a `tracing::warn!` instead so non-trap sub-pages (e.g. a future data property) surface in build logs and can be triaged.
Proxy/* sidebar with Handler methods groupProxy/* sidebar with Handler methods group
caugner
marked this pull request as ready for review
May 26, 2026 16:49
Contributor
Author
|
@Josh-Cena Can you take a look at the screenshots and let me know if this looks good? 🙂 |
Handler methods are properties on a separate `handler` object passed to the `Proxy()` constructor, not members of the `Proxy` class itself. Move the group to the end of the sidebar so it reads as a distinct concept rather than splitting the static-methods/static-properties pairing.
caugner
force-pushed
the
707-refine-Proxy-sidebar
branch
from
May 26, 2026 17:05
b741af8 to
2ff51cb
Compare
Member
|
I'm not fond of this design. These methods should be under the constructor, not the class. |
Drop the separate `Handler methods` group at the class level and instead render the traps as children of the `Proxy()` constructor entry, matching their slug location (`Proxy/Proxy/*`). This also removes the dependency on the `Handler_methods` L10n key.
Put the `Proxy()` link inside `<summary>` and the trap list below it, so the entry can be collapsed/expanded like the surrounding groups.
Drop the `handler_methods` field on `JSRefItem` and the corresponding `if obj == \"Proxy\"` branch in `from_obj_str`. The fetch now lives in `proxy_handler_trap_entries()`, called from the constructor-entry builder where it's actually used. Keeps the per-class data struct free of Proxy-specific quirks.
Generalize the Proxy-specific nesting into a depth-aware fetch and recursive entry builder. For each class, `get_sub_pages` now walks the whole sub-tree; depth-1 pages are still bucketed by `PageType`, and depth-≥2 pages are kept in a `sub_pages` map keyed by parent slug. A new `build_member_entry` helper recursively constructs sidebar entries and nests sub-pages under their parent, using `<details>` whenever an entry has children. This subsumes: - `Proxy/Proxy/*` handler traps (now generic, not Proxy-specific). - `Intl/Segmenter/segment/Segments` (and `Segments/containing`, `Segments/[Symbol.iterator]`), which previously appeared as a separate sidebar via special cases in `slug_to_object_name` and `GROUP_DATA`. Both special cases are removed.
Proxy/* sidebar with Handler methods group`rsplit_once('/')` already yields the parent slug we need for the
nested-pages bucket; comparing it to `class_slug` tells us whether the
page is a direct member without an extra `strip_prefix` + `contains`
pass.
Top-level groups like Constructor or Instance methods still open by default for the current class, but the nested `<details>` for a member that has its own sub-pages (e.g. `Proxy()` with handler traps, or `segment()` with `Segments`) now starts collapsed.
The field holds descendants at depth >= 2 keyed by their immediate parent slug, and `build_member_entry` walks it recursively — the prior wording suggested it was specific to depth-1 members.
`get_sub_pages` only returns descendants of the class slug, so every page here has a parent component. Replace the let-else `continue` with an `expect` that documents the invariant.
Switching `get_sub_pages` from `depth: Some(1)` to `None` widens the directory walk per class, but `read_sub_folders_internal` is `#[memoize]`-cached, so the cost isn't paid per sidebar build. Call that out so the next reader doesn't worry about a hot-path cost.
Contributor
Author
Please have another look, I think this is what you're expecting. |
Member
|
Yes, love this one! Thank you! |
caugner
marked this pull request as ready for review
May 27, 2026 18:32
Contributor
Author
|
@mdn/content-team Do you have any concerns with this change? |
Member
|
I'll defer my code review until content have had a look |
Contributor
Author
|
ping @mdn/content-team |
|
Agree with @Josh-Cena - this is great - thank you! |
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.
Description
Generalize the JS reference sidebar so that any member entry (constructor, method, property) whose page has its own sub-pages renders those sub-pages nested below it, inside a
<details>element with the parent's link in the<summary>. In practice this covers:Proxy/Proxy/*handler traps now nest under theProxy()constructor entry (which lives in the sharedProxysidebar that allProxy/*pages use).Intl/Segmenter/segment/Segments(andSegments/containing,Segments/[Symbol.iterator]) now nest under thesegment()instance method — previously they were surfaced as a separate sidebar via special cases.Motivation
Proxy/Proxy→Proxy/handlerslug mapping pointed at a page that never existed, producingtempl-redirected-linkflaws across theProxyreference pages.Proxy/Proxy/apply,.get,.set, …) rendered under a separate, partially-broken sidebar instead of sharing the surroundingProxysidebar.Intl/Segmenter/segment/Segments) all want the same thing: surface sub-pages where they belong in the hierarchy. Doing it generically removes the special cases and avoids needing a new one each time another member grows sub-pages.Additional details
JSRefItemnow carries asub_pages: HashMap<String, Vec<Page>>keyed by parent page slug.get_sub_pagesfor the class walks the whole sub-tree (depthNone); depth-1 pages are bucketed byPageTypeas before, depth-≥2 pages go intosub_pages.build_member_entryhelper recursively constructs each entry, attachingMetaChildren::Childrenfromsub_pageswhen present and settingDetails::Closedso entries with children are collapsible and start closed (regardless of the surrounding group's open/closed state).(label, list)loop now also covers the Constructor group — there is no separate code path for it.slug_to_object_nameno longer has aProxy/ProxyorIntl/Segmenter/segment/Segmentsspecial case — both fall through to the normal class resolution.GROUP_DATAloses the[Segments, Intl.Segmenter]entry.JSRefItem::from_obj_strloses its Segments-onlytitleoverride.["Proxy", "Proxy/handler"]related-pages entry is removed.test_slug_to_object_namegets assertions forProxy,Proxy/Proxy,Proxy/Proxy/get,Intl/Segmenter/segment/Segments, andIntl/Segmenter/segment/Segments/containing.Screenshots
ProxypageProxy()constructor pagehandler.apply()trap pageIntl.SegmenterpageIntl.Segmenter.segment()pageIntl.Segmenter.segment()->SegmentspageRelated issues and pull requests
Fixes #706.
Closes #732.
Supersedes #707.