Literate Programming

Jim jim.hefferon at gmail.com
Sat Apr 9 12:45:55 CEST 2011


On Apr 8, 3:21 pm, Hans Georg Schaathun <h... at schaathun.net> wrote:
> Interesting tool, but it solves only part of the problem.
> I could use it as a replacement for pylit, but I would then still
> have the problem of commenting code within a block, which is a
> reST/sphinx problem.

I'm sorry; I don't understand "commenting code within a block" but I
wondered if it meant you were not fully familiar with the idea of the
web-type programs.  Instead of looking to typeset the comments, you
uses chunks.  Thus a <<main>> chunk may be something like (pyweb has
somewhat different syntax)
  <<main>>
    def main(argv=None,log=None):
      <<read command line argument>>
      <<handle options>>
      <<run driver routine>>
      <<report results>>
Before each chunk comes the description of what that chunk does.
Something like
  This routine factors $n$ finding any factors that are powers of a
prime number.
  <<run driver routine>>
    def driver(n,opt1,opt2):
      <<find square root>>
      <<factor>>
is a rough idea (here $n$ is a LaTeX; you can do HTML or RST).  So you
are commenting the chunks, which can be blocks of the code.

> Alternatively, I could use pyweb directly with LaTeX.  However, then
> I would need to find or create macro packages which provide the
> features of reST directly in LaTeX.  Do you know of a good candidate?

What features?

Jim



More information about the Python-list mailing list