-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
gh-90300: Reformat the Python CLI help output #93415
Conversation
* All lines are now shorter than 80 columns * All wrapped lines use the same identation * Remove empty lines between -X options * Output only one empty line between sections in --help-all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind showing us the new output of python --help-all for comparison?
--help-all : print complete help information and exit\n\ | ||
--help-env: print help about Python environment variables and exit\n\ | ||
--help-xoptions: print help about implementation-specific -X options and exit\n\ | ||
--help-all: print complete help information and exit\n\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous spacing was following the style of spacing for short options (see lines just above)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it was not. All colons were at the same column, except for long option --check-hash-based-pycs
, in which case the colon was in the first available column. And the same pattern was used for earlier environment variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well it was my intent when I added them! Maybe you disagree on the result 🙂
When I say «following», I meant that all short options have colons at the same column, check-hash-based-pycs is special and uses a new line (with the help text aligned to the help texts for short options), and this new group of long options has colons at the same column (but not the same at the short options, that doesn’t work).
Old output:
New output:
|
Would you prefer the following output?
|
Added the example of the old output and collapse output in the comments above. |
Alternate proposal with fewer changes to the -X options and envvars sections:
|
I like the output @serhiy-storchaka suggests in #93415 (comment) the most. |
I thing that indentations and positions of columns should be consistent at least inside every page. If not use the same position globally, we can increase it for envvars only:
|
We can also follow the existing precedence for long option and always start the description from a new line:
|
Current output with this PR:
It uses the same indentation for descriptions of all options (including -X) and larger indentation for descriptions of envvars. |
Latest comment looks good! |
I resolved the merge conflicts. The new output:
|
Looks good, although it's quite a big wall of text. I think some blank newlines between chunks would help with readability. At least before "Arguments:" and "These variables have equivalent command-line options (see --help for details):", for example: Details
|
Also the first two sections are concatenated this with backslashes: static const char usage_help[] = "\
Options (and corresponding environment variables):\n\
-b : issue warnings about str(bytes_instance), str(bytearray_instance)\n\
and comparing bytes/bytearray with str. (-bb: issue errors)\n\
-B : don't write .pyc files on import; also PYTHONDONTWRITEBYTECODE=x\n\
...
"; static const char usage_xoptions[] = "\
The following implementation-specific options are available:\n\
-X faulthandler: enable faulthandler\n\
-X showrefcount: output the total reference count and number of used\n\
...
; And the last with double quotes: static const char usage_envvars[] =
"Environment variables that change behavior:\n"
"PYTHONSTARTUP : file executed on interactive startup (no default)\n"
"PYTHONPATH : '%lc'-separated list of directories prefixed to the\n"
...
; Is it worth defining them all the same way? (They're also formatted differently, at least in PyCharm.) |
I am going to rewrite also help messages. For most options and variables they should be only 1-2 lines long. More details can be read in the documentation. But this is a different issue. |
It would be not consistent with the way how other longer-than-normal options and envvars are formatted. Padding is only added if the name is shorter-than-normal. If it is longer-than-normal, the colon is added immediately after the name. |
We can also write:
But it would be a waste of precious vertical space. |
I'm not too worried about using extra vertical or horizontal space when it adds room to breathe/see. If we have to stick to that consistency rule (do we?), can we increase the base indent for this section? For example, the |
The added newlines (before arguments and envvars with equivalents) are a nice addition, but I do agree with Serhiy’s comment that taking too much vertical space would not be good. |
It will be not good for almost all of options. Too large distance between the option and its description will harm readability. It will also require more line wraps. |
This PR is in bikeshedding hell since mid-2022 and I think we're all agreeing it's improving the status quo, there's just disagreement on possible further improvements. I feel like this is ready to go. Unless somebody stops me, I will be merging this tomorrow. |
This definitely improves things, so 👍 from me. Thanks @serhiy-storchaka! |
Bit harsh to call all the reviews here bikeshedding, but regardless this is ready 👍🏽 |
Thanks @serhiy-storchaka for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
Sorry, @serhiy-storchaka and @ambv, I could not cleanly backport this to
|
Sorry, @serhiy-storchaka and @ambv, I could not cleanly backport this to
|
I'll deal with the backports. |
Thank you @ambv. |
…93415) (cherry picked from commit 2e92ffd) Co-authored-by: Serhiy Storchaka <[email protected]>
GH-115847 is a backport of this pull request to the 3.12 branch. |
I'll base the 3.11 backport on the 3.12 backport. |
) (cherry picked from commit 2e92ffd) Co-authored-by: Serhiy Storchaka <[email protected]>
…93415) (python#115847) (cherry picked from commit 2e92ffd) Co-authored-by: Serhiy Storchaka <[email protected]> (cherry picked from commit 2bdd1d6)
#90300