@clean-jsdoc-theme/setu

中文文档
5.2.1发布于 2026/10/24MITTypeScriptESM + CJS构建来源已验证近 30 天下载 2.2万

JSDoc doclet processing and MDX generation

原始使用文档
文档目录8 节
  1. Public API
  2. Legacy entry point
  3. Lower-level helpers
  4. Coverage
  5. Link resolution
  6. Pipeline placement
  7. Contributors
  8. License

@clean-jsdoc-theme/setu

JSDoc → SiteManifest. Validates a salty doclet collection, walks the documentable kinds, and emits the structured SiteManifest that dwar consumes. Zero rendering knowledge — no HTML, no JSX, no file I/O.

For the full module map, layering rules, and the wider pipeline, see the repo's docs/ARCHITECTURE.md.

Public API

import { generateSite } from '@clean-jsdoc-theme/setu';
import type { SiteManifest } from '@clean-jsdoc-theme/utils';

const manifest: SiteManifest = generateSite(saltyCollection, {
  pkg: { name: 'my-lib', version: '1.0.0' },
  readme: readmeHtml, // optional: rendered to the home page
  tutorials: tutorialTree, // optional: rendered as guide pages
  sources: sourceFiles, // optional: rendered as source-viewer pages
});

generateSite(collection, opts?) enumerates every documented container symbol, produces one Page per symbol (frontmatter, MDX body, slugified URL, pre-extracted headings), wires the nav grouped by kind, and returns a full SiteManifest ready to hand to dwar.render.

Legacy entry point

import { generateMdx } from '@clean-jsdoc-theme/setu';

const bodies: string[] = generateMdx(collection);

A thin compatibility wrapper that derives its array of body strings from generateSite. Prefer generateSite for new code.

Lower-level helpers

The composer pieces are exported for tools that want to inspect or generate individual pages:

  • buildContainerPage(collection, longname, kind, sourceLink?, resolveLink?) — one container symbol → one Page.
  • buildGlobalsPage(collection, …) — the aggregated globals page (or null).
  • enumerateLongnamesByKind(collection, kind) — unique documented longnames of a kind.
  • extractHeadings(tree) — mdast Root → Heading[] with slugified IDs.
  • buildNav(pages), computeBuildId(pages), splitLongnameForSlug(longname).
  • buildReadmePage, buildTutorialPages, buildSourceModel — the prose / source surfaces.

The kind-parametric pipeline (getContainerView, containerViewToMdast, the mdast builders) is exported from the same surface. The class-era names (buildClassPage, enumerateClassLongnames, getClassView, classViewToMdast) remain as thin aliases.

Coverage

setu renders the five container kinds — class, interface, mixin, module, namespace — through one kind-parametric path (class keeps its constructor- params special case; class/interface walk the inheritance chain). On top of that:

  • Typedef pages.
  • One aggregated Globals page for global-scope symbols that don't own a page.
  • events / enums / constants render as member sections within their parent page.
  • The project README becomes the home page; tutorials become guide pages; documented source files become read-only viewer pages.
  • A docs directory (opts.docs) of Markdown/HTML — the filesystem layout (plus optional YAML frontmatter) drives the slug and sidebar group.
  • Callouts, steps, tabs, and embeds lower to capitalized MDX JSX nodes (<Callout> / <Steps> / <Tabs> / <Embed>) that round-trip to rang components; @iframe tags and ```iframe fences share one config grammar.
  • i18n slots — every translatable string (descriptions, summaries, example captions, param/return descriptions) is emitted as a SlotEntry for aadesh to translate, and stampSite re-renders a locale with its translations.

{@link} / {@linkcode} / {@linkplain} and @see are rewritten into real anchors. A two-pass build first registers every generated page (and its members) into a link registry, then renders each page with a resolver closed over it — so forward references resolve regardless of page order. A namepath resolves to its symbol's slug (plus a #member heading anchor); external URLs link directly; unresolved namepaths fall back to inline code.

Pipeline placement

salty collection ──► setu.generateSite ──► SiteManifest ──► dwar.render ──► HTML/CSS/JS
                          ▲                                        ▲
                          │                                        │
                    schema + slug rules                     components from
                @clean-jsdoc-theme/utils                @clean-jsdoc-theme/rang

Slug rules (slugifyHeading / slugifyPath) live in @clean-jsdoc-theme/utils and are used by both setu (sidebar / TOC generation) and dwar (rendered heading anchors). Same rules → matching anchors on both sides.

Contributors

Thanks to everyone who has helped build clean-jsdoc-theme.

Contributors

License

MIT.

版本与发布记录

@clean-jsdoc-theme/setu 共发布 18 个版本,首次发布于 2026/06/10;过去 12 个月发布了 18 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
5.2.1latest2026/10/2416 天前
5.2.02026/08/282 个月前
5.1.12026/07/293 个月前
5.1.02026/07/243 个月前
5.0.82026/07/183 个月前
5.0.72026/07/074 个月前

其他发布通道:next → 5.0.0-alpha.0。

关于 @clean-jsdoc-theme/setu 的常见问题

@clean-jsdoc-theme/setu 是什么?

JSDoc doclet processing and MDX generation

如何安装 @clean-jsdoc-theme/setu?

在项目目录运行 npm install @clean-jsdoc-theme/setu,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:preact(^10.22.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@clean-jsdoc-theme/setu 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@clean-jsdoc-theme/setu 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@clean-jsdoc-theme/setu 可以商用吗?

@clean-jsdoc-theme/setu 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@clean-jsdoc-theme/setu 的下载量有多少?

根据 npm 官方下载统计,@clean-jsdoc-theme/setu 在 2026/10/10 – 2026/11/08 这 30 天内被下载 21,723 次,日均约 724 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@clean-jsdoc-theme/setu 还在维护吗?

最新版本 5.2.1 发布于 2026/10/24(16 天前);至今共发布 18 个版本,其中过去 12 个月发布了 18 个;首次发布于 2026/06/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。