[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/apidoc/codemodule/ APIDoc now knows about method descriptors

Dmitry Vasiliev dima at hlabs.spb.ru
Mon May 30 06:57:07 EDT 2005


Log message for revision 30552:
  APIDoc now knows about method descriptors
  

Changed:
  U   Zope3/trunk/src/zope/app/apidoc/codemodule/browser/class_.py
  U   Zope3/trunk/src/zope/app/apidoc/codemodule/class_.py
  U   Zope3/trunk/src/zope/app/apidoc/codemodule/interfaces.py

-=-
Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/class_.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/class_.py	2005-05-30 10:50:09 UTC (rev 30551)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/class_.py	2005-05-30 10:56:37 UTC (rev 30552)
@@ -109,6 +109,14 @@
         # `getPermissionIds()` also expects the class's security checker not
         # to be proxied.
         klass = removeSecurityProxy(self.context)
+        for name, attr, iface in klass.getMethodDescriptors():
+            entry = {'name': name,
+                     'signature': "(...)",
+                     'doc': renderText(attr.__doc__ or '',
+                                       zapi.getParent(self.context).getPath()),
+                     'interface': getPythonPath(iface)}
+            entry.update(getPermissionIds(name, klass.getSecurityChecker()))
+            methods.append(entry)
         for name, attr, iface in klass.getMethods():
             entry = {'name': name,
                      'signature': getFunctionSignature(attr),

Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/class_.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/class_.py	2005-05-30 10:50:09 UTC (rev 30551)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/class_.py	2005-05-30 10:56:37 UTC (rev 30552)
@@ -18,7 +18,7 @@
 
 __docformat__ = 'restructuredtext'
 
-from inspect import ismethod
+from inspect import ismethod, ismethoddescriptor
 
 from zope.interface import implements, implementedBy
 from zope.security.checker import getCheckerForInstancesOf
@@ -82,13 +82,18 @@
     def getAttributes(self):
         """See IClassDocumentation."""
         return [(name, obj, iface) for name, obj, iface
-            in self._iterAllAttributes() if not ismethod(obj)]
+            in self._iterAllAttributes()
+            if not (ismethod(obj) or ismethoddescriptor(obj))]
 
     def getMethods(self):
         """See IClassDocumentation."""
         return [(name, obj, iface) for name, obj, iface
             in self._iterAllAttributes() if ismethod(obj)]
 
+    def getMethodDescriptors(self):
+        return [(name, obj, iface) for name, obj, iface
+            in self._iterAllAttributes() if ismethoddescriptor(obj)]
+
     def getSecurityChecker(self):
         """See IClassDocumentation."""
         return getCheckerForInstancesOf(self.__klass)

Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/interfaces.py	2005-05-30 10:50:09 UTC (rev 30551)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/interfaces.py	2005-05-30 10:56:37 UTC (rev 30552)
@@ -87,6 +87,17 @@
         that do not start with an '_'-character.
         """
 
+    def getMethodDescriptors():
+        """Return a list of 3-tuple method descriptor information.
+
+        The first entry of the 3-tuple is the name of the method, the
+        second is the method descriptor object itself. The third entry is the
+        interface in which the method is defined.
+
+        Note that only public methods are returned, meaning only method
+        descriptors that do not start with an '_'-character.
+        """
+
     def getSecurityChecker():
         """Return the security checker for this class.
 
@@ -122,7 +133,7 @@
         title=u'Name',
         description=u'Name of the directive in the form (Namespace. Name)',
         required = True)
-    
+
     schema = zope.schema.Field(
         title=u'Schema',
         description=u'Schema describing the directive attributes',
@@ -132,7 +143,7 @@
         title=u'Attributes',
         description=u'SAX parser representation of the directive\'s attributes',
         required = True)
-        
+
     context = zope.schema.Field(
         title=u'Configuration Context',
         description=u'Configuration context while the directive was parsed.',
@@ -187,4 +198,3 @@
         title=_("XML Root Element"),
         description=_("XML element representing the configuration root."),
         required=True)
-    



More information about the Zope3-Checkins mailing list