[Checkins] SVN: zope.introspector/trunk/src/zope/introspector/code.py Let modules and functions provide their docstrings.

Uli Fouquet uli at gnufix.de
Tue Aug 12 19:51:04 EDT 2008


Log message for revision 89762:
  Let modules and functions provide their docstrings.

Changed:
  U   zope.introspector/trunk/src/zope/introspector/code.py

-=-
Modified: zope.introspector/trunk/src/zope/introspector/code.py
===================================================================
--- zope.introspector/trunk/src/zope/introspector/code.py	2008-08-12 23:04:35 UTC (rev 89761)
+++ zope.introspector/trunk/src/zope/introspector/code.py	2008-08-12 23:51:04 UTC (rev 89762)
@@ -43,6 +43,9 @@
 
     def getModuleInfo(self):
         return self._module_info
+
+    def getDocString(self):
+        return getattr(self._module, '__doc__', u'')
     
 class Package(PackageOrModule):
     def getPath(self):
@@ -210,9 +213,9 @@
 
 class Function(Code):
 
-    def getSignature(self):
-        func = resolve(self.dotted_name)
-        return get_function_signature(func)
+    def __init__(self, dotted_name):
+        super(Function, self).__init__(dotted_name)
+        self.func = resolve(self.dotted_name)
 
 class FunctionInfo(grok.Adapter):
     grok.context(Function)
@@ -220,8 +223,10 @@
     grok.name('function')
 
     def getSignature(self):
-        return self.context.getSignature()
+        return get_function_signature(self.context.func)
 
+    def getDocString(self):
+        return getattr(self.context.func, '__doc__', u'')
 
 class Instance(Code):
     pass



More information about the Checkins mailing list