Literate programming keeps code and its (extensive) documentation in a single source file. The documentation is typically typeset with TeX or LaTeX. Tools are used to extract the code (for compilations) and the documentation (for processing with (La)TeX) from the source file.

Literate programming was promoted by Donald Knuth who developed TeX (and most of his other software) as a literate program. His original tools where specifically tailored for the programming languages he used but more recent literate programming systems are often language agnostic. Within the TeX.SE community, Sweave is the best-known literate programming system that combines LaTeX and R code.

Traditionally, the process of extracting code from a literate program is called tangling and extracting (La)TeX code is called weaving.

history | excerpt history