views:

185

answers:

2

I'm trying to find a good literate programming tool. Let's just say it's not an easy decision. (The generic ones are too generic and the specific ones are too specific :) )

Among others, I've got noweb up and running but I'm having trouble getting output like I'd expect. The noweb wikipedia page has a minimal example that builds correctly with

noweave -index -latex hello.noweb > hello.tex && pdflatex hello && pdflatex hello

but there are no cross-references at the end of each chunk. For example, CWEB has pointers such as "This code is used in section 12." and "See also sections 5 and 7." Is this feature simply missing from noweb or am I missing a step in the compilation?

+1  A: 

You should get, for that WP example, a reference to the license section from each of the two chunks in the Hello World section. You won't get any lists of chunks or identifiers at the end unless you tell latex about them.

To get a list of web chunks, try putting \nowebchunks near the end of the document (i.e., after the last chunk appears), and adding a -x switch to the noweb invocation.

To get a list of identifiers, try putting \nowebindex in a similar place.

Charles Stewart
+2  A: 

Is this feature simply missing from noweb or am I missing a step in the compilation?

Neither: noweb uses much more subtle markers than you are used to seeing from CWEB. In the case of the Wikipedia example, the 3rd chunk (1c) appears in chunks 1a and 1b. This information is condensed into a single '1', which appears in parentheses at the right hand side of the definition.

To get long cross-references in the CWEB style use

\noweboptions{longxref}
Norman Ramsey
Thanks for the help, Norman. Am I right in thinking the workflow from here is to run `noweave -x -n -latex hello.nw > hello.tex` on the source and then `\input` the resulting file into a driver document containing the relevant `\noweboptions` and invocations?
Will Robertson
Aha, or use the `-delay` option. Okay, this is now going very well indeed. Thanks for the great tool!
Will Robertson
@Will: You've got the idea. Your workflow depends on whether you're going "one document is one source file" or "one document is composed from many source files".
Norman Ramsey