[Zope3-checkins] CVS: Zope3/src/zope/configuration - metameta.zcml:1.3 metametaconfigure.py:1.3 metametaconfigurefordocgen.py:1.3 metametafordocgen.zcml:1.3

Jim Fulton jim@zope.com
Fri, 27 Dec 2002 18:28:33 -0500


Update of /cvs-repository/Zope3/src/zope/configuration
In directory cvs.zope.org:/tmp/cvs-serv14937/src/zope/configuration

Modified Files:
	metameta.zcml metametaconfigure.py 
	metametaconfigurefordocgen.py metametafordocgen.zcml 
Log Message:
Added description subdirectives for providing multi-line descriptions.


=== Zope3/src/zope/configuration/metameta.zcml 1.2 => 1.3 ===
--- Zope3/src/zope/configuration/metameta.zcml:1.2	Wed Dec 25 09:13:33 2002
+++ Zope3/src/zope/configuration/metameta.zcml	Fri Dec 27 18:28:33 2002
@@ -30,21 +30,38 @@
       name="directives"
       attributes="namespace name handler attributes description"
       handler="zope.configuration.metametaconfigure.DirectiveNamespace"
-    >
+      >
     <subdirective
         name="directive"
         attributes="namespace name handler attributes description"
-    >
+        >
       <subdirective
           name="attribute"
-          attributes="name description required" />
+          attributes="name description required" >
+        <subdirective
+            name="description"
+            attributes="" 
+            />
+        </subdirective>
+      <subdirective
+          name="description"
+          attributes="" />
       <subdirective
           name="subdirective"
           attributes="name attributes namespace handler_method description"
-      >
+          >
+        <subdirective
+            name="description"
+            attributes="" />
         <subdirective
             name="attribute"
-            attributes="name description required" />
+            attributes="name description required"
+            >
+        <subdirective
+            name="description"
+            attributes="" 
+            />
+          </subdirective>
       </subdirective>
     </subdirective>
   </directive>


=== Zope3/src/zope/configuration/metametaconfigure.py 1.2 => 1.3 ===
--- Zope3/src/zope/configuration/metametaconfigure.py:1.2	Wed Dec 25 09:13:33 2002
+++ Zope3/src/zope/configuration/metametaconfigure.py	Fri Dec 27 18:28:33 2002
@@ -30,15 +30,25 @@
     __class_implements_ = INonEmptyDirective
     __implements__ = ISubdirectiveHandler
 
-    def _Subdirective(self, *args, **kw): return Subdirective(*args, **kw)
+    def _Subdirective(self, *args, **kw):
+        return Subdirective(*args, **kw)
 
-    def _useDescription(self, namespace, name, handler, description, subs): pass
+    def _useDescription(self, namespace, name, handler, description, subs):
+        pass
 
     def directive(self, _context, name, handler, attributes='',
-            namespace=None, description=''):
+                  namespace=None, description=''):
+
         subs, namespace = self._register(_context, name, handler, namespace)
+
+        # Extra whitespace is not significant, since the parser
+        # removes the newlines.
+        description = ' '.join(description.strip().split())
+
         self._useDescription(namespace, name, handler, description, subs)
+
         return self._Subdirective(subs, namespace=namespace, name=name)
+
     directive.__implements__ = INonEmptyDirective
 
 
@@ -51,21 +61,93 @@
         bootstrapSubdirective.__init__(self,subs,namespace)
         self._name = name
 
-    def _useDescription(self, namespace, name, subs, description): pass
+    def _useDescription(self, namespace, name, subs, description):
+        pass
 
     def subdirective(self, _context, name, attributes='',
                      namespace=None, handler_method=None, description=''):
+
         subs, namespace = self._register(_context, name, namespace,
                                          handler_method)
+
+        # Extra whitespace is not significant, since the parser
+        # removes the newlines.
+        description = ' '.join(description.strip().split())
+
         self._useDescription(namespace, name, subs, description)
         return self.__class__(subs, namespace=namespace, name=name)
+
     subdirective.__implements__ = INonEmptyDirective
 
-    def _useAttributeDescription(self, name, required, description): pass
+    def _useAttributeDescription(self, name, required, description):
+        pass
 
     def attribute(self, _context, name, required='', description=''):
+        return Attribute(self, name, required, description)
+
+    attribute.__implements__ = INonEmptyDirective
+
+    def description(self, _context):
+        return Description(self)
+
+    description.__implements__ = INonEmptyDirective
+
+class Description:
+
+    __implements__ = ISubdirectiveHandler
+    
+    def __init__(self, dir):
+        self._dir = dir
+        self._description = ''
+
+    def zcmlText(self, text):
+        self._description += text
+
+    def __call__(self):
+        self._dir._useDescription(
+            self._dir._namespace, self._dir._name, self._dir._subs,
+            self._description)
+
+        return ()
+
+class Attribute:
+
+    __implements__ = ISubdirectiveHandler
+    
+    def __init__(self, dir, name, required, description=''):
         required = required.lower()
