MCPcopy Index your code
hub / github.com/simstudioai/sim / generateAllTriggerDocs

Function generateAllTriggerDocs

scripts/generate-docs.ts:3761–3828  ·  view source on GitHub ↗

* Generate one MDX file per trigger provider and update the sidebar meta.json. * Hand-written docs (HANDWRITTEN_TRIGGER_DOCS) are never touched.

()

Source from the content-addressed store, hash-verified

3759 * Hand-written docs (HANDWRITTEN_TRIGGER_DOCS) are never touched.
3760 */
3761async function generateAllTriggerDocs(): Promise<void> {
3762 try {
3763 console.log('Generating trigger documentation...')
3764
3765 if (!fs.existsSync(TRIGGER_DOCS_OUTPUT_PATH)) {
3766 fs.mkdirSync(TRIGGER_DOCS_OUTPUT_PATH, { recursive: true })
3767 }
3768
3769 const fullRegistry = await buildFullTriggerRegistry()
3770 const grouped = groupTriggersByProvider(fullRegistry)
3771 const colorMap = await buildProviderColorMap()
3772
3773 const generatedProviders: string[] = []
3774
3775 for (const [provider, triggers] of grouped) {
3776 if (SKIP_TRIGGER_PROVIDERS.has(provider)) {
3777 console.log(`Skipping trigger provider: ${provider} (covered by hand-written docs)`)
3778 continue
3779 }
3780
3781 // The trigger lives on the same per-service integration page as the
3782 // service's actions (provider ≠ block type for a few services).
3783 const blockType = PROVIDER_TO_BLOCK_TYPE[provider] ?? provider
3784 const outputFilePath = path.join(DOCS_OUTPUT_PATH, `${blockType}.mdx`)
3785 const baseName = path.basename(outputFilePath, '.mdx')
3786
3787 if (HANDWRITTEN_INTEGRATION_DOCS.has(baseName) || HANDWRITTEN_TRIGGER_DOCS.has(baseName)) {
3788 console.log(`Skipping ${provider} — hand-written page`)
3789 continue
3790 }
3791
3792 const existing = fs.existsSync(outputFilePath)
3793 ? fs.readFileSync(outputFilePath, 'utf-8')
3794 : null
3795
3796 if (existing?.includes('\n## Actions')) {
3797 // Actions page generated this run by the block pass — append the Triggers section.
3798 if (!existing.includes('\n## Triggers')) {
3799 fs.appendFileSync(outputFilePath, `\n${buildTriggersSection(triggers)}`)
3800 }
3801 } else {
3802 // Trigger-only service (no actions block) — (re)write the standalone page,
3803 // preserving manual content from the previous run. Cleanup spares these
3804 // pages (category 'triggers' blocks are in the canonical set).
3805 const providerColor = colorMap.get(blockType) ?? '#6B7280'
3806 const markdown = generateTriggerProviderDoc(provider, triggers, blockType, providerColor)
3807 const rawSections = existing ? extractManualContent(existing) : {}
3808 const manualSections = Object.fromEntries(
3809 Object.entries(rawSections).filter(([, v]) => v.length > 0)
3810 )
3811 const finalContent =
3812 Object.keys(manualSections).length > 0
3813 ? mergeWithManualContent(markdown, existing, manualSections)
3814 : markdown
3815 fs.writeFileSync(outputFilePath, finalContent)
3816 }
3817
3818 generatedProviders.push(blockType)

Callers 1

generateAllBlockDocsFunction · 0.85

Calls 13

buildFullTriggerRegistryFunction · 0.85
groupTriggersByProviderFunction · 0.85
buildProviderColorMapFunction · 0.85
buildTriggersSectionFunction · 0.85
extractManualContentFunction · 0.85
mergeWithManualContentFunction · 0.85
logMethod · 0.80
joinMethod · 0.80
errorMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected