Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-134200: Add adaptive global alignment for help text #134308

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 7 commits into
base: main
Choose a base branch
Loading
from

Conversation

lnperry
Copy link

@lnperry lnperry commented May 20, 2025

Refactors HelpFormatter to improve help text readability and consistency,
addressing issues where argument string lengths varied widely.

Previously, a single very long option could push all help text excessively
to the right, or groups of only short options might not align optimally.

Key changes:

  1. A global help alignment column is now calculated by finding the display
    endpoint of the longest "reasonable" argument invocation string across
    all sections, adding a 2-space padding.

    • A "reasonable" argument is one whose own invocation string (plus
      indent and minimal padding) does not exceed the overall maximum help
      position (derived from max_help_position and terminal width, e.g., 24).
    • This calculated alignment column is itself capped by this overall
      maximum help position.
  2. Help text for arguments is formatted against this single global column:

    • Shorter arguments are padded so their help text (and any wrapped lines)
      begins at this alignment column.
    • Argument invocations too long to fit this same-line alignment will
      have their help text start on the next line, also indented to this
      alignment column.

This ensures:

  • Consistent alignment of help descriptions across all sections.
  • Outlier long options no longer distort the layout for other arguments.
  • Sets of only short options are aligned compactly based on their local
    longest member, rather than being forced to an unnecessarily wide default.
  • The option defining the alignment has exactly two spaces before its help.

@python-cla-bot
Copy link

python-cla-bot bot commented May 20, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented May 20, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented May 20, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented May 21, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented May 21, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented May 21, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented May 21, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented May 21, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

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

Successfully merging this pull request may close these issues.

1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.