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

Function generateMarkdownForBlock

scripts/generate-docs.ts:2783–2973  ·  view source on GitHub ↗
(
  blockConfig: BlockConfig,
  displayType?: string
)

Source from the content-addressed store, hash-verified

2781}
2782
2783async function generateMarkdownForBlock(
2784 blockConfig: BlockConfig,
2785 displayType?: string
2786): Promise<string> {
2787 const {
2788 type,
2789 name,
2790 description,
2791 longDescription,
2792 bgColor,
2793 outputs = {},
2794 tools = { access: [] },
2795 } = blockConfig
2796
2797 let outputsSection = ''
2798
2799 if (outputs && Object.keys(outputs).length > 0) {
2800 outputsSection = '## Outputs\n\n'
2801
2802 outputsSection += '| Output | Type | Description |\n'
2803 outputsSection += '| ------ | ---- | ----------- |\n'
2804
2805 for (const outputKey in outputs) {
2806 const output = outputs[outputKey]
2807
2808 const escapedDescription = output.description
2809 ? output.description
2810 .replace(/\|/g, '\\|')
2811 .replace(/\{/g, '\\{')
2812 .replace(/\}/g, '\\}')
2813 .replace(/\(/g, '\\(')
2814 .replace(/\)/g, '\\)')
2815 .replace(/\[/g, '\\[')
2816 .replace(/\]/g, '\\]')
2817 .replace(/</g, '&lt;')
2818 .replace(/>/g, '&gt;')
2819 : `Output from ${outputKey}`
2820
2821 if (typeof output.type === 'string') {
2822 outputsSection += `| \`${outputKey}\` | ${output.type} | ${escapedDescription} |\n`
2823 } else if (output.type && typeof output.type === 'object') {
2824 outputsSection += `| \`${outputKey}\` | object | ${escapedDescription} |\n`
2825
2826 for (const propName in output.type) {
2827 const propType = output.type[propName]
2828 const commentMatch =
2829 propName && output.type[propName]._comment
2830 ? output.type[propName]._comment
2831 : `${propName} of the ${outputKey}`
2832
2833 outputsSection += `| ↳ \`${propName}\` | ${propType} | ${commentMatch} |\n`
2834 }
2835 } else if (output.properties) {
2836 outputsSection += `| \`${outputKey}\` | object | ${escapedDescription} |\n`
2837
2838 for (const propName in output.properties) {
2839 const prop = output.properties[propName]
2840 const escapedPropertyDescription = prop.description

Callers 1

generateBlockDocFunction · 0.85

Calls 5

stripVersionSuffixFunction · 0.90
getToolInfoFunction · 0.85
formatOutputStructureFunction · 0.85
logMethod · 0.80
replaceMethod · 0.65

Tested by

no test coverage detected