Questions tagged [literate-programming]

A literate program embeds source code in an essay documenting the program.

Literate programming was introduced by Donald Knuth as an alternative to the structured programming. Literate programming encourages programmers to structure their programs by the flow of their thoughts, i.e., in a way that makes it easy to present and document.

158 questions
5
votes
1 answer

Conditional Compilation inside Literate Haskell

I have a literate haskell file and want to use conditional compilation. I use the bird style of literate programming. The following code does not work. > #if MIN_VERSION_base(4,6,0) > import Control.Exception > #endif I need a solution for cabal…
SvenK
  • 2,584
  • 2
  • 21
  • 24
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

How to import/expand noweb refs in evaluated (exported) source blocks in org-babel?

I'm trying to do something like this: * Define some functions #+begin_src python :noweb_ref defs def f1(a,b,c): return True def f2(d,e,f): return False #+end_src * Use them in a results-exported block later #+begin_src python…
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
5
votes
1 answer

How to pipe input to a src_block as stdin ?

Consider the following snippet of perl in org-babel, which uses . ** Ans 2 #+begin_src perl :results output use Math::Trig; $rad = ; $circumference = 2*pi*$rad; print "Circumference of circle is $circumference"; …
Vijayender
  • 1,545
  • 1
  • 11
  • 9
4
votes
2 answers

What's the best way to read code in CWEB format in Windows?

Donald Knuth has a large number of programs to read on his page. But they are mostly in a "strange" CWEB format... What could be the best way to make them appropriately readable in Windows?
Massimiliano
  • 16,770
  • 10
  • 69
  • 112
4
votes
3 answers

Infuriating Tab problem in Vim, in literate Haskell

I am using "Bird" style literate haskell, which requires all code to be like the following: > module Main (main) where and if I have a block it should look something like this: > main = do > args = getArgs > file = args!![0] etc. However…
4
votes
1 answer

Literate programming setup of Docker programming environment with org-mode in Emacs

I put together a small example of how I manage my development environment with Docker from within Emacs. The idea is, rather than having multiple files in folders that interrelate to each other and thus make it hard to track transitional changes, to…
CD86
  • 979
  • 10
  • 27
4
votes
0 answers

Literate Agda in Markdown format to LaTeX via Pandoc

Agda supports Markdown for literate programming input, as described here: everything outside ``` and ```agda blocks is ignored by Agda, allowing you to load the same .lagda.md files into Agda and process them with Pandoc. However, if Pandoc is used…
Cactus
  • 27,075
  • 9
  • 69
  • 149
4
votes
1 answer

How to embed markdown documentation inside a working code with C type syntax for commenting?

Basically I want to write one piece of text which qualifies both as a working code and MarkDown (preferably GitHub flavor) for documentation. The language I'm using has C form commenting \\ for rest-of-line and /* ... */ for multi line comments. So…
Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193
4
votes
0 answers

How to embed Markdown in Scala code?

I know that in Scala we have sbt plugins which allow us to execute code embedded in Markdown, plugins like tut and sbt-site. But how can we do the opposite? I would like to embed Markdown in Scala code as part of comments. E.g.: // number.sc file //…
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
0 answers

Use variable in Sweave code chunk

I am trying to write a vignette based on some example data included with my package. I want the vignette to be as robust as possible to minor changes in example dataset -- for example an id changing. What I was hoping to do is to define the ids in…
dayne
  • 7,504
  • 6
  • 38
  • 56
4
votes
1 answer

How does one reference the result of a call block in an emacs org file?

I'm using emacs org mode for reproducible research. I'm having trouble chaining the results of calls to code blocks. As a minimal example of what I'm trying to do: * Functions #+name: f1 #+begin_src elisp :var x=7 (+ x x) #+end_src #+name:…
rprospero
  • 913
  • 11
  • 26