MCPcopy Create free account
hub / github.com/ChromeDevTools/chrome-devtools-mcp / generateReference

Function generateReference

scripts/generate-docs.ts:192–337  ·  view source on GitHub ↗
(
  title: string,
  outputPath: string,
  toolsWithAnnotations: ToolWithAnnotations[],
  categories: Record<string, ToolWithAnnotations[]>,
  sortedCategories: string[],
)

Source from the content-addressed store, hash-verified

190}
191
192async 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) {

Callers 1

Calls 4

isCategoryOffByDefaultFunction · 0.85
categoryToFlagNameFunction · 0.85
escapeHtmlTagsFunction · 0.85
addCrossLinksFunction · 0.85

Tested by

no test coverage detected