[Python-checkins] python/dist/src/Lib pydoc.py,1.100.2.1,1.100.2.2

ping at users.sourceforge.net ping at users.sourceforge.net
Sat Feb 19 23:57:40 CET 2005


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18476

Modified Files:
      Tag: release24-maint
	pydoc.py 
Log Message:
Use getdoc(object) instead of object.__doc__ to fix indentation problems.
Thanks to Robert Dick <dickrp at 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.)


Index: pydoc.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v
retrieving revision 1.100.2.1
retrieving revision 1.100.2.2
diff -u -d -r1.100.2.1 -r1.100.2.2
--- pydoc.py	1 Jan 2005 07:52:40 -0000	1.100.2.1
+++ pydoc.py	19 Feb 2005 22:57:37 -0000	1.100.2.2
@@ -878,7 +878,7 @@
         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 @@
                 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 @@
             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



More information about the Python-checkins mailing list