Literate Programming

Robert Kern robert.kern at gmail.com
Thu Apr 7 17:21:52 EDT 2011


On 4/7/11 1:09 PM, Hans Georg Schaathun wrote:
> Has anyone found a good system for literate programming in python?
>
> I have been trying to use pylit/sphinx/pdflatex to generate
> technical documentation.  The application is scientific/numerical
> programming, so discussing maths in maths syntax in between
> python syntax is important.
>
> While I like the style, there are several things which do not
> work as they should.
>
> One problem is that reST strips the indentation of code.  When
> documentation intersperses nested blocks, it would look better
> if indentation was preserved so that the semantics of the code
> is clear in the documentation.  Are there any tricks to achieve
> this in sphinx, or other systems which get it right?

http://sphinx.pocoo.org/markup/code.html

As far as I can tell, it just works. See here for an example:

http://ipython.scipy.org/doc/nightly/html/interactive/reference.html

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list