Add support for dynamic hook names with concatenation#20
Merged
akirk merged 2 commits intoakirk:mainfrom Sep 30, 2025
Merged
Conversation
Dynamic hooks (e.g., 'prefix_' . $var) are now properly documented:
- Hook name/slug uses {$var} syntax (e.g., activitypub_inbox_{$type})
- Example code uses wildcard * (e.g., activitypub_inbox_*)
Implementation:
- Detects concatenation operator (.) after hook string
- Extracts variable names and appends as {$var}
- Added extract_dynamic_parts() helper to extract concatenated variables
- Added get_hook_name_for_example() helper to replace {$var} with *
- Works with both 'prefixed' and 'default' example styles
Tests:
- Added test_dynamic_hook_extraction() to verify hook name format
- Added test_dynamic_hook_documentation_uses_wildcard() to verify example format
- All 39 tests passing
Owner
|
Thank you! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
{$var}syntax for clarity*for practical usageProblem
Dynamic hooks like
do_action( 'activitypub_inbox_' . $type, $data, $user_id, $activity )were being extracted as justactivitypub_inbox_(with trailing underscore), making the documentation unclear about the dynamic nature of the hook.Current output:
activitypub_inbox_add_action( 'activitypub_inbox_', ... )Solution
The tool now detects concatenation patterns and properly documents dynamic hooks:
activitypub_inbox_{$type}(shows the variable placeholder)add_action( 'activitypub_inbox_*', ... )(uses wildcard for practical usage)Implementation Details
extract_dynamic_parts()method to detect and extract concatenated variablesget_hook_name_for_example()method to convert{$var}to*in examples.) after hook string{$variable}Test Plan
test_dynamic_hook_extraction()to verify hook name includes{$var}test_dynamic_hook_documentation_uses_wildcard()to verify examples use*Example Output
For code like:
Generated documentation:
activitypub_inbox_{$type}