[racket] using scribble/eval in conjunction with scribble/lp
At Mon, 15 Dec 2014 15:49:38 -0700, Matthew Flatt wrote:
> Meanwhile, I'll work on changing `scribble/lp` so that a module
> implemented with `#lang scribble/lp` can be passed directly to
> Scribble.
That turned out to be `scribble/lp2`, since the changes would be
incompatible with existing uses of `scribble/lp`.
With the development versions of the "drracket" and "scribble"
packages, and with the program below, you can click "Run" to run the
program and interact with `f`, or you can click one of the "Scribble"
buttons to render the document.
----------------------------------------
#lang scribble/lp2
@(require scribble/base
scribble/eval)
@title{An Example}
This would be a @bold{wonderful} way to accomplish things!
@chunk[<*>
(define (f x)
<f-body>)]
@chunk[<f-body>
(* x x)]
And then, I could show an example:
@(begin
(require syntax/location)
(define here (quote-source-file))
(define evaluator (make-base-eval))
(evaluator `(begin
(dynamic-require '(file ,here) #f)
(current-namespace
(module->namespace '(file ,here))))))
@examples[
#:eval evaluator
(f 10)
]