[racket] Scribble question

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Jun 30 17:02:46 EDT 2010

At Wed, 30 Jun 2010 15:21:19 -0400 (EDT), Hari Prashanth wrote:
> I have a function by name map. For its documentation, I have
> something like
> 
> @defproc[(map ...) (...)]{
> @scheme[map] is similar to @scheme[map]
> }
> 
> The want the latter @scheme[map] to refer map provided by lists.
> 
> How can I do that? Can someone help me out with this?

The simplest solution is to create a new module:

 ;; other.rkt:
 #lang at-exp racket/base
 (require scribble/manual
          (for-label racket/base))

 (define racket-map @racket[map])
 (provide racket-map)

And use it like this:

 #lang scribble/manual
 @(require (for-label lang/htdp-intermediate)
           "other.rkt")

 The ISL @racket[map] is similar to Racket's @|racket-map|.

If you want everything in one module, you can play a trick with
macro-introduced imports:

 #lang scribble/manual
 @(require (for-label lang/htdp-intermediate))

 @(begin
   (define-syntax-rule (def racket-map)
     (begin
       (require (for-label racket/base))
       (define racket-map @racket[map])))
   (def racket-map))

 The ISL @racket[map] is similar to Racket's @|racket-map|.

There should be a better way to do this --- maybe a macro that packages
up the macro-introduced-import trick.




Posted on the users mailing list.