Skip to content
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

Allow whitespace before ${cmd_name}. #329

Merged
merged 1 commit into from
Mar 15, 2022
Merged

Conversation

andrewshadura
Copy link
Contributor

@andrewshadura andrewshadura commented Sep 2, 2017

It's not immediately obvious to the plug-in writers ${cmd_name} must be on the very first line of the docstring, and docstrings often begin and end with """ on its own line:

"""
${cmd_name}: Foobarise baz

This command makes baz more foobarish.

${cmd_usage}
${cmd_option_list}
"""

@marcus-h
Copy link
Member

marcus-h commented Sep 2, 2017 via email

@andrewshadura
Copy link
Contributor Author

I thought the explanation in the pull request would be enough… I don't think it's wrong to put """ on its own line, and I actually prefer that style, so why not allow that? Is there any reason to strictly require no whitespace before ${cmd_name}?

@andrewshadura
Copy link
Contributor Author

Right, I suspect you may have not seen it, as I have added the explanation after I created the pull request, and you seem to be using GitHub's email interface. Let me repost it for you:

It's not immediately obvious to the plug-in writers ${cmd_name} must be on the very first line of the docstring, and docstrings often begin and end with """ on its own line:

"""
${cmd_name}: Foobarise baz

This command makes baz more foobarish.

${cmd_usage}
${cmd_option_list}
"""

@andrewshadura
Copy link
Contributor Author

PEP 257 says:

Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. The summary line may be on the same line as the opening quotes or on the next line. The entire docstring is indented the same as the quotes at its first line (see example below).

@marcus-h
Copy link
Member

marcus-h commented Sep 4, 2017 via email

@andrewshadura
Copy link
Contributor Author

andrewshadura commented Sep 4, 2017 via email

Comment on lines +791 to +794
if doc and doc.lstrip().startswith(to_strip):
#log.debug("stripping %r from start of %s's help string",
# to_strip, cmdname)
doc = doc[len(to_strip):].lstrip()
doc = (doc.lstrip())[len(to_strip):].lstrip()
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't be better to do doc = doc.lstrip() before if doc ...?
It is more efficient (running lstrip() only once) and also covers a situation (unlikely one) that the docstring contains only whitespaces.

@dmach dmach added this to In progress in User Experience via automation Jan 4, 2022
@dmach
Copy link
Contributor

dmach commented Mar 15, 2022

This change makes sense to me and it sits in the backlog for too long.
Merging in.

@dmach dmach merged commit 473b0d4 into openSUSE:master Mar 15, 2022
User Experience automation moved this from In progress to Done Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants