[Checkins] SVN: manuel/trunk/ improved error message for improperly indented capture directive

Benji York benji at zope.com
Fri Mar 12 18:22:57 EST 2010


Log message for revision 109938:
  improved error message for improperly indented capture directive
  

Changed:
  U   manuel/trunk/CHANGES.txt
  U   manuel/trunk/src/manuel/capture.py
  U   manuel/trunk/src/manuel/capture.txt

-=-
Modified: manuel/trunk/CHANGES.txt
===================================================================
--- manuel/trunk/CHANGES.txt	2010-03-12 22:36:27 UTC (rev 109937)
+++ manuel/trunk/CHANGES.txt	2010-03-12 23:22:57 UTC (rev 109938)
@@ -5,6 +5,7 @@
 ------------------
 
 - fix a SyntaxError when running the tests under Python 2.5
+- improved error message for improperly indented capture directive
 
 
 1.0.5 (2010-01-29)

Modified: manuel/trunk/src/manuel/capture.py
===================================================================
--- manuel/trunk/src/manuel/capture.py	2010-03-12 22:36:27 UTC (rev 109937)
+++ manuel/trunk/src/manuel/capture.py	2010-03-12 23:22:57 UTC (rev 109938)
@@ -68,9 +68,11 @@
             if indent_matches(line):
                 break
             start = offset + 1
-        else:
-            raise RuntimeError("couldn't find the start of the block")
 
+        if start is None:
+            raise RuntimeError("couldn't find the start of the block; "
+                "improper indentation of capture directive?")
+
         _, temp_region = document.split_region(found_region,
             found_region.lineno+start)
 

Modified: manuel/trunk/src/manuel/capture.txt
===================================================================
--- manuel/trunk/src/manuel/capture.txt	2010-03-12 22:36:27 UTC (rev 109937)
+++ manuel/trunk/src/manuel/capture.txt	2010-03-12 23:22:57 UTC (rev 109938)
@@ -57,3 +57,28 @@
     >>> [r.parsed.block for r in document if r.parsed]
     ['Second level of indentation.\n\n    Third level of indentation.\n\n.. -> foo\n']
 
+
+
+Error reporting
+---------------
+
+If the capture directive is accidentally indented, a (reasonable) error will be
+generated.
+
+::
+
+    This is a block that will be captured::
+
+        Block
+
+        .. -> foo
+
+.. -> source
+
+    >>> import manuel
+    >>> document = manuel.Document(source)
+    >>> import manuel.capture
+    >>> manuel.capture.find_captures(document)
+    Traceback (most recent call last):
+        ...
+    RuntimeError: couldn't find the start of the block; improper indentation of capture directive?



More information about the checkins mailing list