summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKa-Ping Yee <ping@zesty.ca>2005-02-19 22:57:37 (GMT)
committerKa-Ping Yee <ping@zesty.ca>2005-02-19 22:57:37 (GMT)
commit3adf5220ac93538e7696885b10996f835504a490 (patch)
tree7939e0f20baafa3e13229cc0c83e84160a1a964c
parentfcfa195eec472225025da66194d8ad167436f409 (diff)
downloadcpython-3adf5220ac93538e7696885b10996f835504a490.zip
cpython-3adf5220ac93538e7696885b10996f835504a490.tar.gz
cpython-3adf5220ac93538e7696885b10996f835504a490.tar.bz2
Use getdoc(object) instead of object.__doc__ to fix indentation problems.
Thanks to Robert Dick <dickrp@ece.northwestern.edu> for reporting this bug and submitting a patch. Adjust doc(object) to display useful documentation for plain values (e.g. help([]) now shows the methods on the list instead of just printing "[]"). (This change has been tested interactively, by generating docs for the standard library, and by running the module documentation webserver.)
-rwxr-xr-xLib/pydoc.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 16d5585..f08af90 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -878,7 +878,7 @@ class HTMLDoc(Doc):
if name:
push('<dl><dt><strong>%s</strong></dt>\n' % name)
if value.__doc__ is not None:
- doc = self.markup(value.__doc__, self.preformat)
+ doc = self.markup(getdoc(value), self.preformat)
push('<dd><tt>%s</tt></dd>\n' % doc)
for attr, tag in [('fget', '<em>get</em>'),
('fset', '<em>set</em>'),
@@ -1159,7 +1159,7 @@ class TextDoc(Doc):
push(msg)
for name, kind, homecls, value in ok:
if callable(value) or inspect.isdatadescriptor(value):
- doc = getattr(value, "__doc__", None)
+ doc = getdoc(value)
else:
doc = None
push(self.docother(getattr(object, name),
@@ -1464,6 +1464,14 @@ def doc(thing, title='Python Library Documentation: %s', forceload=0):
desc += ' in ' + name[:name.rfind('.')]
elif module and module is not object:
desc += ' in module ' + module.__name__
+ if not (inspect.ismodule(object) or
+ inspect.isclass(object) or
+ inspect.isroutine(object) or
+ isinstance(object, property)):
+ # If the passed object is a piece of data or an instance,
+ # document its available methods instead of its value.
+ object = type(object)
+ desc += ' object'
pager(title % desc + '\n\n' + text.document(object, name))
except (ImportError, ErrorDuringImport), value:
print value