-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a script to generate a list of hooks that defined or used in GLA #1573
Conversation
It will be placed in src/Hooks/README.md.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @ianlin for adding this, I have tested locally and I see that is creating the hooks docs correctly ✅ It would be perfect if we have a description for each hook (similar to the tracking page) but I think in this case, it is not possible.
Just a question related to the docs generator: should we run the hooks docs generator everytime that we add a new hook? or can it be automatize?
bin/HooksDocsGenerator.php
Outdated
$output = "# Hooks Reference\n\n"; | ||
$output .= "A list of hooks, i.e `actions` and `filters`, that are defined or used in this project.\n\n"; | ||
|
||
foreach ( $hook_list as $heading => $hooks ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💅
$heading could be removed as it is not used.
Suggested change: foreach ( $hook_list as $hooks ) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, updated in b7a2dfc.
Thanks for the review @jorgemd24. I also updated the README.md file to include hooks documentation infor.
Indeed, it would be very helpful but currently it's not possible unless we write down the hooks we used using PHPDoc, and see if we can extend PHPDoc for having the custom tags in order to auto generate it.
I think for now we need to run the script every time someone adds a new hook, AFAIK the tracking doc needs to be run manually as well (correct me if I'm wrong). Here's a possible automation approach:
In this PR we have the first version of GLA hooks documentation, I have created a follow-up issue #1576 for enhancing the GLA hooks documentation process. |
@ianlin Thanks for opening the follow-up issue!
Yeah that could work however I think we could remove |
@jorgemd24 |
Thanks, @ianlin for fixing this. I see that the rest of the hooks are now included. It took me a while to see why it was not included in all the hooks but looking at the code again I see that in the original codebase the following part is trying to avoid duplications:
As far as I understand, I think this problem is less visible in the original codebase because the script is including the subpaths:
I compared some hooks from the WC plugin and https://woocommerce.github.io/code-reference/hooks/hooks.html and I saw that some hooks are not included, for example:
Should this be reported to the WC team? At the moment we do not have any hooks in the file but this could change in the future. |
Hey @jorgemd24, sorry for not explaining the reason behind. You're right, the
However, it won't work on the structure like this:
The reason is,
Yeah, I think it's a good idea we report them this potential problem, I will create an issue on their repo then.
Not sure what do you mean about this? |
Thanks!
Sorry! I think I skipped part of the message 😄 . What I meant was that we are not processing the Similar like it is done here: https://github.com/woocommerce/code-reference/blob/331da252e94b3e6529d2d42f6636200ca30dcfe4/generate-hook-docs.php#L45 |
Ah, thanks for catching this, added in 3da1be1. Just created an issue woocommerce/code-reference#20 for the WC folks. |
Thanks, @ianlin, I have added some hooks on |
Changes proposed in this Pull Request:
This PR adds a script to generate a list of hooks (actions or filters) that is defined or used in this project. The output file is generated in
src/Hooks/README.md
.The majority of the codes were copied fro WooCommerce Code Reference repo, and they're published in https://woocommerce.github.io/code-reference/hooks/hooks.html.
Since the hooks in GLA project are mostly used internally so generated as a markdown file would be good enough.
Detailed test instructions:
php bin/HooksDocsGenerator.php
src/Hooks/README.md
Changelog entry