MCPcopy Create free account
hub / github.com/github/copilot-sdk / main

Function main

scripts/docs-validation/validate.ts:581–647  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

579}
580
581async function main() {
582 const args = process.argv.slice(2);
583 const langArg = args.find((a) => a.startsWith("--lang="));
584 const targetLang = langArg?.split("=")[1];
585
586 console.log("🔍 Validating documentation code blocks...\n");
587
588 if (!fs.existsSync(VALIDATION_DIR)) {
589 console.error("❌ No extracted code found. Run extraction first:");
590 console.error(" npm run extract");
591 process.exit(1);
592 }
593
594 let totalFailed = 0;
595 const summaryData: {
596 language: string;
597 passed: number;
598 failed: number;
599 failures: ValidationResult[];
600 }[] = [];
601
602 const validators: [string, () => Promise<ValidationResult[]>][] = [
603 ["TypeScript", validateTypeScript],
604 ["Python", validatePython],
605 ["Go", validateGo],
606 ["C#", validateCSharp],
607 ["Java", validateJava],
608 ];
609
610 for (const [name, validator] of validators) {
611 const langKey = name.toLowerCase().replace("#", "sharp");
612 if (targetLang && langKey !== targetLang) continue;
613
614 console.log(`\n${name}:`);
615 const results = await validator();
616 const { failed, passed, failures } = printResults(results, name);
617 totalFailed += failed;
618 summaryData.push({ language: name, passed, failed, failures });
619 }
620
621 // Write GitHub Actions summary
622 writeGitHubSummary(summaryData);
623
624 console.log("\n" + "─".repeat(40));
625
626 if (totalFailed > 0) {
627 console.log(`\n❌ Validation failed: ${totalFailed} file(s) have errors`);
628 console.log("\nTo fix:");
629 console.log(" 1. Check the error messages above");
630 console.log(" 2. Update the code blocks in the markdown files");
631 console.log(" 3. Re-run: npm run validate");
632 console.log("\nTo skip a code block, add before it:");
633 console.log(" <!-- docs-validate: skip -->");
634 console.log("\nTo validate a complete version while showing a snippet:");
635 console.log(" <!-- docs-validate: hidden -->");
636 console.log(" ```lang");
637 console.log(" // full compilable code");
638 console.log(" ```");

Callers 1

validate.tsFile · 0.70

Calls 5

printResultsFunction · 0.85
writeGitHubSummaryFunction · 0.85
logMethod · 0.45
errorMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…