feat(napi): add RwSite.listSections()#569
Conversation
|
YAGNI follow-up after wiring the consumer side: we ended up not using
Note this loses nothing on correctness:
Net: keep |
c7cb753 to
43a150a
Compare
43a150a to
ebcfd01
Compare
|
One more YAGNI trim on the same theme: on the consumer side we also don't display section titles in v1 — rows are grouped by owning entity and labeled by entity + page path. So Suggest dropping Net for this PR: keep |
ebcfd01 to
4842a7e
Compare
Expose the full section hierarchy through the @rwdocs/core napi addon in one
call, so a host (e.g. a Backstage doc-comment inbox) no longer needs N+1
getNavigation() calls to walk nested sections — which deliberately appear as
childless leaves in their parent scope.
listSections() returns every section flat as { sectionRef, path, ancestors }:
canonical ref (kind:namespace/name), scope path, and full nearest-first
ancestry (root last). Backed by SiteState::list_sections over the already-flat
Sections map; ancestry via a prefix-walk mirroring find_parent_section. Output
sorted by scope path.
Adds SectionEntry (rw-site) and SectionEntryResponse (rw-napi), regenerates the
NAPI-RS index.d.ts, and covers the behavior with rw-site unit tests (ancestry
incl. non-section intermediates, custom root namespace) and a @rwdocs/core JS
integration test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
4842a7e to
c345391
Compare
Implements #567 — exposes the full section hierarchy through the
@rwdocs/corenapi addon in one call.What
RwSite.listSections()→SectionEntry[], whereSectionEntry = { sectionRef, path, ancestors }. Returns every section flat — canonical ref (kind:namespace/name), scope path (""= root), and full nearest-first ancestry (root last). Removes the N+1getNavigation()descent a consumer otherwise needs, since nested sections deliberately appear as childless leaves in their parent scope.sectionRefis named to matchPageMeta.sectionRef.Why it's cheap
Purely additive over the already-flat
SiteState.sectionsmap — no new internal state, no schema change, no behavioural change to existing methods. Ancestry reuses thefind_parent_sectionprefix-walk; the output is sorted by scope path.Scope trims (per review)
The issue originally proposed two extras that the consumer turned out not to need, so they're left out to avoid shipping unused public surface — both trivially re-addable later:
resolveSection(path)— dropped; the consumer keys offlistSections().pathand stored canonical refs. The internalSite::section_locationis untouched (still used byrenderPage); its custom-root-namespace correctness is retained and tested.SectionEntry.title— dropped; v1 rows are grouped/labeled by entity + page path, not section title. The section root page's title is already in the loaded snapshot, so it's free to re-add if a UI wants friendlier labels.Tests
@rwdocs/coreJS integration test:createSite → listSectionsagainst a fixture docs tree.🤖 Generated with Claude Code