NOWEB(1) | General Commands Manual | NOWEB(1) |
notangle, noweave, nountangle - noweb, a literate-programming tool
notangle [-Rrootname ...] [-filter command]
[-L[format]] [file] ...
nountangle
[-ml|-m3|-c|-c++|-awk|-tex|-f77|-f90|-lisp|-matlab]
[-Rrootname ...] [-filter command] [-wwidth] [file] ...
noweave [options] [file] ...
Noweb is a literate-programming tool like Knuth's WEB, only simpler. A noweb file contains program source code interleaved with documentation. When notangle is given a noweb file, it writes the program on standard output. When noweave is given a noweb file, it reads the noweb source and produces, on standard output, LaTeX, TeX, troff, or HTML source for typeset documentation. nountangle converts a literate program into an ordinary program by turning interleaved documentation into comments. The file name `-' refers to standard input.
A noweb file is a sequence of chunks, which may
appear in any order. A chunk may contain code or documentation.
Documentation chunks begin with a line that starts with an at sign (@)
followed by a space or newline. They have no names. Code chunks begin with
<<chunk name>>=
on a line by itself. The double left angle bracket (<<) must be in the
first column. Chunks are terminated by the beginning of another chunk, or by
end of file. 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.
Documentation chunks contain text that is ignored by notangle and copied verbatim to standard output by noweave (except for quoted code). noweave can work with LaTeX, plain TeX, troff or HTML. With plain TeX, it inserts a reference to a TeX macro package, nwmac, which defines commands like \chapter and \section.
Code chunks contain program source code and references to other code chunks. Several code chunks may have the same name; notangle concatenates their definitions to produce a single chunk, just as does tangle(1). Code chunk definitions are like macro definitions; notangle extracts a program by expanding one chunk (by default, the chunk named <<*>>). The definition of that chunk contains references to other chunks, which are themselves expanded, and so on. notangle's output is readable; it preserves the indentation of expanded chunks with respect to the chunks in which they appear.
Code may be quoted within documentation chunks by placing double square brackets ([[...]]) around it. These double square brackets are ignored by notangle, but they may be used by noweave to give the code special typographic treatment, e.g., hypertext links. If quoted code ends with three or more square brackets, noweave chooses the rightmost pair, so that, for example, [[a[i]]] is parsed correctly. The names of code chunks may appear within quoted code unless that quoted code is itself part of the name of a code chunk.
In code, noweb treats unpaired double left or right angle brackets as literal << and >>. To force any such brackets, even paired brackets or brackets in documentation, to be treated as literal, use a preceding at sign (e.g. @<<).
Some programming or formatting languages may require a single @ sign in the first column. Noweb users may achieve this effect by putting a doubled @@ in the first column; in this position only, it stands for a single @ sign.
notangle and nountangle accept the same set of options, although some options have effects only on one or the other. The options are:
C -L'#line %L "%F"%N'
Sun FORTRAN -L'\# %L "%F"%N'
Icon -L'#line %-1L "%F"%N'
Modula-3 -L'<*LINE %L "%F" *>%N'
SML/NJ -L'(*#line %L "%F"*)'
Output from noweave can be used in TeX documents that \input nwmac, in LaTeX documents that use the noweb package (see nowebstyle(1)), and in HTML documents to be browsed with Mosaic(1). Noweave treats code chunks somewhat like LaTeX list environments. If the ``@ '' that terminates a code chunk is followed immediately by text, that text follows the code chunk without a paragraph break. If the rest of the line is blank, noweave puts TeX into ``vertical mode,'' and later text starts a fresh, indented paragraph.
No page breaks occur in the middle of code chunks unless necessary to avoid an overfull vbox. The documentation chunk immediately preceding a code chunk appears on the same page as that code chunk unless doing so would violate the previous rule.
Noweave inserts no extra newlines in its TeX output, so the line numbers given in TeX error messages are the same as those in the input file.
noweave has options that dictate choice of formatter and that support different formatting idioms and tools. Basic options are described here; options related to index and cross-reference information are described in the INDEXING AND CROSS-REFERENCE section.
When used with LaTeX, troff, or HTML, noweave can provide indexing and cross-reference information for chunks and for programming-language identifiers. Identifier definitions may be marked by hand using backticks (`); the -filter btdefn option recognizes these markings. For some languages, definitions may be found automatically using the -autodefs option. This section describes the indexing and cross-reference options; it might well be skipped on first reading.
If notangle or noweave encounters a chunk name within documentation, it assumes that this indicates an error, usually misspelling ``<<name>>=''. Other error messages should be self-explanatory.
It is incorrect to refer to a chunk that is never defined, but it is OK for chunks to be defined and not used.
If you have trouble digesting this man page, you're not alone. Here are a few examples to get you started. I'll assume you have a foo.nw file with a C program in chunk <<foo.c>> and a header file in chunk <<foo.h>>, and that your documentation is marked up using latex(1). I'll show you how to build things using the most common options.
To rebuild your C source, try
To build a printed document, run
To build a web page, run
/usr/lib/noweb/markup markup preprocessor /usr/lib/noweb/unmarkup inverts markup /usr/lib/noweb/nt notangle proper /usr/lib/noweb/finduses find uses of identifiers for index /usr/lib/noweb/noidx generate index and cross-reference info /usr/lib/noweb/toroff back end to emit troff /usr/lib/noweb/totex back end to emit TeX or LaTeX /usr/lib/noweb/tohtml back end to emit HTML /usr/share/texmf/tex/plain/misc/nwmac.tex formatting TeX macros /usr/share/texmf/tex/plain/misc/noweb.sty use in LaTeX documents; see nowebstyle(7)
cpif(1), nodefs(1), noroots(1), noweb(1), noindex(1), noroff(1), nowebstyle(7), nowebfilters(7)
notangle and nountangle fail if names used on the command line contain single quotes.
Ignoring unused chunks can cause problems; if a chunk has multiple definitions and one is misspelled, the misspelled definition is silently ignored. noroots(1) can be used to catch this mistake.
The -L option of notangle puts an implicit initial newline in the format string.
The default LaTeX pagestyles don't set the width of the boxes containing headers and footers. Since noweb code paragraphs are extra wide, this LaTeX bug sometimes results in extra-wide headers and footers. The remedy is to redefine the relevant ps@* commands; ps@noweb in noweb.sty can be used as an example.
latex2html(1) mangles some source files.
noweave has too many options, and this man page is too long.
This man page is from noweb version 2.12.
Norman Ramsey, Tufts University. Internet address
Norman.Ramsey@tufts.edu.
Noweb home page at http://www.cs.tufts.edu/~nr/noweb.
local 10/40/2008 |