prelude-docs
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePrelude docs in a consumer repo
使用方仓库中的 Prelude 文档
Treat the user's argument as the task description (e.g. "add a recipes page under
a Guides group"), not a shell command. Manage the requested Markdown sources
and existing configuration; preserve unrelated settings.
prelude.docs.*Prerequisite: the repo imports (see the
skill). The docs viewer has no enable flag — it activates
automatically when is non-empty, which also installs the
command, its dispatch, and the accelerator.
prelude.flakeModules.defaultprelude-installprelude.docs.pagesdocsx docsd将用户参数视为任务描述(例如“在 Guides 分组下添加一个 recipes 页面”),而不是 shell 命令。管理所请求的 Markdown 源文件和现有的 配置;保留无关设置。
prelude.docs.*前置条件:仓库导入了 (参见 skill)。文档查看器没有启用开关——当 非空时会自动激活,同时安装 命令、 分派和 快捷键。
prelude.flakeModules.defaultprelude-installprelude.docs.pagesdocsx docsdAuthored pages
手动编写的页面
prelude.docs.pagesnix
prelude.docs.pages = [
{ text = ./docs/getting-started.md; } # leaf
{ title = "Guides"; # group: nests, renders no body
children = [ { text = ./docs/guides/a.md; } ]; }
];- Leaf — the file's first H1 labels the sidebar; an optional
{ text = <markdown path>; }overrides it.title - Group — sidebar-only nesting. A hand-written group should not set
{ title; children; }(that field is mdSplit provenance, not a body).text - accepts any store path, so external dependency docs need no vendoring:
textrenders the upstream page at your flake's pinned revision.{ text = inputs.some-dep + "/docs/api.md"; }
prelude.docs.pagesnix
prelude.docs.pages = [
{ text = ./docs/getting-started.md; } # leaf
{ title = "Guides"; # group: nests, renders no body
children = [ { text = ./docs/guides/a.md; } ]; }
];- Leaf ——文件中的首个 H1 用作侧边栏标签;可选的
{ text = <markdown path>; }会覆盖它。title - Group ——仅用于侧边栏嵌套。手动编写的 group 不应设置
{ title; children; }(该字段用于记录 mdSplit 来源,而不是正文)。text - 接受任意 store path,因此外部依赖文档无需 vendoring:
text会在 flake 锁定的 revision 上渲染上游页面。{ text = inputs.some-dep + "/docs/api.md"; }
README as the landing page
将 README 作为落地页
nix
prelude.docs.rootReadme = ./README.md;When a leaf's equals (exact path match, not basename), the
viewer styles it as the project hero: FIGlet wordmark of plus
the HTML intro, with the body kept as authored. To also give the README's H2
sections their own sidebar entries:
textrootReadmeprelude.projectnix
prelude.docs.pages = [
(inputs.prelude.lib.mdSplit ./README.md)
{ text = ./docs/getting-started.md; }
];prelude.lib.mdSplitlib{ title; text; children; }rootReadmenix
prelude.docs.rootReadme = ./README.md;当某个 leaf 的 与 相等时(要求路径精确匹配,而不是仅匹配 basename),查看器会将其设置为项目 hero:显示 的 FIGlet 字标和 HTML 简介,同时正文保持原样。若还需让 README 的各个 H2 章节在侧边栏中拥有独立条目:
textrootReadmeprelude.projectnix
prelude.docs.pages = [
(inputs.prelude.lib.mdSplit ./README.md)
{ text = ./docs/getting-started.md; }
];prelude.lib.mdSplitlib{ title; text; children; }rootReadmeGenerated option docs
生成选项文档
Only when the project defines its own module options. Never hand-maintain an
option table — generate it from the evaluated option tree:
nix
prelude.docs.nixosOptions = {
inherit (eval) options; # lib.evalModules side-eval, not the live flake-parts
transformOptions = o: o // { declarations = []; }; # any nixosOptionsDoc arg
};
prelude.docs.pages = [ /* … */ { generate = "nixosOptions"; title = "Options"; } ];- Side-evaluate options with — closing over the live flake-parts option tree risks cycles and noise.
lib.evalModules { modules = [ … ]; } - (default): nested sidebar, one leaf per terminal option.
split = "allLeaves": one fullsplit = "shallow"page.pkgs.nixosOptionsDoc - Never JSON-serialize the value; it feeds nixosOptionsDoc directly and only Markdown store paths enter the bundle.
nixosOptions
Authored vs generated: authored leaves/groups are prose the repo maintains;
nodes derive from option definitions at build time and are never
edited by hand. Upstream's checked-in is a
maintainer artifact. Do not assume downstream has ; follow its
own generation workflow when one exists.
generatedocs/reference/options.mdx sync-docs仅当项目定义了自己的 module options 时使用。绝不手动维护选项表——应从求值后的选项树生成:
nix
prelude.docs.nixosOptions = {
inherit (eval) options; # lib.evalModules side-eval, not the live flake-parts
transformOptions = o: o // { declarations = []; }; # any nixosOptionsDoc arg
};
prelude.docs.pages = [ /* … */ { generate = "nixosOptions"; title = "Options"; } ];- 使用 对选项进行侧向求值——闭包捕获 live flake-parts 选项树可能导致循环和噪声。
lib.evalModules { modules = [ … ]; } - (默认):使用嵌套侧边栏,每个末端选项对应一个 leaf。
split = "allLeaves":生成一个完整的split = "shallow"页面。pkgs.nixosOptionsDoc - 绝不将 值 JSON 序列化;它会直接传给 nixosOptionsDoc,且只有 Markdown store path 会进入 bundle。
nixosOptions
**手动编写与生成:**手动编写的 leaf/group 是仓库自行维护的说明性内容; 节点在构建时从选项定义派生,绝不能手工编辑。上游仓库中已提交的 是维护者产物。不要假设下游存在 ;如果下游有自己的生成工作流,应遵循该工作流。
generatedocs/reference/options.mdx sync-docsVerify
验证
Make newly referenced files visible to Git-backed flake evaluation by staging
only the intended files; no commit is required. Preserve existing docs pages
when merging the examples above.
From the repo root, without entering the devshell:
sh
nix build .#prelude-docs # evaluates the pages tree and builds the bundle
./result/bin/docs 1 # prints leaf 1 non-interactivelyInside the devshell ():
nix develop- or
docs— TUI: digits 1–9 jump top-level pages, Tab/Shift-Tab moves focus, j/k scroll, q quits.x docs - prints one window; page is a 1-based depth-first leaf index (groups are not pages).
docs <page>/docs nextpage through. Piped output strips ANSI, so this works in scripts and CI logs.docs prev
Reference (pin to your flake.lock's revision):
https://github.com/darkmatter/prelude — (consumer
wiring), , and under
. For catalogue command edits see the skill;
shows the installed surface.
github:darkmatter/preludedocs/your-own-repo.mddocs/configuration.mddocs/reference/options.mdprelude.docs.*prelude-justx --list通过仅暂存预期文件,使新引用的文件对基于 Git 的 flake 求值可见;无需 commit。合并上述示例时,保留现有 docs pages。
在仓库根目录中,无需进入 devshell:
sh
nix build .#prelude-docs # evaluates the pages tree and builds the bundle
./result/bin/docs 1 # prints leaf 1 non-interactively在 devshell()中:
nix develop- 或
docs——TUI:数字 1–9 可跳转到顶层页面,Tab/Shift-Tab 移动焦点,j/k 滚动,q 退出。x docs - 打印一个窗口;
docs <page>是从 1 开始、按深度优先顺序计算的 leaf 索引(group 不是页面)。page/docs next用于逐页浏览。管道输出会去除 ANSI,因此适用于脚本和 CI 日志。docs prev
参考文档(请固定到你的 flake.lock 中 对应的 revision):
https://github.com/darkmatter/prelude——`prelude.docs.*` 下的 (使用方接入)、 和 。如需编辑 catalogue 命令,请参阅 skill; 会显示已安装的命令界面。
github:darkmatter/preludedocs/your-own-repo.mddocs/configuration.mddocs/reference/options.mdprelude-justx --list