MCPcopy Index your code
hub / github.com/github/copilot-sdk / main

Function main

scripts/docs-validation/extract.ts:428–544  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

426}
427
428async function main() {
429 console.log("📖 Extracting code blocks from documentation...\n");
430
431 // Clean output directory
432 if (fs.existsSync(OUTPUT_DIR)) {
433 fs.rmSync(OUTPUT_DIR, { recursive: true });
434 }
435 fs.mkdirSync(OUTPUT_DIR, { recursive: true });
436
437 // Create language subdirectories
438 for (const lang of ["typescript", "python", "go", "csharp", "java"]) {
439 fs.mkdirSync(path.join(OUTPUT_DIR, lang), { recursive: true });
440 }
441
442 // Find all markdown files
443 const mdFiles = await glob("**/*.md", {
444 cwd: DOCS_DIR,
445 ignore: [".validation/**", "node_modules/**", "IMPROVEMENT_PLAN.md"],
446 });
447
448 console.log(`Found ${mdFiles.length} markdown files\n`);
449
450 const manifest: ExtractionManifest = {
451 extractedAt: new Date().toISOString(),
452 blocks: [],
453 };
454
455 const langCounts = new Map<string, number>();
456 let totalBlocks = 0;
457 let skippedBlocks = 0;
458 let hiddenBlocks = 0;
459
460 for (const mdFile of mdFiles) {
461 const fullPath = path.join(DOCS_DIR, mdFile);
462 const content = fs.readFileSync(fullPath, "utf-8");
463 const blocks = parseMarkdownCodeBlocks(content, mdFile);
464
465 for (const block of blocks) {
466 if (block.skip) {
467 skippedBlocks++;
468 continue;
469 }
470
471 if (block.hidden) {
472 hiddenBlocks++;
473 }
474
475 // Skip empty or trivial blocks
476 if (block.code.trim().length < 10) {
477 continue;
478 }
479
480 // Skip incomplete code fragments that can't be validated standalone
481 if (shouldSkipFragment(block)) {
482 skippedBlocks++;
483 continue;
484 }
485

Callers 1

extract.tsFile · 0.70

Calls 8

parseMarkdownCodeBlocksFunction · 0.85
shouldSkipFragmentFunction · 0.85
generateFileNameFunction · 0.85
wrapCodeForValidationFunction · 0.85
getSourceCommentFunction · 0.85
joinMethod · 0.80
logMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…