Skip to content

Commit e35f068

Browse files
committed
refactor(docs): drop 33 more comments that restated their code
Second pass over the generator, e.g. `// Copy icons from sim app to docs app` above `copyIconsFile()`. Kept the multi-line runs (those carry reasoning), the ones with concrete examples, and the one marking a deliberate empty catch. Verified byte-identical output across all 289 generated files. Generator: 3903 -> 3870 lines, 4306 at the start of this branch.
1 parent 7b5b70f commit e35f068

1 file changed

Lines changed: 0 additions & 33 deletions

File tree

scripts/generate-docs.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ if (!fs.existsSync(DOCS_OUTPUT_PATH)) {
157157
fs.mkdirSync(DOCS_OUTPUT_PATH, { recursive: true })
158158
}
159159

160-
// Ensure docs components directory exists
161160
const docsComponentsDir = path.dirname(DOCS_ICONS_PATH)
162161
if (!fs.existsSync(docsComponentsDir)) {
163162
fs.mkdirSync(docsComponentsDir, { recursive: true })
@@ -732,7 +731,6 @@ async function buildToolDescriptionMap(): Promise<ToolMaps> {
732731
* 'api-key' if it uses a plain API key field, or 'none' otherwise.
733732
*/
734733
function extractAuthType(blockContent: string): 'oauth' | 'api-key' | 'none' {
735-
// Prefer the authoritative `authMode` declaration when present.
736734
if (/authMode\s*:\s*AuthMode\.OAuth\b/.test(blockContent)) return 'oauth'
737735
if (/authMode\s*:\s*AuthMode\.(?:ApiKey|BotToken)\b/.test(blockContent)) return 'api-key'
738736
// Fall back to credential subBlock heuristics for blocks without authMode.
@@ -994,7 +992,6 @@ async function writeIntegrationsJson(iconMapping: Record<string, IconRef>): Prom
994992
}
995993
const integrationType = config.integrationType as IntegrationType
996994

997-
// Deduplicate by stripped base type
998995
const baseType = stripVersionSuffix(blockType)
999996
if (seenBaseTypes.has(baseType)) continue
1000997
seenBaseTypes.add(baseType)
@@ -1160,7 +1157,6 @@ function extractAllBlockConfigs(fileContent: string): BlockConfig[] {
11601157
continue
11611158
}
11621159

1163-
// Pass fileContent to enable spread inheritance resolution
11641160
const config = extractBlockConfigFromContent(blockContent, blockName, fileContent)
11651161
if (config) {
11661162
// For V2 blocks that don't have an explicit icon, use the primary icon from the file
@@ -1194,7 +1190,6 @@ function extractBlockConfigFromContent(
11941190
fileContent?: string
11951191
): BlockConfig | null {
11961192
try {
1197-
// Check for spread inheritance
11981193
const spreadBase = extractSpreadBase(blockContent)
11991194
let baseConfig: BlockConfig | null = null
12001195

@@ -1255,7 +1250,6 @@ function extractBlockConfigFromContent(
12551250
/access\s*:\s*\(\s*\w+Block\.tools\?\.access\s*\|\|\s*\[\]\s*\)\.map\s*\(\s*\(\s*\w+\s*\)\s*=>\s*`\$\{\s*\w+\s*\}_v(\d+)`\s*\)/
12561251
)
12571252
if (mapMatch) {
1258-
// V2 block - append the version suffix to base tools
12591253
const versionSuffix = `_v${mapMatch[1]}`
12601254
finalToolsAccess = baseConfig.tools.access.map((tool) => `${tool}${versionSuffix}`)
12611255
}
@@ -1615,13 +1609,11 @@ function resolveConstReference(
16151609
toolPrefix: string,
16161610
depth = 0
16171611
): Record<string, any> | null {
1618-
// Prevent infinite recursion
16191612
if (depth > 10) {
16201613
console.warn(`Max recursion depth reached resolving const: ${constName}`)
16211614
return null
16221615
}
16231616

1624-
// Check cache first
16251617
const cacheKey = `${toolPrefix}:${constName}`
16261618
if (constResolutionCache.has(cacheKey)) {
16271619
return constResolutionCache.get(cacheKey)!
@@ -1670,7 +1662,6 @@ function resolveConstReference(
16701662
// Otherwise, this is a properties object - use parseConstProperties
16711663
const properties = parseConstProperties(constContent, toolPrefix, typesContent, depth + 1)
16721664

1673-
// Cache the result
16741665
constResolutionCache.set(cacheKey, properties)
16751666

16761667
return properties
@@ -1702,7 +1693,6 @@ function parseConstProperties(
17021693

17031694
const resolvedConst = resolveConstFromTypesContent(constName, typesContent, toolPrefix, depth)
17041695
if (resolvedConst && typeof resolvedConst === 'object') {
1705-
// Spread all properties from the resolved const
17061696
Object.assign(properties, resolvedConst)
17071697
}
17081698
}
@@ -1728,7 +1718,6 @@ function parseConstProperties(
17281718
// For 'properties' or 'type', check if it's an output field definition vs a keyword
17291719
// Output field definitions have 'type:' inside (e.g., { type: 'string', description: '...' })
17301720
if ((propName === 'properties' || propName === 'type') && !constRef) {
1731-
// Peek at what's inside the braces
17321721
const startPos = match.index + match[0].length - 1
17331722
const endPos = findMatchingClose(content, startPos)
17341723
if (endPos !== -1) {
@@ -1752,7 +1741,6 @@ function parseConstProperties(
17521741
properties[propName] = resolvedConst
17531742
}
17541743
} else {
1755-
// This property has inline definition
17561744
const startPos = match.index + match[0].length - 1
17571745
const endPos = findMatchingClose(content, startPos)
17581746

@@ -1780,7 +1768,6 @@ function resolveConstFromTypesContent(
17801768
): Record<string, any> | null {
17811769
if (depth > 10) return null
17821770

1783-
// Check cache
17841771
const cacheKey = `${toolPrefix}:${constName}`
17851772
if (constResolutionCache.has(cacheKey)) {
17861773
return constResolutionCache.get(cacheKey)!
@@ -1806,15 +1793,13 @@ function resolveConstFromTypesContent(
18061793
// Check if this const defines a complete output field (has type property)
18071794
const typeMatch = constContent.match(/^\s*type\s*:\s*['"]([^'"]+)['"]/)
18081795
if (typeMatch) {
1809-
// This is a complete output definition (like ATTENDEES_OUTPUT)
18101796
const result = parseConstFieldContent(constContent, toolPrefix, typesContent, depth)
18111797
if (result) {
18121798
constResolutionCache.set(cacheKey, result)
18131799
}
18141800
return result
18151801
}
18161802

1817-
// This is a properties object (like ATTENDEE_OUTPUT_PROPERTIES)
18181803
const properties = parseConstProperties(constContent, toolPrefix, typesContent, depth + 1)
18191804
constResolutionCache.set(cacheKey, properties)
18201805
return properties
@@ -1858,9 +1843,7 @@ function parseConstFieldContent(
18581843
description: description || '',
18591844
}
18601845

1861-
// Check for properties - either inline or const reference
18621846
if (fieldType === 'object' || fieldType === 'json') {
1863-
// Check for const reference first
18641847
const propsConstMatch = fieldContent.match(/properties\s*:\s*([A-Z][A-Z_0-9]+)/)
18651848
if (propsConstMatch) {
18661849
const resolvedProps = resolveConstFromTypesContent(
@@ -1873,7 +1856,6 @@ function parseConstFieldContent(
18731856
result.properties = resolvedProps
18741857
}
18751858
} else {
1876-
// Check for inline properties
18771859
const propertiesStart = fieldContent.search(/properties\s*:\s*\{/)
18781860
if (propertiesStart !== -1) {
18791861
const braceStart = fieldContent.indexOf('{', propertiesStart)
@@ -1892,7 +1874,6 @@ function parseConstFieldContent(
18921874
}
18931875
}
18941876

1895-
// Check for items (arrays)
18961877
const itemsConstMatch = fieldContent.match(/items\s*:\s*([A-Z][A-Z_0-9]+)/)
18971878
if (itemsConstMatch) {
18981879
const resolvedItems = resolveConstFromTypesContent(
@@ -2319,7 +2300,6 @@ function parseToolOutputsField(outputsContent: string, toolPrefix?: string): Rec
23192300
// First, handle top-level const references
23202301
// Patterns: "data: BOOKING_DATA_OUTPUT_PROPERTIES" or "pagination: PAGINATION_OUTPUT"
23212302
if (toolPrefix) {
2322-
// Pattern 1: Direct const reference
23232303
const constRefRegex = /(\w+)\s*:\s*([A-Z][A-Z_0-9]+)\s*(?:,|$)/g
23242304
let constMatch
23252305
while ((constMatch = constRefRegex.exec(outputsContent)) !== null) {
@@ -2379,7 +2359,6 @@ function parseToolOutputsField(outputsContent: string, toolPrefix?: string): Rec
23792359

23802360
const resolvedConst = resolveConstReference(constName, toolPrefix)
23812361
if (resolvedConst && typeof resolvedConst === 'object') {
2382-
// Spread all properties from the resolved const
23832362
Object.assign(outputs, resolvedConst)
23842363
}
23852364
}
@@ -2481,7 +2460,6 @@ function parseFieldContent(fieldContent: string, toolPrefix?: string): any {
24812460
if (resolvedConst && typeof resolvedConst === 'object') {
24822461
// Start with the resolved const and override with inline properties
24832462
const result: any = { ...resolvedConst }
2484-
// Override description if provided inline
24852463
if (description) {
24862464
result.description = description
24872465
}
@@ -2520,7 +2498,6 @@ function parseFieldContent(fieldContent: string, toolPrefix?: string): any {
25202498
result.properties = resolvedProps
25212499
}
25222500
} else {
2523-
// Check for inline properties
25242501
const propertiesRegex = /properties\s*:\s*{/
25252502
const propertiesStart = fieldContent.search(propertiesRegex)
25262503

@@ -2685,7 +2662,6 @@ function parsePropertiesContent(
26852662

26862663
const resolvedConst = resolveConstReference(constName, toolPrefix)
26872664
if (resolvedConst && typeof resolvedConst === 'object') {
2688-
// Spread all properties from the resolved const
26892665
Object.assign(properties, resolvedConst)
26902666
}
26912667
}
@@ -2798,7 +2774,6 @@ async function getToolInfo(toolName: string): Promise<{
27982774
priority: 'fallback',
27992775
})
28002776
} else {
2801-
// Non-versioned tool: try the direct file
28022777
possibleLocations.push({
28032778
path: path.join(rootDir, `apps/sim/tools/${toolPrefix}/${toolSuffix}.ts`),
28042779
priority: 'exact',
@@ -2814,7 +2789,6 @@ async function getToolInfo(toolName: string): Promise<{
28142789
priority: 'fallback',
28152790
})
28162791

2817-
// Fall back to index.ts
28182792
possibleLocations.push({
28192793
path: path.join(rootDir, `apps/sim/tools/${toolPrefix}/index.ts`),
28202794
priority: 'fallback',
@@ -2970,7 +2944,6 @@ async function generateBlockDoc(blockPath: string) {
29702944
return
29712945
}
29722946

2973-
// Process each block config
29742947
for (const blockConfig of blockConfigs) {
29752948
if (!blockConfig.type) {
29762949
continue
@@ -3339,7 +3312,6 @@ function resolveConstVariable(
33393312
): Record<string, any> {
33403313
if (depth > 8) return {}
33413314

3342-
// Match `const varName = {` (with optional type annotation)
33433315
const varRegex = new RegExp(`(?<![.\\w])const\\s+${varName}\\s*(?::[^=]+)?=\\s*\\{`)
33443316

33453317
for (const content of [primaryContent, utilsContent]) {
@@ -3621,7 +3593,6 @@ function buildTriggersSection(triggers: TriggerFullInfo[]): string {
36213593
for (let i = 0; i < triggers.length; i++) {
36223594
const trigger = triggers[i]
36233595

3624-
// Configuration table
36253596
let configSection = ''
36263597
if (trigger.configFields.length > 0) {
36273598
configSection = '#### Configuration\n\n'
@@ -3635,7 +3606,6 @@ function buildTriggersSection(triggers: TriggerFullInfo[]): string {
36353606
configSection += '\n'
36363607
}
36373608

3638-
// Output table
36393609
let outputSection = ''
36403610
if (Object.keys(trigger.outputs).length > 0) {
36413611
outputSection = '#### Output\n\n'
@@ -3830,15 +3800,12 @@ async function generateAllTriggerDocs(): Promise<void> {
38303800

38313801
async function generateAllBlockDocs() {
38323802
try {
3833-
// Copy icons from sim app to docs app
38343803
copyIconsFile()
38353804

3836-
// Generate icon mappings from block definitions
38373805
const docsIconMapping = await generateIconMapping({ includeHidden: true })
38383806
const visibleIconMapping = await generateIconMapping({ includeHidden: false })
38393807
writeIconMapping(docsIconMapping)
38403808

3841-
// Generate landing integrations page data (JSON + icon mapping)
38423809
await writeIntegrationsJson(visibleIconMapping)
38433810
writeIntegrationsIconMapping(visibleIconMapping)
38443811

0 commit comments

Comments
 (0)