Noweb

Noweb is a " literate programming" tool, developed in the years 1989-1999 by Norman Ramsey. Design goals were simplicity, ease of extensibility, and language independence.

As in WEB and CWEB are the main components of noweb two programs: " notangle ", which is extracted from the sources ' Maschinen' source code, and " noweave " that produces formatted printable documents.

Noweb supports TeX, LaTeX, HTML, and troff backend and works with any programming language. Besides simplicity, this is the main advantage over WEB, which requires different versions to support other programming languages ​​as Pascal. (Hence CWEB was necessary that supports C and similar languages. )

Nowebs input

A noweb input text contains program source code interrupted by documentation. It is made of so-called chunks that are either documentation chunks or code chunks.

A documentation chunk starts with a line that starts with an at sign (@ ) followed by a space bar or a line feed. A documentation chunk has no name. Documentation Chunk usually contain LaTeX, but you can also use HTML, simple TeX or troff.

Code chunks are benamt. A code chunk begins with

Chunk << name >> = on a separate line. The double left angle bracket (<< ) should be in the first column.

Each chunk is terminated by the start of the next chunk. If the first line of a file does not mark the beginning of a chunk, it is ausgegenagen that it is the first line of a documentation chunk.

Code chunks are not treated specially by the tools of noweb; they can be placed in any order and, if necessary, joined together in the correct order. Chunk references in the code are dissolved and extracted all the desired source.

Example of a simple noweb program

This is the example of a simple "hello world" - the program with documentation:

\ section { Hello world }   Today I woke up and decided to code. So I started with a Hello World in \ textsf C.   hello.c << >> = / *     license << >> * / # include   int main (int argc, char * argv [ ]) {     printf ("Hello World \ n " );     return 0; } @ \ noindent \ ldots Then I did the same thing in PHP. hello.php << >> = >    * /    echo "Hello world \ n";? > @ \ section { License } Then I remembered my lawyer on the license. So, here it is:   = << license >>               Copyright ( C) 2012 William Smith This program is free software: you can redistribute it and / or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License Either, or any later version. This program is distributed in the hope it will be useful did, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. shouldhave received a copy of the GNU General Public License along with this program. If not, see Suppose the above code is in a file called hello.nw, then the command to extract it to a human readable document in HTML format:

Htmltoc adds a table of contents ( "table of content" ).

Noweave index latex hello.nw > hello.tex

To extract the source:

First, the C code:

Notangle - Rhello.c hello.nw > hello.c

Then ... PHP:

Notangle - Rhello.php hello.nw > hello.php

And now the whole thing in HTML:

Hello world < / h1 >

programs < / h2 >

Today I woke up and decided to code. So I started with a Hello World in C.   hello.c << >> = / *     license << >> * / # include   int main (int argc, char * argv [ ]) {     printf ("Hello World \ n " );     return 0; } @

Then I did the same thing in PHP. hello.php << >> = >    * /    echo "Hello world \ n";? > @

License < / h2 >

Then remembered my lawyer on the license. So, here it is:   = << license >>               Copyright ( C) 2012 William Smith This program is free software: you can redistribute it and / or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License Either, or any later version. This program is distributed in the hope it will be useful did, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. shouldhave received a copy of the GNU General Public License along with this program. If not, see Extract HTML ( and contents produce ) by

Compatibility

Noweb specifies a particular file format and a file probably nested three different formats ( noweb, LaTeX and the programming language used ). This is not understood by other software development tools and, consequently, excludes the use of noweb the use of UML or code documentation tools out.

610258
de