Skip to content

Commit

Permalink
Merge pull request #10 from LuigiPulcini/main
Browse files Browse the repository at this point in the history
Add support for `prefix` option
  • Loading branch information
remcotolsma authored Jan 27, 2022
2 parents 8478326 + bc88207 commit 70f8543
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bin/wp-documentor
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ $application->register( 'parse' )
null
)
->addOption( 'relative', null, InputOption::VALUE_REQUIRED, 'Relative to directory.', null )
->addOption( 'prefix', null, InputOption::VALUE_REQUIRED, 'Comma-separated list of prefixes hooks must match.', 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 )
->addOption(
Expand Down Expand Up @@ -125,6 +126,10 @@ $application->register( 'parse' )

$documentor->relative = ( null === $relative ) ? $source : $relative;

$prefix = $input->getOption( 'prefix' );

$documentor->prefix = ( null === $prefix ) ? null : $prefix;

/**
* Output.
*
Expand Down
9 changes: 9 additions & 0 deletions src/Documentor.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ function( Node $node ) {
);
}

if ( ! is_null( $this->prefix ) ) {
$pattern = sprintf( '/^(%s)/', implode( '|', explode( ',', $this->prefix ) ) );
preg_match( $pattern, $tag_name, $matches );

if ( empty( $matches ) ) {
continue;
}
}

$tag = new Tag( $tag_name, $tag_arg );

$doc_comment = $statement->getDocComment();
Expand Down

0 comments on commit 70f8543

Please sign in to comment.