atangle - Tools for asciidoc literate programming
The atangle program is a literate programming tool for asciidoc documents. Atangle reads file or the standard input if file is not given, extracting the literate programming chunks and writes the source code contained in those chunks to outfile or to the standard output.
In asciidoc, the markup for source code is signified by enclosing it with lines of four or more hyphens. For example,
---- proc myproc {a b} { chan puts "$a $b" } ----
So literate programming in asciidoc is somewhat different than other literate programming environments in that the literate program source is also a valid asciidoc document. The only addition is that of chunk defintions contained in otherwise normal source code markup.
Atangle looks for asciidoc source blocks that contain chunk definitions. A chunk is a name enclosed in "<<" and ">>" markers. There are both chunk definitions and chunk references. A chunk definition appends an equals sign (=) to the chunk marker. A chunk reference does not. For example,
---- <<utility procs>>= proc ut1 {b} { return [string toupper $b] } <<common procs>> ----
In this example, <<utility procs>>=, is a chunk definition and <<common procs>> is a chunk reference.
There may be multiple definitions of the same chunk. In that case, the definitions are concatenated together in the order in which they occur in the input file.
Chunks form an implied tree, where definitions of one chunk can contain references to other chunks. There is a root chunk. By default the root chunk is known as, *. The process of tangling the literate program source extracts the root chunk and recursively replaces any chunk reference with the corresponding definition.
Copyright © 2013 by G. Andrew Mangogna