Skip to content

Standardize argparse help messages#38804

Merged
tgamblin merged 1 commit intospack:developfrom
adamjstewart:cmds/help
Jul 13, 2023
Merged

Standardize argparse help messages#38804
tgamblin merged 1 commit intospack:developfrom
adamjstewart:cmds/help

Conversation

@adamjstewart
Copy link
Copy Markdown
Member

@adamjstewart adamjstewart commented Jul 9, 2023

Rationale

While working on #29549, I noticed a lot of inconsistencies in our argparse help messages. This is important for fish where these help messages end up as descriptions in the tab completion menu. See #29549 (comment) for some examples of longer or more stylized help messages.

Implementation

This PR makes the following changes:

  • help messages start with a lowercase letter.

  • Help messages do not end with a period

  • the first line of a help message is short and simple

    longer text is separated by an empty line

  • "help messages do not use triple quotes"

    """(except docstrings)"""

  • Parentheses not needed for string concatenation inside function call

  • Remove "..." "..." string concatenation leftover from black reformatting

  • Remove Sphinx argument docs from help messages

The first 2 choices aren't very controversial, and are designed to match the syntax of the --help flag automatically added by argparse. The 3rd choice is more up for debate, and is designed to match our package/module docstrings. The 4th choice is designed to avoid excessive newline characters and indentation. We may actually want to go even further and disallow docstrings altogether.

Alternatives

Choice 3 in particular has a lot of alternatives. My goal is solely to ensure that fish tab completion looks reasonable. Alternatives include:

  1. Get rid of long help messages, only allow short simple messages
  2. Move longer help messages to epilog
  3. Separate by 2 newline characters instead of 1
  4. Separate by period instead of newline. First sentence goes into tab completion description

The number of commands with long help text is actually rather small, and is mostly relegated to spack ci and spack buildcache. So 1 isn't actually as ridiculous as it sounds.

Let me know if there are any other standardizations or alternatives you would like to suggest.

@spackbot-app spackbot-app bot added commands core PR affects Spack core functionality labels Jul 9, 2023
@adamjstewart adamjstewart mentioned this pull request Jul 10, 2023
5 tasks
@alalazo
Copy link
Copy Markdown
Member

alalazo commented Jul 12, 2023

Do we have any mechanism in CI to ensure the help messages stay standardized in time?

@adamjstewart
Copy link
Copy Markdown
Member Author

Unfortunately there isn't an easy way to test this. Some help messages start with a proper noun (e.g., Spack, CDash) and should be capitalized. We could add exceptions for each thing. But the standardization proposed here is very superficial. If someone doesn't follow it, nothing breaks, it's just that fish tab completion or spack help output may look a little funny.

@tgamblin tgamblin merged commit bb7f437 into spack:develop Jul 13, 2023
@adamjstewart adamjstewart deleted the cmds/help branch July 13, 2023 15:10
tbhaxor pushed a commit to tbhaxor/spack that referenced this pull request Jul 25, 2023
### Rationale

While working on spack#29549, I noticed a lot of inconsistencies in our argparse help messages. This is important for fish where these help messages end up as descriptions in the tab completion menu. See spack#29549 (comment) for some examples of longer or more stylized help messages.

### Implementation

This PR makes the following changes:

- [x] help messages start with a lowercase letter.
- [x] Help messages do not end with a period
- [x] the first line of a help message is short and simple

    longer text is separated by an empty line
- [x] "help messages do not use triple quotes" 

    """(except docstrings)"""
- [x] Parentheses not needed for string concatenation inside function call
- [x] Remove "..." "..." string concatenation leftover from black reformatting
- [x] Remove Sphinx argument docs from help messages

The first 2 choices aren't very controversial, and are designed to match the syntax of the `--help` flag automatically added by argparse. The 3rd choice is more up for debate, and is designed to match our package/module docstrings. The 4th choice is designed to avoid excessive newline characters and indentation. We may actually want to go even further and disallow docstrings altogether.

