mirror of
https://github.com/python/cpython.git
synced 2025-09-21 16:10:33 +00:00
Patch by Michael Scharf. He writes:
The module cmd requires for each do_xxx command a help_xxx function. I think this is a little old fashioned. Here is a patch: use the docstring as help if no help_xxx function can be found. [I'm tempted to rip out all the help_* functions from pdb, but I'll resist it. Any takers? --Guido]
This commit is contained in:
parent
7039f50828
commit
d5138caba5
1 changed files with 9 additions and 0 deletions
|
@ -127,6 +127,13 @@ class Cmd:
|
||||||
try:
|
try:
|
||||||
func = getattr(self, 'help_' + arg)
|
func = getattr(self, 'help_' + arg)
|
||||||
except:
|
except:
|
||||||
|
try:
|
||||||
|
doc=getattr(self, 'do_' + arg).__doc__
|
||||||
|
if doc:
|
||||||
|
print doc
|
||||||
|
return
|
||||||
|
except:
|
||||||
|
pass
|
||||||
print self.nohelp % (arg,)
|
print self.nohelp % (arg,)
|
||||||
return
|
return
|
||||||
func()
|
func()
|
||||||
|
@ -159,6 +166,8 @@ class Cmd:
|
||||||
if help.has_key(cmd):
|
if help.has_key(cmd):
|
||||||
cmds_doc.append(cmd)
|
cmds_doc.append(cmd)
|
||||||
del help[cmd]
|
del help[cmd]
|
||||||
|
elif getattr(self, name).__doc__:
|
||||||
|
cmds_doc.append(cmd)
|
||||||
else:
|
else:
|
||||||
cmds_undoc.append(cmd)
|
cmds_undoc.append(cmd)
|
||||||
print self.doc_leader
|
print self.doc_leader
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue