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

From: Joel McCracken (mccracken.joel at gmail.com)
Date: Wed Dec 17 10:17:57 EST 2014

OK, so I've gotten a Racket that has scribble/lp2, so Yay. I can
generate documentation with the "Scribble HTML".


Do I need to do something to make `@examples` evaluate with the
current module? This is what I'm currently using that makes it work:


#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)
]


I'm not sure if lp2 includes some facility to make @examples work
without the evaluator creation.




On Tue, Dec 16, 2014 at 11:48 PM, Joel McCracken
<mccracken.joel at gmail.com> wrote:
> I'm glad there is a repository issue -- that's where I tried without
> success. I tried the build available right now (3bb896d) without
> success, but will look again tomorrow.
>
> This is the reason I think Racket is so great. You were able to create
> the lp language version 2 as an afterthought. Awesome.
>
> On Tue, Dec 16, 2014 at 3:04 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
>> ... after the next build, at least.
>>
>> Problems related to the repository split have prevented the snapshots
>> from being up-to-date for the past few days, but I'm optimistic that
>> the next snapshot will be right.
>>
>> At Tue, 16 Dec 2014 14:54:06 -0500, Matthias Felleisen wrote:
>>>
>>> You probably want the current snapshot:
>>>
>>>   http://www.cs.utah.edu/plt/snapshots/
>>>
>>>
>>>
>>>
>>> On Dec 16, 2014, at 1:28 PM, Joel McCracken <mccracken.joel at gmail.com> wrote:
>>>
>>> > Forwarding to users, since I forgot to reply-all.
>>> >
>>> >
>>> > ---------- Forwarded message ----------
>>> > From: Joel McCracken <mccracken.joel at gmail.com>
>>> > Date: Tue, Dec 16, 2014 at 1:27 PM
>>> > Subject: Re: [racket] using scribble/eval in conjunction with scribble/lp
>>> > To: Matthew Flatt <mflatt at cs.utah.edu>
>>> >
>>> >
>>> > Hmm, I'm having trouble finding this new release of Racket that will
>>> > allow a #lang scribble/lp2 -- I'll keep looking later. This is awesome
>>> > though, thank you for the prompt response!
>>> >
>>> > On Mon, Dec 15, 2014 at 8:15 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
>>> >> 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)
>>> >> ]
>>> >>
>>> > ____________________
>>> >  Racket Users list:
>>> >  http://lists.racket-lang.org/users
>>>
>>> ____________________
>>>   Racket Users list:
>>>   http://lists.racket-lang.org/users

Posted on the users mailing list.