Skip to content

Commit

Permalink
Added --output option.
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Apr 13, 2021
1 parent f1fce2b commit ffb2ee9
Show file tree
Hide file tree
Showing 4 changed files with 358 additions and 1,169 deletions.
19 changes: 19 additions & 0 deletions bin/wp-documentor
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\StreamOutput;
use Symfony\Component\Console\Style\SymfonyStyle;

$application = new Application( 'Pronamic WordPress Documentor', '1.0.0' );
Expand All @@ -40,6 +41,7 @@ $application->register( 'parse' )
->addOption( 'template', null, InputOption::VALUE_REQUIRED, 'Render output in a template format.', null )
->addOption( 'type', null, InputOption::VALUE_REQUIRED, 'Hook type.', null )
->addOption( 'relative', null, InputOption::VALUE_REQUIRED, 'Relative to directory.', null )
->addOption( 'output', 'o', InputOption::VALUE_REQUIRED, 'Write output to file instead of stdout.', null )
->addOption( 'memory-limit', null, InputOption::VALUE_REQUIRED, 'Memory limit for the run.', null )
->setCode( function( InputInterface $input, OutputInterface $output ) {
$io = new SymfonyStyle( $input, $output );
Expand All @@ -60,8 +62,25 @@ $application->register( 'parse' )
\ini_set( 'memory_limit', $memory_limit );
}

/**
* Output.
*
* @link https://github.com/symfony/symfony/blob/5.x/src/Symfony/Component/Console/Output/StreamOutput.php
*/
$output = $input->getOption( 'output' );

if ( null !== $output ) {
$output = new StreamOutput( \fopen( $output, 'w' ) );
}

/**
* Parse.
*/
$documentor->parse();

/**
* Printer.
*/
$printer = null;

$format = $input->getOption( 'format' );
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
"post-update-cmd": "echo 'Optionally run: composer bin all update'",
"phpdoc": "vendor/bin/phpdoc --setting='guides.enabled=true'",
"test": [
"bin/wp-documentor parse tests/source --format=hookster --type=actions --relative=tests/docs > tests/docs/hookster-actions.json",
"bin/wp-documentor parse tests/source --format=hookster --type=filters --relative=tests/docs > tests/docs/hookster-filters.json",
"bin/wp-documentor parse tests/source --format=markdown --relative=tests/docs > tests/docs/hooks.md",
"bin/wp-documentor parse tests/source --format=phpdocumentor-rst --type=actions --relative=tests/docs > tests/docs/phpdocumentor-actions.rst",
"bin/wp-documentor parse tests/source --format=phpdocumentor-rst --type=filters --relative=tests/docs > tests/docs/phpdocumentor-filters.rst",
"bin/wp-documentor parse wordpress --format=markdown --relative=tests/docs --memory-limit=-1 > tests/docs/wordpress-hooks.md"
"bin/wp-documentor parse tests/source --format=hookster --type=actions --relative=tests/docs --output=tests/docs/hookster-actions.json",
"bin/wp-documentor parse tests/source --format=hookster --type=filters --relative=tests/docs --output=tests/docs/hookster-filters.json",
"bin/wp-documentor parse tests/source --format=markdown --relative=tests/docs --output=tests/docs/hooks.md",
"bin/wp-documentor parse tests/source --format=phpdocumentor-rst --type=actions --relative=tests/docs --output=tests/docs/phpdocumentor-actions.rst",
"bin/wp-documentor parse tests/source --format=phpdocumentor-rst --type=filters --relative=tests/docs --output=tests/docs/phpdocumentor-filters.rst",
"bin/wp-documentor parse wordpress --format=markdown --relative=tests/docs --memory-limit=-1 --output=tests/docs/wordpress-hooks.md"
]
},
"require-dev": {
Expand Down
16 changes: 15 additions & 1 deletion tests/docs/hookster-actions.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
},
{
"name": "test_{$from}_to_{$to}",
"summary": "Test tag with method call.",
"summary": "Test tag with var and underscores in markdown.",
"desc": "",
"since": null,
"params": [
Expand All @@ -289,6 +289,20 @@
],
"file": "tests\/source\/tests.php"
},
{
"name": "test_{$this->dummy}",
"summary": "Test tag with property fetch.",
"desc": ".",
"since": null,
"params": [
{
"name": "$test",
"type": "\\Pronamic\\WordPress\\Documentor\\TestClass",
"description": "Test object."
}
],
"file": "tests\/source\/tests.php"
},
{
"name": "test_union_types",
"summary": "Test union types.",
Expand Down

0 comments on commit ffb2ee9

Please sign in to comment.