diff --git a/monorepo/DocumentationIntelligence/DocumentationIntelligence.php b/monorepo/DocumentationIntelligence/DocumentationIntelligence.php new file mode 100644 index 00000000000..a2856c3f8c8 --- /dev/null +++ b/monorepo/DocumentationIntelligence/DocumentationIntelligence.php @@ -0,0 +1,298 @@ +&1', $output, $returnCode); + + if ($returnCode !== 0) { + echo '
'.implode("\n", $output).''; + exit(1); + } + + return require_once __DIR__.'/results/dashboard.html'; +} + +require_once __DIR__.'/../../vendor/autoload.php'; +require_once __DIR__.'/../../packages/hydefront/.github/scripts/minima.php'; + +define('TIME_START', microtime(true)); +define('BASE_PATH', realpath(__DIR__.'/../../')); +define('OUTPUT_PATH', realpath(__DIR__.'/results')); + +Command::main(function () { + /** @var Command $this */ + $this->info('Generating documentation intelligence...'); + $this->line(); + + $generator = new DocumentationIntelligence(); + + task('discover pages', fn () => $generator->discoverPages()); + task('assemble model', fn () => $generator->assembleModel()); + task('create pruned model', fn () => $generator->createPrunedModel()); + task('generate model data', fn () => $generator->getModelStatistics()); + task('create dashboard page', fn () => $generator->createDashboardPage()); + + $this->line(); + + $this->line(sprintf(<<<'EOF' + Full model details: + Model size: %s + Model words: %s + Model lines: %s + + Pruned model details: + Model size: %s + Model words: %s + Model lines: %s + Pruned model compression: %s%% + EOF, + ...array_values($generator->getModelStatistics()) + )); + + $this->line(); + $this->info(sprintf('Time taken: %s. Memory used: %s', + number_format((microtime(true) - TIME_START) * 1000, 2).'ms', + number_format(memory_get_peak_usage() / 1024 / 1024, 2).'MB' + )); + + return 0; +}); + +class DocumentationIntelligence +{ + protected HydeKernel $kernel; + + /** @var array