mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-52161: Enhance Cmd support for docstrings (#110987)
In `cmd.Cmd.do_help` call `inspect.cleandoc()`, to clean indentation and remove leading/trailing empty lines from a dosctring before printing.
This commit is contained in:
parent
f1f8392432
commit
4c4b08dd2b
2 changed files with 4 additions and 1 deletions
|
@ -42,7 +42,7 @@ listings of documented functions, miscellaneous topics, and undocumented
|
|||
functions respectively.
|
||||
"""
|
||||
|
||||
import string, sys
|
||||
import inspect, string, sys
|
||||
|
||||
__all__ = ["Cmd"]
|
||||
|
||||
|
@ -305,6 +305,7 @@ class Cmd:
|
|||
except AttributeError:
|
||||
try:
|
||||
doc=getattr(self, 'do_' + arg).__doc__
|
||||
doc = inspect.cleandoc(doc)
|
||||
if doc:
|
||||
self.stdout.write("%s\n"%str(doc))
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue