[Checkins] SVN: manuel/trunk/src/manuel/ incorporate some feedback from Jim
Benji York
benji at zope.com
Tue Jun 23 08:05:48 EDT 2009
Log message for revision 101248:
incorporate some feedback from Jim
Changed:
U manuel/trunk/src/manuel/codeblock.py
U manuel/trunk/src/manuel/codeblock.txt
U manuel/trunk/src/manuel/footnote.txt
U manuel/trunk/src/manuel/table-example.txt
-=-
Modified: manuel/trunk/src/manuel/codeblock.py
===================================================================
--- manuel/trunk/src/manuel/codeblock.py 2009-06-23 08:08:11 UTC (rev 101247)
+++ manuel/trunk/src/manuel/codeblock.py 2009-06-23 12:05:48 UTC (rev 101248)
@@ -2,7 +2,7 @@
import manuel
import textwrap
-CODEBLOCK_START = re.compile(r'^\.\.\s*code-block::?\s*python\b', re.MULTILINE)
+CODEBLOCK_START = re.compile(r'^\.\.\s*(invisible-)?code-block::\s*python\b', re.MULTILINE)
CODEBLOCK_END = re.compile(r'(\n\Z|\n(?=\S))')
Modified: manuel/trunk/src/manuel/codeblock.txt
===================================================================
--- manuel/trunk/src/manuel/codeblock.txt 2009-06-23 08:08:11 UTC (rev 101247)
+++ manuel/trunk/src/manuel/codeblock.txt 2009-06-23 12:05:48 UTC (rev 101248)
@@ -5,8 +5,8 @@
`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
+provide a `"code-block" directive <http://sphinx.pocoo.org/markup/code.html>`_,
+which 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"::
@@ -60,12 +60,14 @@
.. code-block:: python
- document = manuel.Document("""\
.. code-block:: python
-
+
print does_not_exist
- """)
+.. -> source
+
+ >>> document = manuel.Document(source, location='fake.txt')
+
.. the document above was specially formulated to have nothing before or after
the code-block
@@ -76,7 +78,6 @@
...that error will be reported:
- >>> m = manuel.codeblock.Manuel()
>>> document.process_with(m, globs={})
Traceback (most recent call last):
...
@@ -87,8 +88,8 @@
particular block.
-Commented-out Blocks
---------------------
+Invisible Code Blocks
+---------------------
At times you'll want to have a block of code that is executed but not displayed
in the rendered document (like some setup for later examples).
@@ -96,26 +97,27 @@
When using doctest's native format (">>>") that's easy to do, you just put the
code in a reST comment, like so:
-.. ignore-next-block
-
::
.. this is some setup, it is hidden in a reST comment
- >>> do_something()
- >>> do_something_else()
+ >>> a = 5
+ >>> b = a + 3
However, if you want to include a relatively large chunk of Python, you'd
rather use a code-block, but that means that it will be included in the
rendered document. Instead, :mod:`manuel.codeblock` also understands a variant
of the code-block directive (".. code-block:: python") that is actually a reST
-comment: ".. code-block:python" (note the single colon)::
+comment: ".. invisible-code-block:: python" (note the single colon)::
- .. code-block: python
+ .. invisible-code-block:: python
- do_something()
- do_something_else()
+ a = 5
+ b = a + 3
-.. warning:: It would be very easy to confuse the "real" code-block directive
- with the it's-really-a-reSt-comment form. Perhaps a more distinct syntax
- will be introduced in the future.
+.. -> source
+
+ >>> import manuel
+ >>> document = manuel.Document(source)
+ >>> document.process_with(m, globs={})
+ >>> print document.formatted()
Modified: manuel/trunk/src/manuel/footnote.txt
===================================================================
--- manuel/trunk/src/manuel/footnote.txt 2009-06-23 08:08:11 UTC (rev 101247)
+++ manuel/trunk/src/manuel/footnote.txt 2009-06-23 12:05:48 UTC (rev 101248)
@@ -6,7 +6,7 @@
The :mod:`manuel.footnote` module provides an implementation of reST footnote
handling, but instead of just plain text, the footnotes can contain any syntax
-Manuel can interpred including doctests.
+Manuel can interpret including doctests.
>>> import manuel.footnote
>>> m = manuel.footnote.Manuel()
Modified: manuel/trunk/src/manuel/table-example.txt
===================================================================
--- manuel/trunk/src/manuel/table-example.txt 2009-06-23 08:08:11 UTC (rev 101247)
+++ manuel/trunk/src/manuel/table-example.txt 2009-06-23 12:05:48 UTC (rev 101248)
@@ -321,7 +321,7 @@
.. this next bit is actually a reST comment, but it is run during tests anyway
(note the single colon instead of double colon)
-.. code-block: python
+.. invisible-code-block:: python
import unittest
suite = manuel.testing.TestSuite(m, 'table-example.txt')
More information about the Checkins
mailing list