### Alternatives

Choice 3 in particular has a lot of alternatives. My goal is solely to ensure that fish tab completion looks reasonable. Alternatives include:

1. Get rid of long help messages, only allow short simple messages
2. Move longer help messages to epilog
3. Separate by 2 newline characters instead of 1
4. Separate by period instead of newline. First sentence goes into tab completion description

The number of commands with long help text is actually rather small, and is mostly relegated to `spack ci` and `spack buildcache`. So 1 isn't actually as ridiculous as it sounds.

Let me know if there are any other standardizations or alternatives you would like to suggest.
tbhaxor pushed a commit to tbhaxor/spack that referenced this pull request Jul 25, 2023
### Rationale

While working on spack#29549, I noticed a lot of inconsistencies in our argparse help messages. This is important for fish where these help messages end up as descriptions in the tab completion menu. See spack#29549 (comment) for some examples of longer or more stylized help messages.

### Implementation

This PR makes the following changes:

- [x] help messages start with a lowercase letter.
- [x] Help messages do not end with a period
- [x] the first line of a help message is short and simple

    longer text is separated by an empty line
- [x] "help messages do not use triple quotes" 

    """(except docstrings)"""
- [x] Parentheses not needed for string concatenation inside function call
- [x] Remove "..." "..." string concatenation leftover from black reformatting
- [x] Remove Sphinx argument docs from help messages

The first 2 choices aren't very controversial, and are designed to match the syntax of the `--help` flag automatically added by argparse. The 3rd choice is more up for debate, and is designed to match our package/module docstrings. The 4th choice is designed to avoid excessive newline characters and indentation. We may actually want to go even further and disallow docstrings altogether.

### Alternatives

Choice 3 in particular has a lot of alternatives. My goal is solely to ensure that fish tab completion looks reasonable. Alternatives include:

1. Get rid of long help messages, only allow short simple messages
2. Move longer help messages to epilog
3. Separate by 2 newline characters instead of 1
4. Separate by period instead of newline. First sentence goes into tab completion description

The number of commands with long help text is actually rather small, and is mostly relegated to `spack ci` and `spack buildcache`. So 1 isn't actually as ridiculous as it sounds.

Let me know if there are any other standardizations or alternatives you would like to suggest.
mpokorny pushed a commit to mpokorny/spack that referenced this pull request Sep 18, 2023
### Rationale

While working on spack#29549, I noticed a lot of inconsistencies in our argparse help messages. This is important for fish where these help messages end up as descriptions in the tab completion menu. See spack#29549 (comment) for some examples of longer or more stylized help messages.

### Implementation

This PR makes the following changes:

- [x] help messages start with a lowercase letter.
- [x] Help messages do not end with a period
- [x] the first line of a help message is short and simple

    longer text is separated by an empty line
- [x] "help messages do not use triple quotes" 

    """(except docstrings)"""
- [x] Parentheses not needed for string concatenation inside function call
- [x] Remove "..." "..." string concatenation leftover from black reformatting
- [x] Remove Sphinx argument docs from help messages

The first 2 choices aren't very controversial, and are designed to match the syntax of the `--help` flag automatically added by argparse. The 3rd choice is more up for debate, and is designed to match our package/module docstrings. The 4th choice is designed to avoid excessive newline characters and indentation. We may actually want to go even further and disallow docstrings altogether.

### Alternatives

Choice 3 in particular has a lot of alternatives. My goal is solely to ensure that fish tab completion looks reasonable. Alternatives include:

1. Get rid of long help messages, only allow short simple messages
2. Move longer help messages to epilog
3. Separate by 2 newline characters instead of 1
4. Separate by period instead of newline. First sentence goes into tab completion description

The number of commands with long help text is actually rather small, and is mostly relegated to `spack ci` and `spack buildcache`. So 1 isn't actually as ridiculous as it sounds.

Let me know if there are any other standardizations or alternatives you would like to suggest.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands core PR affects Spack core functionality user-experience

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants