Literate Programming is a term coined by Donald E. Knuth to describe a mechanism he devised for weaving both code and its documentation into the same document. For Knuth, the primary content is the documentation, with the program implementation just being one particular example of what is described in the documentation. Many variations on the original concept of literate programming have been undertaken. Those that utilize some tool to separate the program code from the surrounding documentation are closest in spirit to the original idea. Approaches in which the master content is the program, and documentation is extracted from annotations within code comments, have proven more popular than the literate programming method where the documentation is the master, or at least, is on equal footing with the program code.
Dynamic languages like Tcl afford other possiblities, such as ycl::proc::checkargs, in which the documentation for a procedure is written in such a way that it is used at runtime to decide how to process the arguments to a procedure.
See Source Documentation Tools
AM: has some experience using Will Duquette's "expand" for the purpose of intermixing test code with explanatory descriptions. The idea was elegant (IMHO), but requires more elaboration. (Wondering if this will turn into pet project #53 or not ;)
YOSIFOV: New Tcl based, very small (StartPack) LP tool (not for WiKi, but for any programming language: generates flexible document and any number of source code files. Documentation/program (as usual in LP) is one file, like article, where programmer use special markup-commands, all other (references, TOC, index, so on) are generated automatically. Project home is here: http://code.google.com/p/tclp/