[Zope3-checkins] CVS: Zope3/src/zope/configuration - docutils.py:1.2

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Jan 23 12:01:02 EST 2004


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

Modified Files:
	docutils.py 
Log Message:
I had a little bug in my text wrapper. I added a doc test for it now and 
updated the generated ZCML reference.


=== Zope3/src/zope/configuration/docutils.py 1.1 => 1.2 ===
--- Zope3/src/zope/configuration/docutils.py:1.1	Thu Jan 22 18:53:15 2004
+++ Zope3/src/zope/configuration/docutils.py	Fri Jan 23 12:00:31 2004
@@ -21,7 +21,23 @@
 whitespace=re.compile('[ \t\n\r]+')
 
 def wrap(text, width=78, indent=0):
-    """ """
+    """Makes sure that we keep a line length of a certain width.
+
+    Examples:
+
+    >>> print wrap('foo bar')[:-2]
+    foo bar
+    >>> print wrap('foo bar', indent=2)[:-2]
+      foo bar
+    >>> print wrap('foo bar, more foo bar', 10)[:-2]
+    foo bar,
+    more foo
+    bar
+    >>> print wrap('foo bar, more foo bar', 10, 2)[:-2]
+      foo bar,
+      more foo
+      bar
+    """
     paras = para_sep.split(text.strip())
 
     new_paras = []
@@ -32,13 +48,13 @@
         line = []
         length = indent
         for word in words:
-            if length + len(word) + 1 <= width:
+            if length + len(word) <= width:
                 line.append(word)
                 length += len(word) + 1
             else:
                 lines.append(' '*indent + ' '.join(line))
-                line = []
-                length = indent
+                line = [word]
+                length = len(word) + 1 + indent
 
         lines.append(' '*indent + ' '.join(line))
         
@@ -48,7 +64,16 @@
 
 
 def makeDocStructures(context):
-    """ """
+    """Creates two structures that provide a friendly format for
+    documentation.
+
+    'namespaces' is a dictionary that maps namespaces to a directives
+    dictionary with the key being the name of the directive and the value is a
+    tuple: (schema, info).
+
+    'subdirs' maps a (namespace, name) pair to a list of subdirectives that
+    have the form (namespace, name, schema, info).
+    """
     namespaces = {}
     subdirs = {}
     for (namespace, name), schema, usedIn, info, parent in context._docRegistry:




More information about the Zope3-Checkins mailing list