[racket] using scribble/eval in conjunction with scribble/lp

From: Benjamin Greenman (blg59 at cornell.edu)
Date: Sun Dec 14 16:46:08 EST 2014

I tried and failed to figure this out. In particular, when I create the
example "lp.rkt" file described at the top of the scribble/lp docs and
require it "in the normal manner", the identifier f is unbound for me.

The code I'm using is pasted below:

;; lp.rkt
#lang scribble/lp

Literate programs have chunks of code, like this one:

@chunk[<f>
       (define (f x)
         <fs-body>)]

and this one:

@chunk[<fs-body>
       (* x x)]

that, when assembled, produce a complete program, in this case:

@racketblock[(define (f x)
               (* x x))]

-----

;; lp-test.rkt
#lang racket
(require "lp.rkt")
(f 3) ;; Error!



On Sun, Dec 14, 2014 at 2:24 AM, Joel McCracken <mccracken.joel at gmail.com>
wrote:
>
> I'm trying to create a document that includes code, describes that
> code, includes example usage, and exports some of the bindings so that
> it may be included later.
>
> I've been looking at the scribble documentation, and it seems like all
> this should be possible. I can't seem to figure out how to actually
> run examples. Here's what I have:
>
> #lang scribble/lp
>
> @(require scribble/eval)
>
> This would be a wonderful way to accomplish things!
>
> @chunk[*
>         (define (f x)
>           <f-body>)]
>
> @chunk[<f-body>
>         (* x x)]
>
>
> And then, I could show an example:
>
> @examples[
>         (f 10)
> ]
>
>
> Any advice would be really appreciated.
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20141214/743969cc/attachment.html>

Posted on the users mailing list.