Author: | Norman Ramsey |
Latest Release Version: | 2.12 |
Latest Release Date: | [1] |
Programming Language: | C, AWK, and Icon |
Operating System: | Cross-platform |
Language: | English |
Genre: | Literate programming |
License: | BSD-2-Clause license |
Noweb, stylised in lowercase as noweb, is a literate programming tool, created in 1989–1999 by Norman Ramsey, and designed to be simple, easily extensible and language independent.[2] [3]
As in WEB and CWEB, the main components of Noweb are two programs: "notangle", which extracts 'machine' source code from the source texts, and "noweave", which produces nicely-formatted printable documentation.
Noweb supports TeX, LaTeX, HTML, and troff back ends and works with any programming language. Besides simplicity this is the main advantage over WEB, which needs different versions to support programming languages other than Pascal. (Thus the necessity of CWEB, which supports C and similar languages.)
A Noweb input text contains program source code interleaved with documentation. It consists of so-called chunks that are either documentation chunks or code chunks.
A documentation chunk begins with a line that starts with an at sign (@) followed by a space or newline. A documentation chunk has no name. Documentation chunks normally contain LaTeX, but Noweb is also used with HTML, plain TeX, and troff.
Code chunks are named. A code chunk begins with
<
on a line by itself. The double left angle bracket (<<) must be in the first column.
Each chunk is terminated by the beginning of another chunk. If the first line in the file does not mark the beginning of a chunk, it is assumed to be the first line of a documentation chunk.
Code chunks aren't treated specially by Noweb's tools—they may be placed in any order and, when needed, they are just concatenated. Chunk references in code are dereferenced and the whole requested source code is extracted.
This is an example of a "hello world" program with documentation:
Today I awoke and decided to writesome code, so I started to write Hello World in \textsf C.
<
int main(int argc, char *argv[]) @\noindent \ldots then I did the same in PHP.
<
<
... and in LaTeX format:
To extract machine source code:
Noweb defines a specific file format and a file is likely to interleave three different formats (Noweb, LaTeX and the language used for the software). This is not recognised by other software development tools and consequently using Noweb excludes the use of UML or code documentation tools.