[Checkins] SVN: manuel/trunk/s The previous commit (107715) was incorrectly labled. This change actually

Benji York benji at zope.com
Tue Jan 5 17:13:36 EST 2010


Log message for revision 107722:
  The previous commit (107715) was incorrectly labled.  This change actually
  merges in the bug fix from branches/chrism-codeblocks (with doctest based test
  instead of unittest tests)
  
  r107715 was a couple of small code tweaks and an errant test snippet that this
  change removes
  

Changed:
  U   manuel/trunk/setup.py
  U   manuel/trunk/src/manuel/bugs.txt
  U   manuel/trunk/src/manuel/codeblock.py

-=-
Modified: manuel/trunk/setup.py
===================================================================
--- manuel/trunk/setup.py	2010-01-05 20:47:28 UTC (rev 107721)
+++ manuel/trunk/setup.py	2010-01-05 22:13:36 UTC (rev 107722)
@@ -16,8 +16,7 @@
     zip_safe=False,
     author='Benji York',
     author_email='benji at benjiyork.com',
-    description=
-        'Manuel lets you build tested documentation.'
+    description= 'Manuel lets you build tested documentation.',
     license='ZPL',
     install_requires=[
         'setuptools',

Modified: manuel/trunk/src/manuel/bugs.txt
===================================================================
--- manuel/trunk/src/manuel/bugs.txt	2010-01-05 20:47:28 UTC (rev 107721)
+++ manuel/trunk/src/manuel/bugs.txt	2010-01-05 22:13:36 UTC (rev 107722)
@@ -93,9 +93,22 @@
     <BLANKLINE>
 
 
-Universal Newlines
+Code-block Options
 ------------------
 
-Manuel should open documents with universal newlines mode enabled.
+The code-block handler didn't originally allow reST options, so blocks like the
+one below would generate a syntax error during parsing.
 
-    >>> suite = manuel.testing.TestSuite(m, path_to_test)
+    .. code-block:: python
+       :linenos:
+
+       class Foo(object):
+           pass
+
+.. -> source
+
+.. code-block:: python
+
+    import manuel.codeblock
+    m = manuel.codeblock.Manuel()
+    manuel.Document(source).parse_with(m)

Modified: manuel/trunk/src/manuel/codeblock.py
===================================================================
--- manuel/trunk/src/manuel/codeblock.py	2010-01-05 20:47:28 UTC (rev 107721)
+++ manuel/trunk/src/manuel/codeblock.py	2010-01-05 22:13:36 UTC (rev 107722)
@@ -2,7 +2,9 @@
 import manuel
 import textwrap
 
-CODEBLOCK_START = re.compile(r'^\.\.\s*(invisible-)?code-block::?\s*python\b', re.MULTILINE)
+CODEBLOCK_START = re.compile(
+    r'(^\.\.\s*(invisible-)?code-block::?\s*python\b(?:\s*\:\w+\:)*)',
+    re.MULTILINE)
 CODEBLOCK_END = re.compile(r'(\n\Z|\n(?=\S))')
 
 
@@ -13,7 +15,8 @@
 
 def find_code_blocks(document):
     for region in document.find_regions(CODEBLOCK_START, CODEBLOCK_END):
-        source = textwrap.dedent('\n'.join(region.source.splitlines()[1:]))
+        start_end = CODEBLOCK_START.search(region.source).end()
+        source = textwrap.dedent(region.source[start_end:])
         source_location = '%s:%d' % (document.location, region.lineno)
         code = compile(source, source_location, 'exec', 0, True)
         document.claim_region(region)



More information about the checkins mailing list