| 1 |
LeMock Developer Notes |
| 2 |
|
| 3 |
|
| 4 |
LeMock is implemented in Lua 5.1, but its source code is written as |
| 5 |
literate documents, and usees the tool noweb to generate the .lua files. |
| 6 |
The distributed source archive includes all the tangled files in the build |
| 7 |
directory, to avoid dependending on noweb for installation. |
| 8 |
|
| 9 |
The source is contained in the src directory in the form of literate |
| 10 |
documents. To extract (tangle) the final files from the sources, the tool |
| 11 |
[noweb http://www.cs.tufts.edu/~nr/noweb/] is needed. |
| 12 |
|
| 13 |
The source files are meant to be tangled together all at once, because the |
| 14 |
contents of a target file can be spread over several source files. The |
| 15 |
target files are all the chunk names that are roots. These can be found |
| 16 |
with noroots in the noweb toolbox. To automate the tangle process, there is |
| 17 |
a custom script named autotangle in the tools directory. This script finds |
| 18 |
all the target file names and tangles them in the current directory, |
| 19 |
creating subdirectories as needed. The script is written for yet another |
| 20 |
obscure tool, [rc http://www.libra-aries-books.co.uk/software/rc] [1]. It |
| 21 |
is probably easy to port the short rc script to your favourit language. It |
| 22 |
is invoked (in rc syntax) as: |
| 23 |
|
| 24 |
``` ../tools/autotangle `{find ../src -name '*.nw'} |
| 25 |
|
| 26 |
which means it wants all (recursively) .nw files in the src directory as |
| 27 |
arguments. |
| 28 |
|
| 29 |
The documentation is written in [txt2tags http://txt2tags.sourceforge.net/], |
| 30 |
which can generate HTML among many other formats. The README, HISTORY, |
| 31 |
COPYRIGHT, and this DEVEL text file are written as simple txt2tags |
| 32 |
documents to remain readable as is. The .nw source files define wrapper |
| 33 |
txt2tags documents for the web pages, which use txt2tags' include mechanism |
| 34 |
to include the actual txt2tags files. The user guide is defined in the .nw |
| 35 |
sources as a separate txt2tags document, so it can be easily generated as a |
| 36 |
LaTeX document or Unix man page, but it too is included in a wrapper |
| 37 |
txt2tags document when generating the web pages. |
| 38 |
|
| 39 |
The building of the web pages is done with |
| 40 |
[mk http://en.wikipedia.org/wiki/Mk_%28software%29], a Unix port of the |
| 41 |
Plan9 make tool. (The mk files uses rc syntax.) |
| 42 |
|
| 43 |
A set of unit tests (defined in the .nw source) can be run with |
| 44 |
[lunit http://www.nessie.de/mroth/lunit/index.html] with the command: |
| 45 |
|
| 46 |
``` lunit unit/*.lua |
| 47 |
|
| 48 |
A program like [luacov http://luacov.luaforge.net/] can be used to check |
| 49 |
the coverage of the unit tests. |
| 50 |
|
| 51 |
|
| 52 |
-------------------- |
| 53 |
== Footnotes == |
| 54 |
: [1] |
| 55 |
I use Byron's Unix port, which syntax is extended and incompatible with |
| 56 |
the original (and other ports). |
| 57 |
: |