[Doc-SIG] Unindented blocks in reStructuredText

Hrvoje Nikšić hniksic at gmail.com
Sun Oct 21 11:30:17 CEST 2007


I'd like my rst documents to include snippets of Python that are
pasteable into the interpreter.  Something like:

This text demonstrates creation of a class::

class Foo(object):
    pass

Unfortunately, rst2html warns about "Literal block expected; none
found" and doesn't create a literal block.

If I indent the Python block by any amount of spaces, everything works
-- but then I can no longer paste the example into Python.  Of course,
I can generate the HTML, and paste the code from the browser into
Python, but that makes it much harder to debug Python examples while
writing the documentation.

Am I missing an option here?  I find it surprising that a tool written in
and for Python would make it hard to include valid Python code.  To
clarify my expectations, I'd expect something (approximately) like
this to work:

This text demonstrates creation of a class::

class Foo(object):
    pass
..

(The ".." could mark the end of the block.)


More information about the Doc-SIG mailing list