|
| 1 | +#!/usr/bin/env php |
| 2 | +<?php |
| 3 | +require __DIR__.'/vendor/autoload.php'; |
| 4 | + |
| 5 | +use Symfony\Component\Console\Application; |
| 6 | +use Symfony\Component\Console\Input\InputInterface; |
| 7 | +use Symfony\Component\Console\Output\OutputInterface; |
| 8 | +use Symfony\Component\Process\Process; |
| 9 | +use Symfony\Component\Process\Exception\ProcessFailedException; |
| 10 | +use Symfony\Component\Console\Input\InputOption; |
| 11 | + |
| 12 | +(new Application('Symfony Docs Builder', '1.0')) |
| 13 | + ->register('build-docs') |
| 14 | + ->addOption('generate-fjson-files', null, InputOption::VALUE_NONE, 'Use this option to generate docs both in HTML and JSON formats') |
| 15 | + ->addOption('disable-cache', null, InputOption::VALUE_NONE, 'Use this option to force a full regeneration of all doc contents') |
| 16 | + ->setCode(function(InputInterface $input, OutputInterface $output) { |
| 17 | + $command = [ |
| 18 | + 'php', |
| 19 | + 'vendor/symfony/docs-builder/bin/console', |
| 20 | + 'build:docs', |
| 21 | + sprintf('--save-errors=%s', __DIR__.'/logs.txt'), |
| 22 | + __DIR__.'/../', |
| 23 | + __DIR__.'/output/', |
| 24 | + ]; |
| 25 | + |
| 26 | + if ($input->getOption('generate-fjson-files')) { |
| 27 | + $command[] = '--output-json'; |
| 28 | + } |
| 29 | + |
| 30 | + if ($input->getOption('disable-cache')) { |
| 31 | + $command[] = '--disable-cache'; |
| 32 | + } |
| 33 | + |
| 34 | + $process = new Process($command); |
| 35 | + $process->setTimeout(3600); |
| 36 | + |
| 37 | + $this->getHelper('process')->run($output, $process); |
| 38 | + |
| 39 | + if (!$process->isSuccessful()) { |
| 40 | + throw new ProcessFailedException($process); |
| 41 | + } |
| 42 | + }) |
| 43 | + ->getApplication() |
| 44 | + ->setDefaultCommand('build-docs', true) |
| 45 | + ->run(); |
0 commit comments