Skip to content

add logic to ensure that the hooks inside of the woocommerce/src/ are parsed #29

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

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from

Conversation

piinthecloud
Copy link

This PR enhances the WooCommerce Code Reference Generator to support local development workflows by and improving the recursive file scanning to detect hooks in woocommerce/src and deeper subdirectories.

Expanded file parsing

Added woocommerce/src to parsed files: The logic in generate-hook-docs.php has been updated to know also look inside woocommerce/src to detect hooks and filters in use.

Fixed generate-hook-docs.php recursion: During testing, I detected that the getFiles() function wasn't going deep enough into the directories to appropriately retrieve all hook references. I simplified the logic on line 113 to directly merge the files from each subdirectory directly into the $files array.

Hook and filter detection: Increased from 1,732 to 2,580 hooks.

Local development

To facilitate development, I've added the run-local.sh which lets you easily set up a local server with a local copy of the docs.

Tweaks

Updated the .gitignore to ensure linked /woocommerce files never get committed.

@piinthecloud piinthecloud requested review from jorgeatorres, bacoords and a team and removed request for bacoords July 23, 2025 12:40
Copy link

@bacoords bacoords left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the local environment didn't work for me - it comes up but it doesn't have any of the actual file references. This isn't critical if you know it's working for you, but maybe we should screenshare to confirm.

Copy link
Member

@jorgeatorres jorgeatorres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @piinthecloud!

Thanks for the PR 💯. It works beautifully and I can confirm that the missing hooks are now present in the docs.

As for the local script, I left some small suggestions. Nothing's really a blocker, though. Please let me know what you think! Thanks again!

Comment on lines +56 to +59
# Copy only the directories we want for documentation
cp -r "$WOOCOMMERCE_DIR"/includes woocommerce/ 2>/dev/null || true
cp -r "$WOOCOMMERCE_DIR"/src woocommerce/ 2>/dev/null || true
cp -r "$WOOCOMMERCE_DIR"/templates woocommerce/ 2>/dev/null || true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you prefer this to the symbolic link you tried first?

If the symlink-based approach worked correctly, that'd be faster and less error prone than copying directories as we wouldn't need to keep this script in sync with paths inside the plugin. Everything could be handled from the phpcs.xml file as today.

Copy link
Author

@piinthecloud piinthecloud Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the files were symlinked, not all the files were being parsed. So the site would build, but there would large gaps of content missing, for examples Namespaces were completely empty. cp is slower, but it's the only way I could get it to build out the whole site.

Screenshot 2025-07-25 at 11 34 32

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@piinthecloud I tested the new, non-symlinked approach and it's working for me 👍

run-local.sh Outdated
Comment on lines 73 to 81
# Run PHPDocumentor directly with the local source
./vendor/bin/phpdoc run \
--template="data/templates/woocommerce" \
--sourcecode \
--defaultpackagename="WooCommerce"

# Generate hook documentation AFTER PHPDocumentor completes
echo "🔧 Generating hook documentation..."
php generate-hook-docs.php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid duplication, I'd suggest we call the ./deploy.sh script here instead.
For example:

./deploy.sh --no-download --build-only --source-version 0.0.0

This will also take care of deleting the build/ directory if needed.

Note the 0.0.0 version. deploy.sh shouldn't require --source-version when --build-only and --no-download are used but we can probably fix that later. For now the 0.0.0 does the trick.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, didn't know i could run that. That also obviates the need for lines 74-77

@jorgeatorres jorgeatorres self-requested a review July 25, 2025 16:38
@piinthecloud
Copy link
Author

@jorgeatorres any additional concerns?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants