Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Lib/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,16 @@
functions respectively.
"""

import string, sys
import inspect
import string
import sys

__all__ = ["Cmd"]

PROMPT = '(Cmd) '
IDENTCHARS = string.ascii_letters + string.digits + '_'


class Cmd:
"""A simple framework for writing line-oriented command interpreters.

Expand Down Expand Up @@ -297,7 +300,8 @@ def do_help(self, arg):
func = getattr(self, 'help_' + arg)
except AttributeError:
try:
doc=getattr(self, 'do_' + arg).__doc__
doc = getattr(self, 'do_' + arg).__doc__
doc = inspect.cleandoc(doc)
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUIC, this line is the actual patch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this and, obviously, the additional import

if doc:
self.stdout.write("%s\n"%str(doc))
return
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:meth:`cmd.Cmd.do_help` now cleans docstrings with :func:`inspect.cleandoc`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know if ":meth:cmd.Cmd.do_help" is correct, there definitely is no cmd.Cmd.do_help anchor in the documentation. Maybe I'd need to update the documentation to give do_help a separate section. I'm open to feedback here and in general.

Copy link
Member

Choose a reason for hiding this comment

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

It seems to work. Let's not worry about it.

before writing them. Patch by Filip Łapkiewicz.