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
4
votes
1 answer

How to hide block of code

I'm writing a program in a .lhs file which contains code in Haskell (I'm specifying this because I want it to be clear that it's not only for rendering a pdf but it's also for being execute with runhaskell or ghci). I'm rendering the code with…
Jcao02
  • 794
  • 8
  • 24
4
votes
3 answers

Intuitive motivation for Literate Programming?

So, I used the scribble/lp module to write my first literate program using plt-scheme: #lang scribble/lp (require scribble/lp) <> @chunk[ (define (f x) (* x x))] Nothing useful there, of course. Now…
user59634
4
votes
0 answers

HTML anchor in noweb style literate programming by org-mode

This is my simple C source code in org-mode. #+name: hello_one.c #+begin_src C :noweb tangle :tangle hello_one.c #include int main() { printf("Hello, world!\n"); reurn 0; } #+end_src Maybe I can break this whole thing into many…
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
3
votes
1 answer

Literate Programming with rust and org mode

So I am trying to use rust in org mode, and it works fine after installing ob-rs and cargo-script. But the problem is, I can't figure out how to use other crates(like rand) from the source code blocks. I tried just converting the main project into a…
Ayush Singh
  • 1,409
  • 3
  • 19
  • 31
3
votes
1 answer

F# Literate pass arguments to script file

I am using F# Formatting to do some Literate programming. My use case is that I have a couple of hundred data sets that I need to run through, and for each I want to create a "report" of some statistics and plots. They are all of the same format. So…
UmaN
  • 905
  • 1
  • 15
  • 29
3
votes
1 answer

Emacs polymode for Markdown and Python

I use the python3 pweave library (http://mpastell.com/pweave/usage.html) for literate programming. pweave uses as text mode markdown, as code mode python3, and it is possible to use noweb (https://en.wikipedia.org/wiki/Noweb) literate programming…
bue
  • 333
  • 2
  • 12
3
votes
1 answer

"$" symbol in a code chunk of noweb (literate programming) file

I have following javascript code inside a code chunk of a noweb (i.e., .nw) file: <>= $("span").tooltip({ tip: 'tooltip', predelay: 30, delay: 3000, onShow: function(){} }); @ The generated javascript code is correct. But…
3
votes
1 answer

Show tangled file name in org mode code block export

I am doing literate programming in Emacs org mode. When I do the Latex export to a pdf, I would like the name of the file the code gets tangled to to be displayed by each code block. I can't find a suitable header argument in the manual. Here is…
8n8
  • 1,233
  • 1
  • 8
  • 21
3
votes
0 answers

Alternative approach to reproducible research where source code is the primary medium

TL;DR: The common dynamic document (IPython notebook style) approach to reproducible research usually does not result in reusable source code modules. Are there tools/approaches that use the source code as the primary medium and include text within…
3
votes
2 answers

No instance for (GHC.Base.Alternative Parser) error running Literate Haskell code

I'm trying to execute examples in Graham Hutton's Programming in Haskell book (http://www.cs.nott.ac.uk/~gmh/book.html). Even though the examples are in literate haskell, I could launch ghci to load the examples; for example ghci cipher.lhs…
prosseek
  • 182,215
  • 215
  • 566
  • 871
3
votes
1 answer

Literate programming in multiple languages

I've a library project which requires C's interoperability with other languages, and reasonable performance, but must be documented very clearly, à la literate programming, and whose documentation might benefit from a functional approach, like…
Jeff Burdges
  • 4,204
  • 23
  • 46
3
votes
2 answers

How to include code excerpts using tags in asciidoc?

I can include the full Greet.java file public class Greet { public static void main(String[] args) { System.out.println("Hello World!"); } } from within the asciidoc file == Hello Java This is how one greets in…
Calaf
  • 10,113
  • 15
  • 57
  • 120
3
votes
2 answers

R code in Sweave

I have a scientific paper under review, and a referee asked for my R code to be provided as a Sweave document. I've never heard of Sweave before, do you know what's the better way to do it? Thanks a lot :-)
Federico Giorgi
  • 10,495
  • 9
  • 42
  • 56
3
votes
1 answer

org-mode File Specific Functions

I am working on a literate program in org-mode. I have couple of functions in my .emacs that I use to setup a repl for the program, is it possible to move these functions to the org-mode file and they are evaluated every time the file is opened…
Hamza Yerlikaya
  • 49,047
  • 44
  • 147
  • 241