Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 11, 2026

When a command's PHPDoc contains multiple description paragraphs separated by blank lines, only the first line appeared in the DESCRIPTION section. Additional paragraphs incorrectly appeared after ALIAS or SYNOPSIS sections.

Example of the issue:

/**
 * Clear the Cloudflare cache. Default: purge everything.
 *
 * API documentation: https://developers.cloudflare.com/api/resources/cache/
 *
 * ## OPTIONS
 * ...
 * @alias clear_cloudflare_cache
 */

Previously rendered as:

DESCRIPTION
  Clear the Cloudflare cache. Default: purge everything.

SYNOPSIS
  wp command <arg>

ALIAS
  clear_cloudflare_cache

  API documentation: https://developers.cloudflare.com/api/resources/cache/  ← Wrong location

OPTIONS
  ...

Changes

  • Split longdesc processing: Extract description paragraphs (content before first ## section header) separately from OPTIONS/EXAMPLES sections
  • Include descriptions in template: Append description paragraphs to shortdesc binding so they render in DESCRIPTION section
  • Optimize reference link parsing: Call parse_reference_links() once in show_help() and pass processed result to get_initial_markdown()
  • Add helper methods:
    • extract_before_sections() - Common logic for extracting content before ## headers
    • get_longdesc_description() - Extract description paragraphs only
    • get_longdesc_sections() - Extract OPTIONS/EXAMPLES sections only

Now correctly renders as:

DESCRIPTION
  Clear the Cloudflare cache. Default: purge everything.

  API documentation: https://developers.cloudflare.com/api/resources/cache/  ← Correct location

SYNOPSIS
  wp command <arg>

ALIAS
  clear_cloudflare_cache

OPTIONS
  ...

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • example.com
    • Triggering command: /usr/bin/php php vendor/bin/phpunit --color=always --bootstrap ./vendor/wp-cli/wp-cli-tests/tests/bootstrap.php et_longdesc requests/src/Exception/Http/Status429.php ep php/WP_CLI/Iterawhich (dns block)
    • Triggering command: /usr/bin/php php vendor/bin/phpunit --color=always --bootstrap ./vendor/wp-cli/wp-cli-tests/tests/bootstrap.php tup_errors=0&#39; &#39;--n grep tnet/tools/git tion/Http/Status505.php&#39; t ndor/bin/git php /usr�� &#39;-d short_open_tag=Off&#39; &#39;-d error_reporting=E_ALL&#39; &#39;-n&#39; &#39;-l&#39; &#39;./php/WP_CLI/Fetchers/Base.php&#39; grep /usr/sbin/ls tter.php&#39; requests/src/Exc/home/REDACTED/work/wp-cli/wp-cli/vendor/bin/run-phpcs-tests eption/Http/Status413.php ls (dns block)
  • nosuchhost_asdf_asdf_asdf.com
    • Triggering command: /usr/bin/php php vendor/bin/phpunit --color=always --bootstrap ./vendor/wp-cli/wp-cli-tests/tests/bootstrap.php et_longdesc requests/src/Exception/Http/Status429.php ep php/WP_CLI/Iterawhich (dns block)
    • Triggering command: /usr/bin/php php vendor/bin/phpunit --color=always --bootstrap ./vendor/wp-cli/wp-cli-tests/tests/bootstrap.php tup_errors=0&#39; &#39;--n grep tnet/tools/git tion/Http/Status505.php&#39; t ndor/bin/git php /usr�� &#39;-d short_open_tag=Off&#39; &#39;-d error_reporting=E_ALL&#39; &#39;-n&#39; &#39;-l&#39; &#39;./php/WP_CLI/Fetchers/Base.php&#39; grep /usr/sbin/ls tter.php&#39; requests/src/Exc/home/REDACTED/work/wp-cli/wp-cli/vendor/bin/run-phpcs-tests eption/Http/Status413.php ls (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Portions of a multi-line command description are located in a misleading place when viewed via wp help</issue_title>
<issue_description>## Bug Report

Describe the current, buggy behavior

Here is a sample PHP DocBlock for a command I created called clear-cloudflare-cache:

	/**
	 * Clear the Cloudflare cache. Default: purge everything. Uses $CLOUDFLARE_API_KEY environment variable.
	 *
	 * API documentation: https://developers.cloudflare.com/api/resources/cache/
	 *
	 * ## OPTIONS
	 *
	 * <zone_id>
	 * : Cloudflare zone ID.
	 *
	 * ## EXAMPLES
	 *
	 *     # Clear the cloudflare cache for a domain.
	 *     wp bzmn clear-cloudflare-cache 12345
	 *     Success: The Cloudflare cache has been cleared.
	 *
	 * @subcommand clear-cloudflare-cache
	 * @alias clear_cloudflare_cache
	 */

As you can see, the command description falls on multiple lines:

Clear the Cloudflare cache. Default: purge everything. Uses $CLOUDFLARE_API_KEY environment variable.

API documentation: https://developers.cloudflare.com/api/resources/cache/

When I view the help documentation via wp help bzmn clear-cloudflare-cache, here is what it looks like:

NAME

  wp bzmn clear-cloudflare-cache

DESCRIPTION

  Clear the Cloudflare cache. Default: purge everything. Uses
  $CLOUDFLARE_API_KEY environment variable.

SYNOPSIS

  wp bzmn clear-cloudflare-cache <zone_id>

ALIAS

  clear_cloudflare_cache

  API documentation: https://developers.cloudflare.com/api/resources/cache/

OPTIONS
...

As you can see, the second line beginning with "API documentation..." is displayed in the ALIAS section. This is very misleading and not desirable.

If I remove the @alias definition, here is what the output of wp help bzmn clear-cloudflare-cache looks like:

NAME

  wp bzmn clear-cloudflare-cache

DESCRIPTION

  Clear the Cloudflare cache. Default: purge everything. Uses
  $CLOUDFLARE_API_KEY environment variable.

SYNOPSIS

  wp bzmn clear-cloudflare-cache <zone_id>

  API documentation: https://developers.cloudflare.com/api/resources/cache/

OPTIONS

  <zone_id>
    Cloudflare zone ID.

EXAMPLES
...

The second line beginning with "API documentation..." is now in the SYNOPSIS section. This to me is still not right. What I would like to see is the "API documentation..." line under the first line of the DESCRIPTION section like so:

NAME

  wp bzmn clear-cloudflare-cache

DESCRIPTION

  Clear the Cloudflare cache. Default: purge everything. Uses
  $CLOUDFLARE_API_KEY environment variable.

  API documentation: https://developers.cloudflare.com/api/resources/cache/

SYNOPSIS

  wp bzmn clear-cloudflare-cache <zone_id>

ALIAS

  clear_cloudflare_cache

OPTIONS
...

Finally, here's the output of "wp cli info":

OS:     Darwin 24.6.0 Darwin Kernel Version 24.6.0: Wed Nov  5 21:33:59 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T8112 x86_64
Shell:  /bin/zsh
PHP binary:     /usr/local/Cellar/php@8.3/8.3.23/bin/php
PHP version:    8.3.23
php.ini used:   /usr/local/etc/php/8.3/php.ini
MySQL binary:   /Users/Shared/DBngin/mysql/8.0.27/bin/mysql
MySQL version:  mysql  Ver 8.0.27 for macos11 on x86_64 (MySQL Community Server - GPL)
SQL modes:      ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       phar:///usr/local/bin/wp
WP-CLI packages dir:    /Users/saul/.wp-cli/packages/
WP-CLI cache dir:       /Users/saul/.wp-cli/cache
WP-CLI global config:   /Users/saul/.wp-cli/config.yml
WP-CLI project config:
WP-CLI version: 2.12.0
```</issue_description>

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

<comments>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 11, 2026 19:42
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
…de duplication

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix misleading placement of multi-line command description in wp help Fix multi-paragraph command descriptions appearing after ALIAS/SYNOPSIS in help output Jan 11, 2026
Copilot AI requested a review from swissspidy January 11, 2026 19:50
@codecov

This comment was marked as resolved.

This comment was marked as resolved.

swissspidy and others added 2 commits January 11, 2026 21:27
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@swissspidy
Copy link
Member

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively resolves the issue of multi-paragraph command descriptions being misplaced in the help output. The approach of splitting the long description into a description part and a sections part is sound, and the refactoring into helper methods improves code clarity. The addition of feature tests is also a great way to ensure the fix is working as expected. I have one suggestion to improve the implementation of the new helper functions for better robustness and to avoid potential formatting issues.

@swissspidy swissspidy marked this pull request as ready for review January 11, 2026 20:53
@swissspidy swissspidy requested a review from a team as a code owner January 11, 2026 20:53
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.

Portions of a multi-line command description are located in a misleading place when viewed via wp help

2 participants