build(docs): teach wp-hookdoc to read standard PHPDoc#1191
Open
utkarshcloudinary wants to merge 3 commits into
Open
build(docs): teach wp-hookdoc to read standard PHPDoc#1191utkarshcloudinary wants to merge 3 commits into
utkarshcloudinary wants to merge 3 commits into
Conversation
Patch wp-hookdoc so @hook docblocks can use standard, PHPStan-clean PHPDoc syntax (@param Type $name / @return Type) instead of the JSDoc/legacy brace form. The patch normalizes tags to JSDoc syntax in the beforeParse hook, so generated hook docs render correctly while the PHP source keeps valid PHPDoc. Wired via patch-package on postinstall.
JSDoc rejects leading-backslash FQCNs (\WP_Post, \Cloudinary\Sync). Normalize them to JSDoc form when converting @hook docblock types.
Fresh lockfile resolution so npm ci passes in CI: reconciles pre-existing drift in transitive deps (e.g. date-fns 4.1.0 -> 4.4.0) and includes patch-package.
Contributor
There was a problem hiding this comment.
Needed to re-generate the lock file.
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.
Relates to the PHPStan work in #1180.
When #1180 normalizes the
@hookdocblocks to standard, PHPStan-clean PHPDoc (@param Type $name/@return Type), the documentation generator breaks. The docs are built withwp-hookdoc, a JSDoc plugin that expects the type in{braces}(@param {Type} $name). With valid PHPDoc the hook pages render the type where the variable name should go, drop the type metadata, and leak the variable name into the description. This PR fixes the docs pipeline so the PHP source can keep valid PHPDoc.Approach
wp-hookdoc@0.2.0(viapatch-package) so itsbeforeParsehook normalizes standard PHPDoc tag syntax to the JSDoc syntax the parser expects, only inside@hookblocks:@param Type $name Desc(standard PHPDoc) →@param {Type} $name Desc@param $name {Type} Desc(legacy hookdoc) →@param {Type} $name Desc@return Type Desc→@return {Type} Desc{Type}form are left untouched.\WP_Post/\Cloudinary\Syncare normalized toWP_Post/Cloudinary.Syncso they no longer error during the build.patch-packageintopostinstall(patch-package && composer install) and add it as a devDependency; the committed patch lives inpatches/wp-hookdoc+0.2.0.patch.package-lock.jsonsonpm ciis in sync (reconciles pre-existing transitive drift, e.g.date-fns4.1.0 → 4.4.0, and addspatch-package).This keeps the PHP source as valid PHPDoc (PHPStan stays green) while the generated hook documentation continues to render correctly.
QA notes
npm install— confirmpatch-packageapplies the patch on postinstall (look forwp-hookdoc@0.2.0 ✔).npm ci— completes without "package.json and package-lock.json are in sync" errors.npm run build:docs— completes with noUnable to parse a tag's type expression/invalid name or invalid syntaxerrors.docs/cloudinary_dns_prefetch_types.html,docs/cloudinary_can_sync_asset.html,docs/cloudinary_context_options.html): the filter signature shows the variable name and→ {Type}return, the Parameters table lists$name, its type, and description correctly, including union (bool|WP_Error) and FQCN (WP_Post,Cloudinary.Sync) types.