2020-09-30 09:25:41 +02:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
|
|
|
/* (c) Anton Medvedev <anton@medv.io>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Deployer;
|
|
|
|
|
|
|
|
use Deployer\Documentation\ApiGen;
|
2020-10-02 00:11:13 +02:00
|
|
|
use Deployer\Documentation\DocGen;
|
2020-09-30 09:25:41 +02:00
|
|
|
use Symfony\Component\Console\Application;
|
|
|
|
use Symfony\Component\Console\Input\ArgvInput;
|
|
|
|
use Symfony\Component\Console\Output\ConsoleOutput;
|
|
|
|
|
|
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
|
|
|
|
chdir(realpath(__DIR__ . '/..'));
|
|
|
|
|
|
|
|
$input = new ArgvInput();
|
|
|
|
$output = new ConsoleOutput();
|
|
|
|
$app = new Application('DocGen', '1.0.0');
|
2020-10-02 00:11:13 +02:00
|
|
|
$app->setDefaultCommand('all');
|
2020-09-30 09:25:41 +02:00
|
|
|
|
2020-10-08 09:53:25 +02:00
|
|
|
$api = function () use ($output) {
|
2020-09-30 09:25:41 +02:00
|
|
|
$parser = new ApiGen();
|
|
|
|
$parser->parse(file_get_contents(__DIR__ . '/../src/functions.php'));
|
2020-09-30 15:35:44 +02:00
|
|
|
$md = $parser->markdown();
|
|
|
|
file_put_contents(__DIR__ . '/../docs/api.md', $md);
|
2020-10-08 09:53:25 +02:00
|
|
|
$output->writeln('API Reference documentation updated.');
|
2020-10-02 00:11:13 +02:00
|
|
|
};
|
|
|
|
|
2020-10-08 09:53:25 +02:00
|
|
|
$recipes = function () use ($input, $output) {
|
2020-10-02 00:11:13 +02:00
|
|
|
$docgen = new DocGen(__DIR__ . '/..');
|
|
|
|
$docgen->parse(__DIR__ . '/../recipe');
|
|
|
|
$docgen->parse(__DIR__ . '/../contrib');
|
|
|
|
|
|
|
|
if ($input->getOption('json')) {
|
|
|
|
echo json_encode($docgen->recipes, JSON_PRETTY_PRINT);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$docgen->gen(__DIR__ . '/../docs');
|
2020-10-08 09:53:25 +02:00
|
|
|
$output->writeln('Recipes documentation updated.');
|
2020-10-02 00:11:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
$app->register('api')->setCode($api);
|
|
|
|
$app->register('recipes')->setCode($recipes)->addOption('json');
|
|
|
|
$app->register('all')->setCode(function () use ($recipes, $api) {
|
|
|
|
$api();
|
|
|
|
$recipes();
|
2020-10-08 09:53:25 +02:00
|
|
|
echo `git status`;
|
2020-10-02 00:11:13 +02:00
|
|
|
})->addOption('json');
|
2020-09-30 09:25:41 +02:00
|
|
|
|
|
|
|
$app->run($input, $output);
|