Skip to content

Format multiline doc strings to match style of other help messages #1007

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

Merged
merged 7 commits into from
Nov 12, 2020

Conversation

bambu
Copy link
Contributor

@bambu bambu commented Oct 10, 2020

Changed cmd2 do_cmd to dedent doc strings using pydoc.getdoc in order for the output of multi-line doc strings to look similar to argparse or a single line doc string. It continues prioritizing help_func functions over doc strings.

Before patch:

(cmd2) ➜  cmd2 git:(docstr_fmt) ✗ python examples/help_categories.py
(Cmd) help findleakers
Find Leakers command
(Cmd) help sslconnectorciphers

        SSL Connector Ciphers command is an example of a command that contains
        multiple lines of help information for the user. Each line of help in a
        contiguous set of lines will be printed and aligned in the verbose output
        provided with 'help --verbose'

        This is after a blank line and won't de displayed in the verbose help

After patch:

(cmd2) ➜  cmd2 git:(docstr_fmt) ✗ python examples/help_categories.py
(Cmd) help findleakers
Find Leakers command
(Cmd) help sslconnectorciphers
SSL Connector Ciphers command is an example of a command that contains
multiple lines of help information for the user. Each line of help in a
contiguous set of lines will be printed and aligned in the verbose output
provided with 'help --verbose'

This is after a blank line and won't de displayed in the verbose help

Changed cmd2 do_cmd to dedent docstrings using `pydoc.getdoc`. This patch provides output for docstrings that look like using argparse or a single line docstring
@tleonhardt
Copy link
Member

@bambu Thanks for the PR. Can you please fix the flake8 error(s)?

@kmvanbrunt @anselor Do either of you have an opinion about the changes in this PR? It changes the way help is displayed, but it isn't clear to me if the change makes things better or worse or if its just neautral.

@kmvanbrunt
Copy link
Member

@tleonhardt I would like some time to check out the effects of this PR. Unfortunately I've been sick, so I'll take a look when I'm well.

@tleonhardt
Copy link
Member

@kmvanbrunt I don’t think there is any rush for merging this in. @bambu needs to fix the flake8 error(s) first anyways. So take your time.

@codecov
Copy link

codecov bot commented Oct 20, 2020

Codecov Report

Merging #1007 (86d0e9c) into master (887bda4) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1007      +/-   ##
==========================================
+ Coverage   97.87%   97.89%   +0.02%     
==========================================
  Files          22       22              
  Lines        4613     4616       +3     
==========================================
+ Hits         4515     4519       +4     
+ Misses         98       97       -1     
Impacted Files Coverage Δ
cmd2/cmd2.py 97.27% <100.00%> (+<0.01%) ⬆️
cmd2/utils.py 97.88% <0.00%> (+0.23%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 887bda4...86d0e9c. Read the comment docs.

tleonhardt
tleonhardt previously approved these changes Oct 20, 2020
Copy link
Member

@tleonhardt tleonhardt left a comment

Choose a reason for hiding this comment

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

To me, the change appears neutral - better in some ways and worse in others. It doesn't seem to hurt anything. I'm pretty ambivalent in regards to whether we merge this in or reject it.

@kmvanbrunt @anselor @kotfu If any of you has an opinion, please weigh in. There is no rush to merge this, so lets gather input from all interested in providing it.

@tleonhardt
Copy link
Member

@bambu Thanks for fixing the minor flake8 error so the all of the continuous integration checks can pass.

@bambu
Copy link
Contributor Author

bambu commented Oct 20, 2020

@tleonhardt it is definitely a minor change. I primarily like the consistency of having the same amount of indentation whether you are using argparse or a docstring. IMHO it also looks odd when the docstring itself has some indentation. In these cases there are multiple levels of indentation and usually inconsistent spacing.

Also, no rush on the merge

Copy link
Member

@tleonhardt tleonhardt left a comment

Choose a reason for hiding this comment

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

Changes look good.

TravisCI appears to potentially broken for us today. If its a temporary thing fine. If not, we might need to look into our configuration and/or moving to GitHubActions.

@tleonhardt tleonhardt merged commit aac467e into python-cmd2:master Nov 12, 2020
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.

4 participants