docs(website): name the Python SDK group SDK

The group holds language SDKs, and the sidebar reads `SDK > Python` rather
than repeating the word in the page label.
This commit is contained in:
Yichen Jiang
2026-08-12 14:08:18 +08:00
parent d6af042cf7
commit 555771496b
5 changed files with 14 additions and 14 deletions

View File

@@ -2,5 +2,5 @@
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write .agents/notes/implemented/process/2026-08-12-documentation-site-navigation-and-chrome.md
2026-08-12-documentation-site-navigation-and-chrome.md: 07f88d303a96676806cce0801bce5d478fb5406e
2026-08-12-documentation-site-navigation-and-chrome.zh.md: ca605e2a890bac4bcff9f22a6c6ab8928d1a8aa8
2026-08-12-documentation-site-navigation-and-chrome.md: 03cd44b94f853725da33800e8c89886b1a657a0b
2026-08-12-documentation-site-navigation-and-chrome.zh.md: d0972f909e648278cb3cecb7788705b228f4b675

View File

@@ -6,7 +6,7 @@ English | [中文](2026-08-12-documentation-site-navigation-and-chrome.zh.md)
## Problem
The reference sidebar rendered its 43 subsystem pages first, ahead of every other group: `sectionOrder` in the VitePress config listed no position for `子系统`/`Subsystems` — nor for `其他接口`/`Other interfaces` so `indexOf` returned `-1` and sorted them ahead of the ordered sections. Clicking the `参考` navigation item landed on the architecture page whose own sidebar entry was link 44 of 62, 1549px down a 2478px sidebar — outside the viewport. Four subsystem pages carried `order` values already taken by other pages in the same section, resolved only by `Array.prototype.sort` stability and the order the manifest's arrays happened to be concatenated.
The reference sidebar rendered its 43 subsystem pages first, ahead of every other group: `sectionOrder` in the VitePress config listed no position for the subsystem groups, nor for the group holding the Python SDK page, so `indexOf` returned `-1` and sorted them ahead of the ordered sections. Clicking the `参考` navigation item landed on the architecture page whose own sidebar entry was link 44 of 62, 1549px down a 2478px sidebar — outside the viewport. Four subsystem pages carried `order` values already taken by other pages in the same section, resolved only by `Array.prototype.sort` stability and the order the manifest's arrays happened to be concatenated.
The navigation bar named `/guide/` while the manifest published the guide's first page at `guide/quickstart.md`, so that item served a 404: written-down navigation targets drift from the routes the manifest publishes.
@@ -14,7 +14,7 @@ Separately, every canonical page carries lines written for its GitHub reader —
## Decision
[website/docs.ts](../../../../website/docs.ts) owns section placement. `sections` declares the groups per locale, and `sectionSpec(locale, label)` returns a group's position and collapse behavior, throwing when a locale declares no placement for a label. A group absent from the declaration now fails the build instead of sorting silently to the top. Placement is per locale because the two sidebars name their groups independently: one shared list ordered both label sets by convention and accepted a label missing from either without complaint.
[website/docs.ts](../../../../website/docs.ts) owns section placement. `sections` declares the groups per locale, and `sectionSpec(locale, label)` returns a group's position and collapse behavior, throwing when a locale declares no placement for a label. A group absent from the declaration now fails the build instead of sorting silently to the top. Placement is per locale because the two sidebars name their groups independently, and a label both use — `SDK` — cannot hold one rank against `入门` and against `Guide` at once.
Subsystem pages are grouped by concern — overview, core and scopes, sessions and persistence, model and context, execution and tools, policy and interaction, platform and access — and the six topical groups render collapsed until one holds the page being read. The groups sort last within the reference sidebar: expanded, they outnumber every other group combined, so anything placed after them is reachable only by scrolling past the whole list. Page `order` derives from array position rather than a hand-written number.

View File

