Skip to content

Commit

Permalink
Merge branch 'release/1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Jan 27, 2022
2 parents 70f8543 + 5a702f0 commit 44b4d32
Show file tree
Hide file tree
Showing 33 changed files with 6,464 additions and 1,641 deletions.
16 changes: 12 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.1] 2021-06-10
## [1.2.0] - 2022-01-27
### Fixed
- List of arguments is empty when `apply_filters` is returned instead of assigned to variable (props [@LuigiPulcini](https://github.com/LuigiPulcini)). ( [#11](https://github.com/pronamic/wp-documentor/issues/11) )

### Added
- Added `--prefix` option (props [@LuigiPulcini](https://github.com/LuigiPulcini)). ( [#10](https://github.com/pronamic/wp-documentor/pull/10) )

## [1.1.1] - 2021-06-10
### Changed
- Progress bar now shows the file being processed.

Expand All @@ -23,7 +30,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- First Release.

[Unreleased]: https://github.com/pronamic/wp-documentor/compare/1.1.1...HEAD
[1.1.1]: https://github.com/pronamic/wp-documentor/releases/tag/1.2.0
[1.1.0]: https://github.com/pronamic/wp-documentor/releases/tag/1.1.0
[Unreleased]: https://github.com/pronamic/wp-documentor/compare/1.2.0...HEAD
[1.2.0]: https://github.com/pronamic/wp-documentor/compare/1.1.1...1.2.0
[1.1.1]: https://github.com/pronamic/wp-documentor/compare/1.1.0...1.1.1
[1.1.0]: https://github.com/pronamic/wp-documentor/compare/1.0.0...1.1.0
[1.0.0]: https://github.com/pronamic/wp-documentor/releases/tag/1.0.0
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ If the search directory contains a `.gitignore` file, you can reuse those rules

Example: `--ignore-vcs-ignored`

### `--prefix=PREFIX`

Only parse hooks starting with the specified prefixes.

Example: `--prefix=my_theme --prefix=my_plugin`

### Examples

```
Expand Down
17 changes: 13 additions & 4 deletions bin/wp-documentor
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ $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(
'prefix',
null,
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
'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 @@ -126,9 +132,12 @@ $application->register( 'parse' )

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

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

$documentor->prefix = ( null === $prefix ) ? null : $prefix;
/**
* Prefixes.
*
* @link https://github.com/pronamic/wp-documentor/pull/10
*/
$documentor->prefixes = (array) $input->getOption( 'prefix' );

/**
* Output.
Expand Down
24 changes: 16 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,21 @@
"bin/wp-documentor"
],
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"roots/wordpress-core-installer": true,
"bamarni/composer-bin-plugin": true
}
},
"require": {
"phpdocumentor/reflection": "^4.0",
"phpdocumentor/reflection-docblock": "^5.2",
"symfony/console": "^5.2",
"symfony/filesystem": "^5.2",
"symfony/finder": "^5.2"
},
"phpdocumentor/reflection": "^4.0",
"phpdocumentor/reflection-docblock": "^5.2",
"symfony/console": "^5.2",
"symfony/filesystem": "^5.2",
"symfony/finder": "^5.2",
"symfony/polyfill-php80": "^1.24"
},
"scripts": {
"post-install-cmd": "echo 'Optionally run: composer bin all install'",
"post-update-cmd": "echo 'Optionally run: composer bin all update'",
Expand All @@ -45,7 +51,9 @@
"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"
"bin/wp-documentor parse wordpress --format=markdown --relative=tests/docs --memory-limit=-1 --output=tests/docs/wordpress-hooks.md",
"bin/wp-documentor parse tests/issue-10 --format=markdown --output=tests/issue-10/hooks.md --prefix=prefix_1 --prefix=prefix_2",
"bin/wp-documentor parse tests/issue-11 --format=markdown --output=tests/issue-11/hooks.md"
]
},
"require-dev": {
Expand Down
18 changes: 9 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Argument.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Argument
*
* @author Pronamic <[email protected]>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Documentor
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Changelog.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Changelog
*
* @author Pronamic <[email protected]>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Documentor
*/
Expand Down
2 changes: 1 addition & 1 deletion src/ChangelogFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Changelog Factory
*
* @author Pronamic <[email protected]>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Documentor
*/
Expand Down
2 changes: 1 addition & 1 deletion src/DefaultPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Default Printer
*
* @author Pronamic <[email protected]>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Documentor
*/
Expand Down
47 changes: 35 additions & 12 deletions src/Documentor.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Documentor
*
* @author Pronamic <[email protected]>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Documentor
*/
Expand Down Expand Up @@ -32,11 +32,19 @@ class Documentor {
*/
private $hooks;

/**
* Prefixes.
*
* @var string[]
*/
public $prefixes;

/**
* Construct documentor.
*/
public function __construct() {
$this->hooks = array();
$this->hooks = array();
$this->prefixes = array();
}

/**
Expand Down Expand Up @@ -91,6 +99,26 @@ public function relative( \SplFileInfo $file ) {
return \trim( $filesystem->makePathRelative( $end->getRealPath(), $start->getRealPath() ), '/' );
}

/**
* Check if the specified tag name should be parsed.
*
* @param string $name Tag name.
* @return bool True if should parse, false otherwise.
*/
private function should_parse_tag( $name ) {
if ( 0 === \count( $this->prefixes ) ) {
return true;
}

foreach ( $this->prefixes as $prefix ) {
if ( \str_starts_with( $name, $prefix ) ) {
return true;
}
}

return false;
}

/**
* Parse.
*
Expand Down Expand Up @@ -173,24 +201,19 @@ 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;
}
if ( ! $this->should_parse_tag( $tag_name ) ) {
continue;
}

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

$doc_comment = $statement->getDocComment();

if ( null === $doc_comment ) {
$previous = $statement->getAttribute( 'previous' );
$parent = $statement->getAttribute( 'parent' );

if ( null !== $previous ) {
$doc_comment = $previous->getDocComment();
if ( null !== $parent ) {
$doc_comment = $parent->getDocComment();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Hook
*
* @author Pronamic <[email protected]>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Documentor
*/
Expand Down
2 changes: 1 addition & 1 deletion src/HooksterPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Hookster Printer
*
* @author Pronamic <[email protected]>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Documentor
*/
Expand Down
2 changes: 1 addition & 1 deletion src/NamespaceResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Namespace Resolver
*
* @author Pronamic <[email protected]>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Documentor
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Since.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Since
*
* @author Pronamic <[email protected]>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Documentor
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Tag
*
* @author Pronamic <[email protected]>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Documentor
*/
Expand Down
2 changes: 1 addition & 1 deletion src/TagPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Tag Printer
*
* @author Pronamic <[email protected]>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Documentor
*/
Expand Down
2 changes: 1 addition & 1 deletion src/TemplatePrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Template Printer
*
* @author Pronamic <[email protected]>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Documentor
*/
Expand Down
2 changes: 1 addition & 1 deletion templates/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @link https://github.com/themeblvd/hookster
* @author Pronamic <[email protected]>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Documentor
*/
Expand Down
4 changes: 2 additions & 2 deletions templates/markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @link https://guides.github.com/features/mastering-markdown/
* @author Pronamic <[email protected]>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Documentor
*/
Expand Down Expand Up @@ -70,7 +70,7 @@
printf(
'<em>Generated by <a href="%s">Pronamic WordPress Documentor</a> <code>%s</code></em>',
'https://github.com/pronamic/wp-documentor',
'1.1.1'
'1.2.0'
);

echo '<p>';
Expand Down
2 changes: 1 addition & 1 deletion templates/parts/markdown-hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Markdown Hook Template.
*
* @author Pronamic <[email protected]>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Documentor
*/
Expand Down
Loading

0 comments on commit 44b4d32

Please sign in to comment.