setu Examples
setu internal है। आप एक सामान्य docs build में generateSite को call नहीं करते — JSDoc और TypeDoc bridges आपके लिए इसे call करते हैं। आप इसकी ओर सीधे तभी बढ़ते हैं जब आप एक custom bridge बना रहे हों (एक नया front-end जो एक salty doclet collection produce करता है)। इसलिए यहाँ के ईमानदार उदाहरण theme के साथ ship होने वाले दो असली bridges हैं।
अगर आप सिर्फ़ theme को configure करना चाहते हैं, तो इसके बजाय Configuration और guides देखें।
The call shape
दोनों bridges एक salty doclet collection बनाते हैं, एक options object assemble करते हैं, और generateSite को call करते हैं। नीचे का हर field index.ts में GenerateSiteOptions पर मौजूद है — कुछ भी आविष्कृत नहीं है।
यह TypeDoc bridge है, जो पूरी तरह ESM है और setu को सीधे import करता है (से write-site.ts):
import salty from '@jsdoc/salty';
import { generateSite } from '@clean-jsdoc-theme/setu';
// reflections → flat doclets → a salty collection (the shape setu consumes).
const doclets = reflectionsToDoclets(project, logger);
const collection = salty.taffy(doclets);
const manifest = generateSite(collection, {
...(pkg ? { pkg } : {}), // package.json fields
...(readme ? { readme } : {}), // README HTML → home page
...(sources.length > 0 ? { sources } : {}), // SourceFileInput[] → viewer pages
...(sectionOrder ? { sectionOrder } : {}), // sidebar section order
...(menu ? { menu } : {}), // full sidebar menu
...(clubSidebarItems ? { clubSidebarItems } : {}),// prefix-group sidebar entries
});JSDoc bridge वही करता है, साथ ही वे options जो केवल एक JSDoc run से अर्थपूर्ण हैं — tutorials, docs directory, doc-group ordering, और source-link target (से publish.ts):
const manifest = generateSite(data, {
...(pkg ? { pkg } : {}),
...(readme ? { readme } : {}),
...(tutorialTree.length > 0 ? { tutorials: tutorialTree } : {}),
...(sources.length > 0 ? { sources } : {}),
...(sources.length > 0 && sourceLinkToComment ? { sourceLinkToComment } : {}),
...(docs.length > 0 ? { docs } : {}),
...(docGroups ? { docGroups } : {}),
...(defaultDocGroup ? { defaultDocGroup } : {}),
...(sectionOrder ? { sectionOrder } : {}),
...(menu ? { menu } : {}),
...(clubSidebarItems ? { clubSidebarItems } : {}),
});pattern पर ध्यान दें: हर option conditionally spread होता है, इसलिए एक अनुपस्थित feature बस pass नहीं होती। एकमात्र आवश्यक argument collection है — generateSite के दोनों arguments अन्यथा इस बात से driven हैं कि bridge ने क्या पाया।
पूरी option surface
GenerateSiteOptions पर हर field (index.ts):
| Option | यह क्या करता है |
|---|---|
pkg | package.json fields manifest में embedded (header/footer/OG tags)। |
readme | Project README HTML के रूप में → site home page (slug '')। |
tutorials | एक TutorialInput[] tree → "Tutorials" के नीचे guide pages। |
docs | एक DocInput[] list (bridge द्वारा पूर्व-पठित) → prose/guide pages। एक root index home page बन जाता है। |
docGroups | Top-level doc-group display order। |
defaultDocGroup | बिना group वाले एक doc page के लिए group label। |
sources | एक SourceFileInput[] → read-only source-viewer pages + Source: links। |
sourceLinkToComment | true → Source: links declaration के बजाय doc-comment line की ओर इशारा करते हैं (default false)। |
sectionOrder | एक एकीकृत list जो @category names, doc groups, और kind labels को order करती है। |
menu | पूरा sidebar menu (sectionOrder पर वरीयता लेता है)। |
clubSidebarItems | संबंधित entries को one-level prefix subtrees में club करता है। |
जो वापस आता है, और कहाँ जाता है
generateSite एक SiteManifest लौटाता है — pages, nav, एक optional pkg, और एक content-stable buildId:
const manifest = generateSite(collection, opts);
// manifest.pages — Page[] (one per symbol + globals + prose + source pages)
// manifest.nav — NavNode[] (the sidebar tree)
// manifest.buildId — string (timestamp + content hash, for cache busting)manifest कोई search index field नहीं रखता। setu की per-page bodies वही हैं जो बाद में search को feed करती हैं; manifest ख़ुद बस
{ pages, nav, pkg?, buildId }है।
अगला कदम हमेशा वही होता है: manifest को सीधे dwar.render() को सौंप दें, जो इसे HTML में बदलता है। दोनों bridges ठीक यही करते हैं:
import { render } from '@clean-jsdoc-theme/dwar';
const result = await render(manifest, { theme, destination });
await writeOutputFiles(destination, result.files);setu ने model produce किया; dwar उसे render करता है। दोनों कभी एक-दूसरे को import नहीं करते — वे केवल utils में परिभाषित SiteManifest type पर मिलते हैं।
Authored features setu behavior में कैसे map होते हैं
आप अपने source comments और docs files में जो लिखते हैं वह यहाँ manifest structure बन जाता है। कुछ connections जानने योग्य हैं:
@categoryऔर@order. एक API symbol का@category Core/Parsing order=1tag उसका sidebar group बन जाता है (एक/-path इसे nest करता है:Core▸Parsing) और उसकी within-group sort key। एक standalone@order Nकिसी भी symbol को position करता है — यहाँ तक कि एक untagged@classको भी — उसके kind section के भीतर।generate-site.tsमें parse किया जाता है। देखें अपना sidebar structure करें और Custom tags।- README → home. आपका README (JSDoc/TypeDoc द्वारा HTML में rendered) slug
''पर home page बन जाता है,buildReadmePageके ज़रिए। आपकी docs directory में एक rootindex.mdइसे override करता है। - Docs folder → guide pages. आपकी docs directory के नीचे हर Markdown/HTML file अपने clean (unprefixed) slug पर एक prose page बन जाती है, अपने frontmatter
groupया अपने directory path द्वारा grouped,buildDocPagesके ज़रिए। Frontmattertitle/group/order/hiddenका सम्मान किया जाता है। देखें एक guides site बनाएँ। @link/@see/@tutorial. pass 2 में बनी link registry के विरुद्ध resolve किए जाते हैं — केवल वे targets resolve होते हैं जिनके पास वास्तव में एक page या member heading है; बाक़ी एक broken anchor के बजाय inert text पर fall back करते हैं (link-registry.ts)।
Read the source
ये canonical, working usages हैं — ऊपर के किसी snippet पर भरोसा करने के बजाय इन्हें पढ़ें:
- TypeDoc bridge:
packages/typedoc/src/write-site.ts—salty.taffyके साथ collection बनाता है,generateSiteको call करता है, manifest कोrenderको सौंपता है। - JSDoc bridge:
packages/clean-jsdoc-theme/src/publish.ts— वहpublish(data, opts, tutorials)entry जिसे JSDoc invoke करता है; sources, docs, और tutorials collect करता है, फिरgenerateSiteको call करता है। - The options type:
packages/setu/src/index.ts
आगे
- setu सिंहावलोकन — setu क्यों मौजूद है और इसकी contract boundaries।
- dwar सिंहावलोकन —
SiteManifestका उपभोग क्या करता है। - एक API reference बनाएँ — वह end-to-end path जिसे ये bridges power करते हैं।