Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 8, 2025

The docblock parser was truncating multiline descriptions when the first line didn't end with {. This affected @param descriptions in Utils\http_request() (e.g., the $data parameter lost its continuation line "or in the body for POST requests.") and would similarly affect @return, @throws, and other docblock tags.

Root cause: Parser only tracked multiline descriptions when they ended with {, ignoring other line-ending characters like commas.

Changes:

  • Set $in_param for all docblock tags (@param, @return, @throws, etc.), not just those ending with {
  • Continue appending lines until encountering another @ tag instead of checking for }
  • Add empty string guards before array access
// Before: Only tracked params ending with '{'
if ( ! empty( $ret['parameters'][ $param_name ][ $key ][2] )
    && '{' === substr( $ret['parameters'][ $param_name ][ $key ][2], -1 ) ) {
    $in_param = [ $param_name, $key ];
}

// After: Track all tags, terminate on next @ tag
if ( ! empty( $ret['parameters'][ $param_name ][ $key ][2] ) ) {
    $in_param = [ $param_name, $key ];
} else {
    $in_param = false;
}

Testing:
Verified that multiline descriptions work correctly for:

  • @param tags (original issue)
  • @return tags
  • @throws tags
  • Multiple multiline tags in the same docblock
Original prompt

This section details on the original issue you should resolve

<issue_title>Parsing issue with multiline argument description</issue_title>
<issue_description>The documentation parser fails to correctly parse a multiline argument description in the Utils\http_request() method.

See parsing bug result here: https://github.com/wp-cli/handbook/pull/476/files/d742f6da07acc8c1ce7145db037c8f9a8933c223#diff-cde919b1ce38772f91380d956b64197e339541cf3d40ffe52c3b485dd3306e0bR35

image
</issue_description>

<agent_instructions>See proposed change in #527 in case it helps</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 8, 2025 20:30
The parser now correctly handles multiline @param descriptions that end with commas or other characters (not just '{').

Changes:
- When in $in_param mode, continue parsing until we hit another @ tag
- Always set $in_param for @param tags (not just when description ends with '{')
- Remove the check for '}' as the end condition for multiline params

Co-authored-by: swissspidy <[email protected]>
Address code review feedback to prevent undefined index error when $info is empty

Co-authored-by: swissspidy <[email protected]>
@swissspidy swissspidy marked this pull request as ready for review December 8, 2025 20:42
@swissspidy swissspidy requested a review from a team as a code owner December 8, 2025 20:42
Copilot AI changed the title [WIP] Fix parsing issue with multiline argument description Fix docblock parser to handle multiline @param descriptions Dec 8, 2025
Copilot AI requested a review from swissspidy December 8, 2025 20:43
@swissspidy
Copy link
Member

@copilot I need to handle multiline @return descriptions as well

Extended the fix to handle multiline descriptions for all docblock tags
(@return, @throws, etc.), not just @param. Removed the 'param' === $param_name
check so any tag with a description can span multiple lines.

Co-authored-by: swissspidy <[email protected]>
Copy link
Contributor Author

Copilot AI commented Dec 17, 2025

@copilot I need to handle multiline @return descriptions as well

Done in 9ec518a. The fix now handles multiline descriptions for all docblock tags (@return, @throws, etc.), not just @param.

Copilot AI changed the title Fix docblock parser to handle multiline @param descriptions Fix docblock parser to handle multiline descriptions for all tags Dec 17, 2025
@swissspidy swissspidy merged commit 1c594b8 into main Dec 17, 2025
6 checks passed
@swissspidy swissspidy deleted the copilot/fix-multiline-argument-parsing branch December 17, 2025 20:54
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.

Parsing issue with multiline argument description

2 participants