[Zope-dev] patterns for using sphinx with the Zope Toolkit?

Benji York benji at zope.com
Sun Jan 3 16:08:46 EST 2010


On Sat, Jan 2, 2010 at 8:44 PM, Chris McDonough <chrism at plope.com> wrote:
> Python samples in Sphinx docs are generated like so:
>
> .. code-block:: python
>
>     a == 1
>
> I did a bit of fooling around with Manuel, because I wanted to make sure that
> the code blocks in my documentation actually worked, but I wound up in a place
> where I use Manuel to check only the *syntax* of a subets of the Sphinx code
> blocks I use.  It will do this right out of the box if you read the Manuel docs
>  But I couldn't really figure out a way to do the moral equivalent of this:
>
> .. code-block:: python
>
>    a == 1
>
> .. manuel-expect:
>
>    True

Sphinx and Manuel both support interpreter blocks, so the normal
approach will work:

    >>> a == 1
    True

Occasionally you want to show some code but hide the assertions about
the effects of the code.  You can do that by putting the tests in a reST
comment after the code.

.. code-block:: python

    a = Foo()
    b = a.bar()

.. make sure the above worked correctly

    >>> b.baz
    42
-- 
Benji York


More information about the Zope-Dev mailing list