- Noweb
noweb is a free
literate programming tool,created in 1989-1999 by Norman Ramsey [http://www.eecs.harvard.edu/~nr/index.html] ,and designed to be simple, easily extensible and language independent.Like in
WEB andCWEB 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 'out of the box' supports
TeX ,LaTeX ,HTML , andtroff back ends and works with any programming language.Besides simplicity this is the main advantage overWEB , whichneeds different versions to support programming languagesother than Pascal.(Thus the necessity ofCWEB , which supports C andsimilar languages.)Noweb's input
A noweb input text contains program source code interleaved with documentation.It consists of so-called "chunks" that areeither "code-chunks" or "documentation-chunks".
It uses
LaTeX code for "documentation chunks", but you mayeasily use any form you like."Code chunks" aren't treated speciallyby noweb's tools - they may be placed in any orderand when needed, they are just concatenated,chunk-references in code are dereferenced andthe whole requested source code is extracted.
Example of a simple noweb program
This is an example of a hello-world program(s) with documentation:
@ section{Hello world} Today I awakened and decided to write some code, so I started to write a Hello World in extsf C. <
>= /* < > */ #include int main(int argc, char *argv [] ) { printf("Hello World! "); return 0; } @ oindent ldots then I did the same in PHP. < >= > */ echo "Hello world! "; ?> @ section{License} Later, 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.noweb',the command to extract the human-readable document in
HTML format is:noweave -filter l2h -index -html hello.noweb | htmltoc > hello.html
... and in
LaTeX format:noweave -index -latex hello.noweb > hello.tex
To extract machine source code:
notangle -Rhello.c hello.noweb > hello.c
notangle -Rhello.php hello.noweb > hello.php
See also
*
WEB
*CWEB External links
* [http://www.eecs.harvard.edu/~nr/noweb/ Noweb home page]
* [http://www.eecs.harvard.edu/~nr/index.html Norman Ramsey's home page]
* [http://www.cs.virginia.edu/cgi-bin/manpage?section=1&topic=notangle notangle online man page]
Wikimedia Foundation. 2010.