Noweb
   HOME

TheInfoList



OR:

Noweb, stylised in lowercase as noweb, is a
literate programming Literate programming is a programming paradigm introduced in 1984 by Donald Knuth in which a computer program is given as an explanation of its logic in a natural language, such as English, interspersed (embedded) with snippets of macros and t ...
tool, created in 1989–1999 by Norman Ramsey, and designed to be simple, easily extensible and language independent. As in
WEB Web most often refers to: * Spider web, a silken structure created by the animal * World Wide Web or the Web, an Internet-based hypertext system Web, WEB, or the Web may also refer to: Computing * WEB, a literate programming system created by ...
and
CWEB Web is a computer programming system created by Donald E. Knuth as the first implementation of what he called "literate programming": the idea that one could create software as works of literature, by embedding source code inside descriptive t ...
, 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 Tex may refer to: People and fictional characters * Tex (nickname), a list of people and fictional characters with the nickname * Joe Tex (1933–1982), stage name of American soul singer Joseph Arrington Jr. Entertainment * ''Tex'', the Italian ...
,
LaTeX Latex is an emulsion (stable dispersion) of polymer microparticles in water. Latexes are found in nature, but synthetic latexes are common as well. In nature, latex is found as a milky fluid found in 10% of all flowering plants (angiosperms ...
,
HTML The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScri ...
, and troff back ends and works with any programming language. Besides simplicity this is the main advantage over
WEB Web most often refers to: * Spider web, a silken structure created by the animal * World Wide Web or the Web, an Internet-based hypertext system Web, WEB, or the Web may also refer to: Computing * WEB, a literate programming system created by ...
, which needs different versions to support programming languages other than
Pascal Pascal, Pascal's or PASCAL may refer to: People and fictional characters * Pascal (given name), including a list of people with the name * Pascal (surname), including a list of people and fictional characters with the name ** Blaise Pascal, Fren ...
. (Thus the necessity of
CWEB Web is a computer programming system created by Donald E. Knuth as the first implementation of what he called "literate programming": the idea that one could create software as works of literature, by embedding source code inside descriptive t ...
, which supports C and similar languages.)


Noweb's input

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 with 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.


Example of a simple Noweb program

This is an example of a "hello world" program with documentation: \section Today I awoke and decided to write some code, so I started to write Hello World in \textsf C. <>= /* <> */ #include int main(int argc, char *argv[]) @ \noindent \ldots then I did the same in PHP. <>= > */ echo "Hello world!\n"; ?> @ \section Later the same day some lawyer reminded me about licenses. So, here it is: <>= This work is placed in the public domain. Assuming that the above code is placed in a file named 'hello.nw', the command to extract the human-readable document in
HTML The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScri ...
format is: noweave -filter l2h -index -html hello.nw , htmltoc > hello.html ... and in
LaTeX Latex is an emulsion (stable dispersion) of polymer microparticles in water. Latexes are found in nature, but synthetic latexes are common as well. In nature, latex is found as a milky fluid found in 10% of all flowering plants (angiosperms ...
format: noweave -index -latex hello.nw > hello.tex To extract machine source code: notangle -Rhello.c hello.nw > hello.c notangle -Rhello.php hello.nw > hello.php


Compatibility

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.


See also

*
WEB Web most often refers to: * Spider web, a silken structure created by the animal * World Wide Web or the Web, an Internet-based hypertext system Web, WEB, or the Web may also refer to: Computing * WEB, a literate programming system created by ...
*
CWEB Web is a computer programming system created by Donald E. Knuth as the first implementation of what he called "literate programming": the idea that one could create software as works of literature, by embedding source code inside descriptive t ...


Notes


External links

*{{Official website
Norman Ramsey's home pagenotangle online man pagenoweb.py – an open-source noweb clone written in Pythonnoweb.php – noweb clone in PHP
Free documentation generators Literate programming Troff