-        if required not in ('', 'yes', 'no'): raise ValueError(required)
-        self._useAttributeDescription(name, required, description)
+        if required not in ('', 'yes', 'no'):
+            raise ValueError(required)
+
+        # Extra whitespace is not significant, since the parser
+        # removes the newlines.
+        description = ' '.join(description.strip().split())
+
+        self._dir = dir
+        self._name = name
+        self._required = required
+        self._description = description
+
+    def description(self, _context):
+        return AttrDescription(self)
+
+    description.__implements__ = INonEmptyDirective
+
+    def __call__(self):
+        self._dir._useAttributeDescription(
+            self._name, self._required, self._description)
+        return ()
+
+class AttrDescription:
+
+    __implements__ = ISubdirectiveHandler
+    
+    def __init__(self, dir):
+        self._dir = dir
+
+    def zcmlText(self, text):
+        self._dir._description += text
+
+    def __call__(self):
         return ()
-    attribute.__implements__ = IEmptyDirective
+        


=== Zope3/src/zope/configuration/metametaconfigurefordocgen.py 1.2 => 1.3 ===
--- Zope3/src/zope/configuration/metametaconfigurefordocgen.py:1.2	Wed Dec 25 09:13:33 2002
+++ Zope3/src/zope/configuration/metametaconfigurefordocgen.py	Fri Dec 27 18:28:33 2002
@@ -61,11 +61,16 @@
 _metadataKey = "__zope.configuration.metadataKey__"
 
 def _recordCommandMetadata(subs, description, handler=None):
-    if _metadataKey not in subs: subs[_metadataKey] = {}
+    if _metadataKey not in subs:
+        subs[_metadataKey] = {}
+
     md = subs[_metadataKey]
-    if 'attributes' not in md: md['attributes'] = {}
-    if description: md['description'] = ' '.join(description.split())
-    if handler: md['handler'] = handler
+    if 'attributes' not in md:
+        md['attributes'] = {}
+    if description:
+        md['description'] = description
+    if handler:
+        md['handler'] = handler
 
 
 class DirectiveNamespace(baseDirectiveNamespace):
@@ -74,7 +79,8 @@
     __class_implements_ = INonEmptyDirective
     __implements__ = ISubdirectiveHandler
 
-    def _Subdirective(self, *args, **kw): return Subdirective(*args, **kw)
+    def _Subdirective(self, *args, **kw):
+        return Subdirective(*args, **kw)
 
     def _useDescription(self, namespace, name, handler, description, subs):
         _recordCommandMetadata(subs, description, handler)
@@ -91,5 +97,5 @@
     def _useAttributeDescription(self, name, required, description):
         attribs = self._subs[_metadataKey]['attributes']
         attribs[name] = {
-            'description': description and ' '.join(description.split()),
+            'description': description,
             'required': required}


=== Zope3/src/zope/configuration/metametafordocgen.zcml 1.2 => 1.3 ===
--- Zope3/src/zope/configuration/metametafordocgen.zcml:1.2	Wed Dec 25 09:13:33 2002
+++ Zope3/src/zope/configuration/metametafordocgen.zcml	Fri Dec 27 18:28:33 2002
@@ -16,16 +16,18 @@
       handler="zope.configuration.metametaconfigurefordocgen.DirectiveNamespace"
       description="Define a set of new configuration directives within a
           defaultnamespace"
-  >
+      >
+
     <attribute
         name="namespace"
         required="yes"
         description="XML-style namespace identifier for the namespace
             in which the directives being defined will reside." />
+
     <subdirective
         name="directive"
         description="Define a new configuration directive."
-    >
+        >
       <attribute
           name="name"
           required="yes"
@@ -46,11 +48,15 @@
           name="description"
           description="structured Text sentences that document the
               purpose and function of the directive." />
+
+
+
+
       <subdirective
           name="attribute"
           description="Define an attribute that may be specified on the
               directive being defined"
-      >
+          >
         <attribute
             name="name"
             required="yes"
@@ -67,16 +73,31 @@
             name="description"
             description="structured Text sentences describing the purpose,
               function, and allowed values of the attribute." />
+
+        <subdirective
+            name="description"
+            description="Provide a description for the directive"
+            />
+
       </subdirective>
+
+
+      <subdirective
+          name="description"
+          description="Provide a description for the directive"
+          />
+
       <subdirective
           name="subdirective"
           description="Define a subdirective that may be used inside
               the enclosing directive in a configuration."
-      >
+          >
+
         <attribute
             name="name"
             required="yes"
             description="the name of the subdirective" />
+
         <attribute
             name="handler_method"
             description="the name of an IEmptyDirective or an
@@ -84,22 +105,26 @@
                 ISubDirectiveHandler returned by the handler for
                 the enclosing directive.  If not specified, the
                 subdirective name is used." />
+
         <attribute
             name="description"
             description="structured Text sentences that document the
                 purpose and function of the subdirective." />
+
         <attribute
             name="namespace"
             description="XML-style namespace identifier for the namespace
                 in which the directives being defined will reside.  If
                 specified it overrides the namespace inherited from
                 the enclosing directive." />
+
         <!--
              We don't need to redefine the attribute subdirective of
              the subdirective subdirective, because defining it in
              directive's namespace defined it in the same (recursive)
              namespace subdirective uses.
         -->
+
       </subdirective>
     </subdirective>
   </directive>