[Doc-SIG] Unindented blocks in reStructuredText

David Goodger goodger at python.org
Sun Oct 21 15:55:07 CEST 2007

[Hrvoje Nikšić]
> I'd like my rst documents to include snippets of Python that are
> pasteable into the interpreter.
> Am I missing an option here?

You can use

    .. include:: source.py

combined with the :start-after: and :end-before: options.

> I find it surprising that a tool written in and for Python

reST is written in Python but is not specifically for Python.  It's a
general-purpose tool.  (Doctest blocks are an exception to the rule; call them a
wart if you like, an early mistake.)

> 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.)

It's an interesting idea, worth considering.  It isn't currently implemented though.

David Goodger <http://python.net/~goodger>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : http://mail.python.org/pipermail/doc-sig/attachments/20071021/144a7748/attachment.pgp 

More information about the Doc-SIG mailing list