Questions tagged [noweb]

noweb is a literate programming tool for a variety of languages.

noweb is a literate programming tool written by Norman Ramsey which works for a variety of programming languages. It is a modern alternative to programs like Knuth's CWEB.

noweb takes a single specially formatted file, and generates both code and documentation; in this sense, it is kind of like the reverse of a Javadoc - instead of embedding documentation inside code, noweb embeds code inside documentation. Since "chunks" of code are named, code can even be reordered and repeated.

The documentation parts can be in LaTeX or HTML so that printed output or web pages can be generated from noweb input. noweb is language independent, so it can process any programming language (since noweb respects indentation, it can even process languages like Python and Haskell, and produce valid output).

See Nweb's Home Page for more information and downloads; Wikipedia contains a good example of what noweb's format looks like and how to generate code and documentation from it.

This tag should be used for questions about how to use the noweb program.

35 questions
46
votes
7 answers

What's the best way to do literate programming in Python on Windows?

I've been playing with various ways of doing literate programming in Python. I like noweb, but I have two main problems with it: first, it is hard to build on Windows, where I spend about half my development time; and second, it requires me to…
JasonFruit
  • 7,764
  • 5
  • 46
  • 61
11
votes
5 answers

Emacs, R, Org-mode: how to enable automatic switch to ESS-mode within R code blocks?

When using R code chunks in an .Rnw document, the emacs buffer automatically detects that the cursor is within a code chunk (i.e. within <<>> and @), and switches to ESS-mode -- this is very valuable because one can get ESS-based code-formatting…
Prasad Chalasani
  • 19,912
  • 7
  • 51
  • 73
7
votes
1 answer

Sweave,R,Beamer : How to convert the LaTex text in an Rnw file to R comments?

Say I have a .Rnw file containing the usual LaTex mixed in with R code chunks. (I'm especially interested in converting a .Rnw slides document, but this question applies to any .Rnw document). Now I want to convert this to a file which contains all…
Prasad Chalasani
  • 19,912
  • 7
  • 51
  • 73
7
votes
1 answer

Has anyone tried literate programming for C#, with Lyx and noweb

I came across this blog post yesterday, and it once again made me want to give literate programming a try. Has anyone else tried doing literate programming for C#? I'm wondering about trying Lyx + noweb, but wondered if you might have other…
Benjol
  • 63,995
  • 54
  • 186
  • 268
6
votes
1 answer

Documenting C or C++ code with noweb and LaTeX

I am using noweb to document my C++ and C code. In the pdf file (generated after weaving and using pdflatex) some of the code is slightly off: >> and << turn into proper opening and closing guillemets; -- turns into an n-dash. My weaving command…
user1812457
5
votes
1 answer

Set default arguments to Sweave code chunk

I am using cacheSweave with a large LaTeX Sweave document. Rather than put <>= ...snip... @ in almost all of my code chunks, I would rather have cache=true be the default, and use <>= ...snip... @ when I don't want a code…
David Robinson
  • 77,383
  • 16
  • 167
  • 187
5
votes
3 answers

Code chunk fontification in Emacs noweb mode?

In noweb mode, I would like to make the doc chunks and code chunks easier to distinguish. I'm already using font-lock-mode, but it applies the same face to strings in R and strings in tex, so doesn't distinguish the code and doc chunks very…
Kevin Wright
  • 2,397
  • 22
  • 29
5
votes
2 answers

Minimal noweb example with cross referencing

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…
Will Robertson
  • 62,540
  • 32
  • 99
  • 117
5
votes
2 answers

Using noweb on a large Java project

Has anyone used the noweb literate programming tool on a large Java project, where several source code files must be generated in different subdirectories? How did you manage this with noweb? Are there any resources and/or best practices out there?
lindelof
  • 34,556
  • 31
  • 99
  • 140
4
votes
1 answer

Org-Mode: call the noweb insertion from the noweb insertion

a and b -- python functions, c -- simple noweb insertion to python source-blocks, and d -- noweb insertion to function with noweb insertion. Function c -- is working, but function d -- not, because python trying execute insertions but this is…
4
votes
1 answer

Emacs org mode: how to create literate programs with noweb syntax

I am trying to create this Perl program: #!/usr/bin/perl use strict; use warnings; open(my $fh, "<", "test.txt") or die "cannot open < file name: $!"; while (my $line = <$fh>) { print $line; } close($fh); I created this org…
user4035
  • 22,508
  • 11
  • 59
  • 94
4
votes
1 answer

missing chunk names in knitr tangled R code

When using Stangle on a Sweave document, the output includes a comment that gives the chunk name. This is incredibly useful in a teaching setting to orient students in the code as they cut-and-paste. However, when I use knitr to generate the .R…
seandavi
  • 2,818
  • 4
  • 25
  • 52
3
votes
1 answer

FIXED: emacs:org-babel: noweb reference expand with an surplus line

When noweb reference in org-mode 's source code block is expanded, ever the content of the reference consists of only one line, it will expand the reference with an surplus line. This is an example: The source block is : #+srcname: test …
astropeak
  • 147
  • 1
  • 8
3
votes
1 answer

Noweb does not cross-reference Perl identifiers delimited on the left by @

Consider this Noweb source file named quux.nw: \documentclass{article} \usepackage{noweb} \usepackage[colorlinks]{hyperref} \begin{document} <>= my @foo ; my $bar ; my %baz ; @ %def foo bar baz \end{document} and compiled using the…
MetaEd
  • 3,753
  • 1
  • 28
  • 30
3
votes
1 answer

How to create hyperlinks for noweb references in org-mode

I'm wondering if there is a way to add hyperlinks to noweb references, i.e., in the following org-mode snippet: #+name: list-all #+begin_src sh ls -a #+end_src and we come here #+begin_src sh :noweb no-export :tangle myscript.sh echo "Hello…
margolari
  • 651
  • 3
  • 11
1
2 3