Incremental definition and evaluation of examples in Scribble

The scribble/eval library provides utilities for evaluating code at document-build time and incorporating the results in the document, especially to show example uses of defined procedures and syntax.

Here is an example where the OP was:

trying to figure out a way to insert some text in between Scheme definitions: that is, have some definitions (@schemeblock or equivalent), with their explanations (text mode), and then an interaction, like @interaction, except that it should be aware of the preceeding definitions.

Here is the solution:

#lang scribble/manual
@(require scribble/eval)
@(define ex-eval (make-base-eval))
First, we define @scheme[x]:
@interaction[
#:eval ex-eval
(define x 1)
]
Next, we use it:
@interaction[
#:eval ex-eval
x
]
@(close-eval ex-eval)

(via plt)

One thought on “Incremental definition and evaluation of examples in Scribble”

Leave a Reply

Your email address will not be published. Required fields are marked *