[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/apidoc/ -
zope.app.apidoc.ifacemodule.browser.InterfaceDetails:
Fred L. Drake, Jr.
fdrake at gmail.com
Wed Oct 20 23:35:59 EDT 2004
Log message for revision 28226:
- zope.app.apidoc.ifacemodule.browser.InterfaceDetails:
Get field names using a helper method, to allow the ZCML package to
override.
- zope.app.apidoc.zcmlmodule.browser.DirectiveDetails:
Override the field-name helper method from InterfaceDetails to strip
off the trailing underscore for directive attributes that otherwise
correspond to Python keywords. This allows the documentation to
match the ZCML syntax.
Changed:
U Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.py
U Zope3/trunk/src/zope/app/apidoc/zcmlmodule/browser.py
-=-
Modified: Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.py 2004-10-21 03:25:01 UTC (rev 28225)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.py 2004-10-21 03:35:57 UTC (rev 28226)
@@ -394,7 +394,7 @@
# remove security proxies, the location proxy's module will be
# returned.
fields = map(lambda x: x[1], _getInOrder(self.context, IField))
- return [{'name': field.getName(),
+ return [{'name': self._getFieldName(field),
'iface': _getFieldInterface(field),
'class': _getFieldClass(field),
'required': _getRequired(field),
@@ -404,6 +404,9 @@
removeAllProxies(self.context).__module__)}
for field in fields]
+ def _getFieldName(self, field):
+ return field.getName()
+
def getRequiredAdapters(self):
"""Get adapters where this interface is required.
Modified: Zope3/trunk/src/zope/app/apidoc/zcmlmodule/browser.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/zcmlmodule/browser.py 2004-10-21 03:25:01 UTC (rev 28225)
+++ Zope3/trunk/src/zope/app/apidoc/zcmlmodule/browser.py 2004-10-21 03:35:57 UTC (rev 28226)
@@ -17,6 +17,8 @@
"""
__docformat__ = 'restructuredtext'
+import keyword
+
from zope.configuration.xmlconfig import ParserInfo
from zope.security.proxy import removeSecurityProxy
@@ -88,9 +90,26 @@
return None
+def _getFieldName(field):
+ name = field.getName()
+ if name.endswith("_") and keyword.iskeyword(name[:-1]):
+ name = name[:-1]
+ return name
+
+
class DirectiveDetails(object):
"""View class for a Directive."""
+ def _getInterfaceDetails(self, schema):
+ schema = LocationProxy(schema,
+ self.context,
+ getPythonPath(schema))
+ details = InterfaceDetails()
+ details._getFieldName = _getFieldName
+ details.context = schema
+ details.request = self.request
+ return details
+
def getSchema(self):
"""Return the schema of the directive.
@@ -113,13 +132,7 @@
>>> iface.context
<InterfaceClass zope.app.apidoc.zcmlmodule.browser.IFoo>
"""
- schema = LocationProxy(self.context.schema,
- self.context,
- getPythonPath(self.context.schema))
- details = InterfaceDetails()
- details.context = schema
- details.request = self.request
- return details
+ return self._getInterfaceDetails(self.context.schema)
def getNamespaceName(self):
"""Return the name of the namespace.
@@ -261,11 +274,7 @@
"""
dirs = []
for ns, name, schema, handler, info in self.context.subdirs:
- schema = LocationProxy(schema, self.context, getPythonPath(schema))
- details = InterfaceDetails()
- details.context = schema
- details.request = self.request
-
+ details = self._getInterfaceDetails(schema)
path = getPythonPath(handler)
dirs.append({'namespace': ns,
'name': name,
More information about the Zope3-Checkins
mailing list