@@ -6,7 +6,7 @@ Status: implemented
## 问题
参考侧边栏把 43 个子系统页排在了所有其他分组之前VitePress 配置中的 `sectionOrder` 既没有为 `子系统`/`Subsystems` 也没有为 `其他接口`/`Other interfaces` 声明位置,`indexOf` 返回 `-1`,于是它们排到了所有已排序分区的前面。点击 `参考` 导航项落在架构页,而该页自己的侧边栏条目是 62 条中的第 44 条,位于 2478px 侧边栏的 1549px 处——在视口之外。四个子系统页所用的 `order` 值已被同一分区内的其他页占用,只靠 `Array.prototype.sort` 的稳定性和 manifest 数组恰好的拼接顺序才没有错乱。
参考侧边栏把 43 个子系统页排在了所有其他分组之前VitePress 配置中的 `sectionOrder` 既没有为子系统分组、也没有为承载 Python SDK 页的分组声明位置,`indexOf` 返回 `-1`,于是它们排到了所有已排序分区的前面。点击 `参考` 导航项落在架构页,而该页自己的侧边栏条目是 62 条中的第 44 条,位于 2478px 侧边栏的 1549px 处——在视口之外。四个子系统页所用的 `order` 值已被同一分区内的其他页占用,只靠 `Array.prototype.sort` 的稳定性和 manifest 数组恰好的拼接顺序才没有错乱。
顶栏把 `入门` 指向 `/guide/`,而 manifest 已把入门首页发布在 `guide/quickstart.md`,该导航项因此返回 404写死的导航目标会与 manifest 实际发布的路由脱节。
@@ -14,7 +14,7 @@ Status: implemented
## 决定
[website/docs.ts](../../../../website/docs.ts) 拥有分区位置。`sections` 按 locale 声明各分组,`sectionSpec(locale, label)` 返回分组的位置与折叠行为,当某 locale 未为该 label 声明位置时抛错。未出现在声明中的分组现在会让构建失败,而不是静默排到最前。位置按 locale 声明,是因为两侧侧边栏各自命名分组:单一共享列表既要按约定排列两套标签,又会对任一侧缺失的标签毫无反应
[website/docs.ts](../../../../website/docs.ts) 拥有分区位置。`sections` 按 locale 声明各分组,`sectionSpec(locale, label)` 返回分组的位置与折叠行为,当某 locale 未为该 label 声明位置时抛错。未出现在声明中的分组现在会让构建失败,而不是静默排到最前。位置按 locale 声明,是因为两侧侧边栏各自命名分组,而两侧共用的标签 `SDK` 无法同时相对 `入门` 和相对 `Guide` 取同一位次
子系统页按关注点分组——总览、内核与作用域、会话与持久化、模型与上下文、执行与工具、策略与交互、平台与接入——其中六个主题组保持折叠,直到某一组包含正在阅读的页面。这些分组排在参考侧边栏的最后:展开时它们的数量超过其余所有分组之和,因此排在它们之后的任何内容都只能靠滚过整个列表才能到达。页面 `order` 由数组位置推导,不再手写数字。

View File

@@ -378,10 +378,10 @@ describe('sidebar ordering', () => {
})
it('declares placements per locale rather than in one shared list', () => {
// Each locale ranks only its own labels, so a label one locale never uses
// cannot borrow a rank from the other.
expect(sectionSpec('root', '入门').index).toBe(0)
expect(sectionSpec('en', 'Guide').index).toBe(0)
// `SDK` labels a group in both locales, so one shared list would have to
// rank it against `入门` and against `Guide` at the same position.
expect(sectionSpec('root', 'SDK').index).toBeGreaterThan(sectionSpec('root', '入门').index)
expect(sectionSpec('en', 'SDK').index).toBeGreaterThan(sectionSpec('en', 'Guide').index)
expect(() => sectionSpec('en', '入门')).toThrow()
expect(() => sectionSpec('root', 'Guide')).toThrow()
})

View File

@@ -133,9 +133,9 @@ const homeAndGuide = pairedPages([
{
source: 'docs/user/guide/python-sdk.md',
route: 'guide/python-sdk.md',
label: { root: 'Python SDK', en: 'Python SDK' },
label: { root: 'Python', en: 'Python' },
sidebar: { root: 'zh-guide', en: 'en-guide' },
section: { root: '其他接口', en: 'Other interfaces' },
section: { root: 'SDK', en: 'SDK' },
order: 1,
},
])
@@ -427,7 +427,7 @@ export interface DocsSection {
*/
const sections: Record<DocsLocale, readonly DocsSection[]> = {
root: [
{ label: '入门' }, { label: '其他接口' },
{ label: '入门' }, { label: 'SDK' },
{ label: '基础' }, { label: '框架能力' }, { label: '实战' }, { label: 'Cordis 框架教程' },
{ label: '概念' }, { label: '生成参考' }, { label: 'Cordis API' }, { label: '开发手册' },
{ label: '总览' },
@@ -439,7 +439,7 @@ const sections: Record<DocsLocale, readonly DocsSection[]> = {
{ label: '平台与接入', collapsed: true },
],
en: [
{ label: 'Guide' }, { label: 'Other interfaces' },
{ label: 'Guide' }, { label: 'SDK' },
{ label: 'Basics' }, { label: 'Framework' }, { label: 'Practice' }, { label: 'Cordis framework tutorial' },
{ label: 'Concepts' }, { label: 'Generated reference' }, { label: 'Cordis Core API' }, { label: 'Cookbook' },
{ label: 'Overview' },