-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1a91a84
Showing
8 changed files
with
1,002 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea/ | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
<h1 align="center">WP Doc Generator</h1> | ||
|
||
WordPress Doc Generator is a tool to automatically extract data about the __actions__ and __filters__ of your WordPress theme or plugin. | ||
|
||
__Shortcodes__ support will come soon. | ||
|
||
|
||
## Table of contents | ||
|
||
- [Getting Started](#getting-started) | ||
- [Command Line Usage](#command-line-usage) | ||
- [Notes](#notes) | ||
- [Alternatives](#alternatives) | ||
- [Links](#links) | ||
|
||
## Getting Started | ||
|
||
### Installation | ||
|
||
Install it with composer | ||
|
||
``` | ||
composer require dudo1985/wp-doc-generator --dev | ||
``` | ||
|
||
## Command Line Usage | ||
|
||
First paramater is the input directorty, second is the output file, e.g. | ||
|
||
#### `vendor/bin/wp-doc-gen . hooks.md` | ||
|
||
This will parse all the files in the current directory (.) and write a file called hooks.md | ||
|
||
### Optional params | ||
#### `--exclude` or `-e` | ||
|
||
Exclude the specified folders, comma separated, e.g. | ||
#### `vendor/bin/wp-doc-gen . hooks.md --exclude vendor,node_modules` | ||
|
||
Another example, if you're launching the script from another dir: | ||
#### `vendor bin/wp-doc-gen.php ../my-plugin/ docs/hooks.md --exclude vendor,node_modules --prefix yasr` | ||
|
||
There is no need to include the full paths of the excluded dirs, it is automatically ../my-plugin/vendor and | ||
../my-plugin/node_modules | ||
|
||
#### `--prefix` or `-p` | ||
Only parse hooks starting with the specified prefixes. | ||
|
||
#### `vendor/bin/wp-doc-gen . hooks.md --exclude vendor,node_modules --prefix=yasr` | ||
|
||
## Notes | ||
To make the parser work fine, the comment must be a valid phpDocBlock, e.g. | ||
|
||
> | ||
> ``` | ||
> /** | ||
> * Use this action to add tabs inside shortcode creator for tinymce | ||
> */ | ||
> do_action('yasr_add_tabs_on_tinypopupform'); | ||
> ``` | ||
> | ||
will generate this code | ||
> | ||
>### `do_action('yasr_add_tabs_on_tinypopupform')` | ||
>Source: [../yet-another-stars-rating/admin/editor/YasrEditorHooks.php, line 219](../yet-another-stars-rating/admin/editor//YasrEditorHooks.php:219) | ||
> | ||
>*Use this action to add tabs inside shortcode creator for tinymce* | ||
> | ||
or, another example with tags | ||
> | ||
> ``` | ||
> /** | ||
> * Use this action to add content inside shortcode creator | ||
> * | ||
> * @param int $n_multi_set | ||
> * @param string $multi_set the multiset name | ||
> */ | ||
> do_action('yasr_add_content_on_tinypopupform', $n_multi_set, $multi_set); | ||
>``` | ||
will generate this code with table | ||
> ### `do_action('yasr_add_content_on_tinypopupform')` | ||
> | ||
> Source: [../yet-another-stars-rating/admin/editor/YasrEditorHooks.php, line 235](../yet-another-stars-rating/admin/editor/YasrEditorHooks.php:235) | ||
> | ||
> *Use this action to add content inside shortcode creator* | ||
> ``` | ||
> | ||
> | Argument | Type | Description | | ||
> |--------------|--------|-------------------| | ||
> | $n_multi_set | int | | | ||
> | $multi_set | string | the multiset name | | ||
> ``` | ||
But, if you use the type *after* the argument, e.g. | ||
> ``` | ||
> /** | ||
> * Use this action to add content inside shortcode creator | ||
> * | ||
> * @param $n_multi_set int | ||
> * @param $multi_set string the multiset name | ||
> */ | ||
> do_action('yasr_add_content_on_tinypopupform', $n_multi_set, $multi_set); | ||
> ``` | ||
> | ||
this will insert the type (*int* and *string* in this example) inside the "Description" column: | ||
> ### `do_action('yasr_add_content_on_tinypopupform')` | ||
> Source: [../yet-another-stars-rating/admin/editor//YasrEditorHooks.php, line 234](../yet-another-stars-rating/admin/editor//YasrEditorHooks.php:234) | ||
> | ||
> *Use this action to add content inside shortcode creator* | ||
> ``` | ||
> | Argument | Type | Description | | ||
> |--------------|------|--------------------------| | ||
> | $n_multi_set | | int | | ||
> | $multi_set | | string the multiset name | | ||
> ``` | ||
> | ||
## Alternatives | ||
Here is a list of alternatives that I found. However, none of these satisfied my needs | ||
- [WP Documentor](https://github.com/pronamic/wp-documentor/) by [Pronamic](https://github.com/pronamic) | ||
| This is the project that I used for a while, but I needed something to best fit my needs. The following list comes | ||
from their readme | ||
- [WP Parser](https://github.com/WordPress/phpdoc-parser) by [WordPress](https://github.com/WordPress) | ||
- [Hookster](https://github.com/themeblvd/hookster) by [Theme Blvd](https://github.com/themeblvd) | ||
- [WordPress HookDoc](https://github.com/matzeeable/wp-hookdoc) by [Matthias Günter](https://github.com/matzeeable) | ||
- [GitHub Actions for WordPress](https://github.com/10up/actions-wordpress/blob/stable/hookdocs-workflow.md) by [10up](https://github.com/10up) | ||
- [Yoast Parser](https://github.com/Yoast/code-documentation-extractor) by [Yoast](https://github.com/Yoast) | ||
- [WooCommerce Code Reference Generator](https://github.com/woocommerce/code-reference) by [WooCommerce](https://github.com/woocommerce) | ||
- [WordPress Hooks Reference](https://github.com/johnbillion/wp-hooks) by [John Blackbourn](https://github.com/johnbillion) / [Human Made](https://github.com/humanmade) | ||
- [wp-hooks-generator](https://github.com/johnbillion/wp-hooks-generator) by [John Blackbourn](https://github.com/johnbillion) / [Human Made](https://github.com/humanmade) | ||
## Links | ||
- https://developer.wordpress.org/plugins/hooks/ | ||
- https://developer.wordpress.org/plugins/hooks/actions/ | ||
- https://developer.wordpress.org/reference/functions/do_action/ | ||
- https://developer.wordpress.org/reference/functions/add_action/ | ||
- https://developer.wordpress.org/plugins/hooks/filters/ | ||
- https://developer.wordpress.org/reference/functions/apply_filters/ | ||
- https://developer.wordpress.org/reference/functions/add_filter/ | ||
- https://developer.wordpress.org/reference/hooks/ | ||
- https://www.phpdoc.org/ | ||
- https://github.com/phpdocumentor/phpdocumentor | ||
- https://symfony.com/doc/current/console.html | ||
- https://symfony.com/doc/current/components/finder.html | ||
- https://developer.wordpress.org/cli/commands/i18n/make-pot/ | ||
- https://developer.wordpress.org/cli/commands/i18n/make-json/ | ||
- https://github.com/pronamic/deployer/blob/master/bin/pronamic-deployer | ||
- https://gitlab.com/pronamic/wp-updates/-/blob/master/index.php | ||
- https://github.com/wp-pay/core/issues/45 | ||
- https://github.com/phpDocumentor/phpDocumentor/issues/2865 | ||
- https://github.com/themeblvd/hookster |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Dudo1985\WPDocGen; | ||
|
||
//PHP 8 is required | ||
if (version_compare(PHP_VERSION, '8.0.0') < 0) { | ||
echo "ERROR: PHP 8 is required to run WPDocGen, version ". PHP_VERSION. " is installed\n"; | ||
exit(1); | ||
} | ||
|
||
require 'vendor/autoload.php'; | ||
|
||
$finder = new WPDocGen(); | ||
$finder->init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "dudo1985/wpdocgen", | ||
"description": "Documentation Generator for WordPress.", | ||
"keywords": ["documentation", "hooks", "phpdoc", "wordpress", "markdown"], | ||
"license": "GPL-2.0-or-later", | ||
"authors": [ | ||
{ | ||
"name": "Dario Curvino", | ||
"email": "[email protected]", | ||
"homepage": "https://dariocurvino.it" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"Dudo1985\\WPDocGen\\": "src" | ||
} | ||
}, | ||
"bin": [ | ||
"bin/wpdocgen.php" | ||
], | ||
"require": { | ||
"php": ">=8.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
|
||
### `do_action('yasr_add_tabs_on_tinypopupform')` | ||
|
||
Source: [../yet-another-stars-rating/admin/editor//YasrEditorHooks.php, line 218](../yet-another-stars-rating/admin/editor//YasrEditorHooks.php:218) | ||
|
||
*Use this action to add tabs inside shortcode creator for tinymce* | ||
|
||
___ | ||
### `do_action('yasr_add_content_on_tinypopupform')` | ||
|
||
Source: [../yet-another-stars-rating/admin/editor//YasrEditorHooks.php, line 234](../yet-another-stars-rating/admin/editor//YasrEditorHooks.php:234) | ||
|
||
*Use this action to add content inside shortcode creator* | ||
|
||
| Argument | Type | Description | | ||
| --- | --- | --- | | ||
| $n_multi_set | | int | | ||
| $multi_set | | string the multiset name | | ||
___ | ||
|
||
### `do_action('yasr_metabox_below_editor_add_tab')` | ||
|
||
Source: [../yet-another-stars-rating/admin/editor//YasrMetaboxBelowEditor.php, line 60](../yet-another-stars-rating/admin/editor//YasrMetaboxBelowEditor.php:60) | ||
|
||
*Use this hook to add new tabs into the metabox below the editor* | ||
|
||
___ | ||
### `do_action('yasr_metabox_below_editor_content')` | ||
|
||
Source: [../yet-another-stars-rating/admin/editor//YasrMetaboxBelowEditor.php, line 66](../yet-another-stars-rating/admin/editor//YasrMetaboxBelowEditor.php:66) | ||
___ | ||
### `do_action('yasr_add_content_multiset_tab_top')` | ||
|
||
Source: [../yet-another-stars-rating/admin/editor//YasrMetaboxBelowEditor.php, line 205](../yet-another-stars-rating/admin/editor//YasrMetaboxBelowEditor.php:205) | ||
|
||
*Hook here to add new content at the beginning of the div* | ||
|
||
| Argument | Type | Description | | ||
| --- | --- | --- | | ||
| $post_id | | int | | ||
| $set_id | | int | | ||
___ | ||
### `do_action('yasr_add_content_multiset_tab_pro')` | ||
|
||
Source: [../yet-another-stars-rating/admin/editor//YasrMetaboxBelowEditor.php, line 288](../yet-another-stars-rating/admin/editor//YasrMetaboxBelowEditor.php:288) | ||
|
||
*Hook here to add new content* | ||
|
||
| Argument | Type | Description | | ||
| --- | --- | --- | | ||
| $post_id | | int | | ||
| $set_id | | int | | ||
___ | ||
|
||
### `do_action('yasr_on_save_post')` | ||
|
||
Source: [../yet-another-stars-rating/admin/editor//YasrOnSavePost.php, line 61](../yet-another-stars-rating/admin/editor//YasrOnSavePost.php:61) | ||
|
||
*Hook here to add actions when YASR save data on save_post* | ||
|
||
| Argument | Type | Description | | ||
| --- | --- | --- | | ||
| $post_id | | int | | ||
___ | ||
### `do_action('yasr_action_on_overall_rating')` | ||
|
||
Source: [../yet-another-stars-rating/admin/editor//YasrOnSavePost.php, line 106](../yet-another-stars-rating/admin/editor//YasrOnSavePost.php:106) | ||
|
||
*Do action before overall rating is saved, works only in classic editor* | ||
|
||
| Argument | Type | Description | | ||
| --- | --- | --- | | ||
| $post_id | | int | | ||
| $rating | | float | | ||
___ | ||
|
||
### `do_action('yasr_add_content_bottom_topright_metabox')` | ||
|
||
Source: [../yet-another-stars-rating/admin/editor//yasr-metabox-top-right.php, line 121](../yet-another-stars-rating/admin/editor//yasr-metabox-top-right.php:121) | ||
|
||
*Hook here to add content at the bottom of the metabox* | ||
|
||
| Argument | Type | Description | | ||
| --- | --- | --- | | ||
| $post_id | | int | | ||
___ |
Oops, something went wrong.