( title: string, outputPath: string, toolsWithAnnotations: ToolWithAnnotations[], categories: Record<string, ToolWithAnnotations[]>, sortedCategories: string[], )
| 190 | } |
| 191 | |
| 192 | async function generateReference( |
| 193 | title: string, |
| 194 | outputPath: string, |
| 195 | toolsWithAnnotations: ToolWithAnnotations[], |
| 196 | categories: Record<string, ToolWithAnnotations[]>, |
| 197 | sortedCategories: string[], |
| 198 | ) { |
| 199 | console.log(`Found ${toolsWithAnnotations.length} tools`); |
| 200 | |
| 201 | // Generate markdown documentation |
| 202 | let markdown = `<!-- AUTO GENERATED DO NOT EDIT - run 'npm run gen' to update--> |
| 203 | |
| 204 | # ${title} |
| 205 | |
| 206 | `; |
| 207 | // Generate table of contents |
| 208 | for (const category of sortedCategories) { |
| 209 | const categoryTools = categories[category]; |
| 210 | const categoryName = labels[category]; |
| 211 | const anchorName = categoryName.toLowerCase().replace(/\s+/g, '-'); |
| 212 | markdown += `- **[${categoryName}](#${anchorName})** (${categoryTools.length} tools)\n`; |
| 213 | |
| 214 | // Sort tools within category for TOC |
| 215 | categoryTools.sort(sortTools); |
| 216 | for (const tool of categoryTools) { |
| 217 | // Generate proper markdown anchor link: backticks are removed, keep underscores, lowercase |
| 218 | const anchorLink = tool.name.toLowerCase(); |
| 219 | markdown += ` - [\`${tool.name}\`](#${anchorLink})\n`; |
| 220 | } |
| 221 | } |
| 222 | markdown += '\n'; |
| 223 | |
| 224 | for (const category of sortedCategories) { |
| 225 | const categoryTools = categories[category]; |
| 226 | const categoryName = labels[category]; |
| 227 | |
| 228 | markdown += `## ${categoryName}\n\n`; |
| 229 | |
| 230 | if (isCategoryOffByDefault(category)) { |
| 231 | const flagName = `--${categoryToFlagName(category)}`; |
| 232 | |
| 233 | markdown += `> NOTE: The ${categoryName} category is not active by default. Use the '${flagName}' flag.\n\n`; |
| 234 | } |
| 235 | |
| 236 | // Sort tools within category |
| 237 | categoryTools.sort(sortTools); |
| 238 | |
| 239 | for (const tool of categoryTools) { |
| 240 | markdown += `### \`${tool.name}\`\n\n`; |
| 241 | |
| 242 | if (tool.description) { |
| 243 | // Escape HTML tags but preserve JS function syntax |
| 244 | let escapedDescription = escapeHtmlTags(tool.description); |
| 245 | |
| 246 | const requiredFlags: string[] = []; |
| 247 | |
| 248 | const isOffByDefault = isCategoryOffByDefault(category); |
| 249 | if (isOffByDefault) { |
no test coverage detected