[Checkins] SVN: manuel/trunk/src/manuel/ (basic) documentation of the code-block handler

Benji York benji at zope.com
Mon Jun 8 22:41:48 EDT 2009


Log message for revision 100752:
  (basic) documentation of the code-block handler
  

Changed:
  A   manuel/trunk/src/manuel/code-block.txt
  U   manuel/trunk/src/manuel/tests.py

-=-
Added: manuel/trunk/src/manuel/code-block.txt
===================================================================
--- manuel/trunk/src/manuel/code-block.txt	                        (rev 0)
+++ manuel/trunk/src/manuel/code-block.txt	2009-06-09 02:41:48 UTC (rev 100752)
@@ -0,0 +1,44 @@
+Code blocks
+===========
+
+`Sphinx <http://sphinx.pocoo.org/>`_ and other docutils `extensions
+<http://docutils.sourceforge.net/sandbox/code-block-directive/docs/syntax-highlight.html>`_
+provide a `"code-block" directive <http://sphinx.pocoo.org/markup/code.html>`_
+allows inlined snippets of code in `reST
+<http://docutils.sourceforge.net/rst.html>`_ documents.
+
+For example a block of Python would be prefixed with ".. code-block:: python"::
+
+    .. code-block:: python
+
+        print 'hello'
+
+The manuel.codeblock module provides the ability to execute the contents of
+Python code-blocks.
+
+    >>> import manuel.codeblock
+    >>> m = manuel.codeblock.Manuel()
+
+Let's create a reST document with a code block.
+
+    >>> document = manuel.Document("""
+    ... Here is a code-block:
+    ...
+    ... .. code-block:: python
+    ...
+    ...     x = 'hello'
+    ...
+    ... A little prose to separate the examples.
+    ...
+    ...     >>> print x
+    ...     hello
+    ...     
+    ... """)
+
+Since the above document mixes code-blocks and doctests, we'll mix in the
+doctest handler.
+
+    >>> import manuel.doctest
+    >>> m.extend(manuel.doctest.Manuel())
+    >>> document.process_with(m, globs={})
+    >>> print document.formatted()


Property changes on: manuel/trunk/src/manuel/code-block.txt
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: manuel/trunk/src/manuel/tests.py
===================================================================
--- manuel/trunk/src/manuel/tests.py	2009-06-08 17:52:30 UTC (rev 100751)
+++ manuel/trunk/src/manuel/tests.py	2009-06-09 02:41:48 UTC (rev 100752)
@@ -16,7 +16,7 @@
         ])
     suite = unittest.TestSuite()
 
-    tests = ['README.txt', 'footnote.txt', 'bugs.txt']
+    tests = ['README.txt', 'footnote.txt', 'bugs.txt', 'code-block.txt']
 
     # Run the tests once with doctest.
     suite.addTest(
@@ -29,5 +29,6 @@
     # Run the table example with doctest plus the codeblock extension.
     m = manuel.doctest.Manuel(optionflags=optionflags, checker=checker)
     m.extend(manuel.codeblock.Manuel())
-    suite.addTest(manuel.testing.TestSuite(m, 'table-example.txt'))
+    suite.addTest(manuel.testing.TestSuite(
+        m, 'table-example.txt'))
     return suite



More information about the Checkins mailing list