( title: string, outputPath: string, toolsWithAnnotations: ToolWithAnnotations[], categories: Record<string, ToolWithAnnotations[]>, sortedCategories: string[], )
| 291 | } |
| 292 | |
| 293 | async function generateReference( |
| 294 | title: string, |
| 295 | outputPath: string, |
| 296 | toolsWithAnnotations: ToolWithAnnotations[], |
| 297 | categories: Record<string, ToolWithAnnotations[]>, |
| 298 | sortedCategories: string[], |
| 299 | ) { |
| 300 | console.log(`Found ${toolsWithAnnotations.length} tools`); |
| 301 | |
| 302 | // Generate markdown documentation |
| 303 | let markdown = `<!-- AUTO GENERATED DO NOT EDIT - run 'npm run gen' to update--> |
| 304 | |
| 305 | # ${title} |
| 306 | |
| 307 | `; |
| 308 | // Generate table of contents |
| 309 | for (const category of sortedCategories) { |
| 310 | const categoryTools = categories[category]; |
| 311 | const categoryName = labels[category]; |
| 312 | const anchorName = categoryName.toLowerCase().replace(/\s+/g, '-'); |
| 313 | markdown += `- **[${categoryName}](#${anchorName})** (${categoryTools.length} tools)\n`; |
| 314 | |
| 315 | // Sort tools within category for TOC |
| 316 | categoryTools.sort(sortTools); |
| 317 | for (const tool of categoryTools) { |
| 318 | // Generate proper markdown anchor link: backticks are removed, keep underscores, lowercase |
| 319 | const anchorLink = tool.name.toLowerCase(); |
| 320 | markdown += ` - [\`${tool.name}\`](#${anchorLink})\n`; |
| 321 | } |
| 322 | } |
| 323 | markdown += '\n'; |
| 324 | |
| 325 | for (const category of sortedCategories) { |
| 326 | const categoryTools = categories[category]; |
| 327 | const categoryName = labels[category]; |
| 328 | |
| 329 | markdown += `## ${categoryName}\n\n`; |
| 330 | |
| 331 | if (OFF_BY_DEFAULT_CATEGORIES.includes(category)) { |
| 332 | const flagName = `--${buildFlag(category)}`; |
| 333 | |
| 334 | markdown += `> NOTE: The ${categoryName} category is not active by default. Use the '${flagName}' flag.\n\n`; |
| 335 | } |
| 336 | |
| 337 | // Sort tools within category |
| 338 | categoryTools.sort(sortTools); |
| 339 | |
| 340 | for (const tool of categoryTools) { |
| 341 | markdown += `### \`${tool.name}\`\n\n`; |
| 342 | |
| 343 | if (tool.description) { |
| 344 | // Escape HTML tags but preserve JS function syntax |
| 345 | let escapedDescription = escapeHtmlTags(tool.description); |
| 346 | |
| 347 | const requiredFlags: string[] = []; |
| 348 | |
| 349 | const isOffByDefault = OFF_BY_DEFAULT_CATEGORIES.includes(category); |
| 350 | if (isOffByDefault) { |
no test coverage detected