scribble-code-examples
code-examples
make-code-eval
6.3.90.900

scribble-code-examples

 (require scribble-code-examples)
  package: scribble-code-examples

procedure

(code-examples #:lang language    
  #:context context    
  [#:inset? inset?    
  #:show-lang-line show-lang-line    
  #:eval evaluator]    
  examples ...)  block?
  language : string?
  context : syntax?
  inset? : boolean? = #true
  show-lang-line : (or/c boolean? pre-flow?) = #false
  evaluator : evaluator? = (make-code-eval #:lang language)
  examples : string?
A scribble examples form that works for non-s-expression languages.

For example, this:

@code-examples[#:lang "at-exp racket" #:context #'here]|{

(+ 1 2)

@+[1 3]

}|

Produces this:

>

 

(+ 1 2)

3

>

 

@+[1 3]

4

And this:

@code-examples[#:lang "at-exp racket" #:context #'here]|{

(require scribble-code-examples (for-label racket/base))

@code-examples[#:lang "at-exp racket" #:context #'here]|{

(+ 1 2)

@+[1 3]

}|

}|

Produces this:

>

 

(require scribble-code-examples (for-label racket/base))

file-exists?: `exists' access denied for /System/Library/Frameworks/Foundation.framework/Foundation.so context...: /home/racket/build-pkgs/racket/collects/ffi/../racket/private/map.rkt:113:23: loop /home/racket/build-pkgs/racket/collects/ffi/unsafe.rkt:117:0: get-ffi-lib10 /home/racket/build-pkgs/racket/collects/ffi/unsafe/nsalloc.rkt: [running body] /home/racket/build-pkgs/racket/collects/planet/private/resolver.rkt: [traversing imports]

>

 

@code-examples[#:lang "at-exp racket" #:context #'here]|{
(+ 1 2)
@+[1 3]
}|

code-examples: undefined; cannot reference an identifier before its definition in module: 'anonymous-module context...: /home/racket/build-pkgs/racket/share/pkgs/sandbox-lib/racket/sandbox.rkt:379:0: call-with-limits

procedure

(make-code-eval #:lang language)  evaluator?

  language : string?
Creates a sandbox evaluator that can be used as the #:eval argument for code-examples.

Examples:

>

 

(require scribble-code-examples)

file-exists?: `exists' access denied for /System/Library/Frameworks/Foundation.framework/Foundation.so context...: /home/racket/build-pkgs/racket/collects/ffi/../racket/private/map.rkt:113:23: loop /home/racket/build-pkgs/racket/collects/ffi/unsafe.rkt:117:0: get-ffi-lib10 /home/racket/build-pkgs/racket/collects/ffi/unsafe/nsalloc.rkt: [running body] /home/racket/build-pkgs/racket/collects/net/http-client.rkt: [traversing imports]

>

 

(define ev (make-code-eval #:lang "racket"))

make-code-eval: undefined; cannot reference an identifier before its definition in module: 'anonymous-module context...: /home/racket/build-pkgs/racket/share/pkgs/sandbox-lib/racket/sandbox.rkt:379:0: call-with-limits

>

 

(ev '(+ 1 2))

ev: undefined; cannot reference an identifier before its definition in module: 'anonymous-module context...: /home/racket/build-pkgs/racket/share/pkgs/sandbox-lib/racket/sandbox.rkt:379:0: call-with-limits

>

 

(ev "(+ 1 2)")

ev: undefined; cannot reference an identifier before its definition in module: 'anonymous-module context...: /home/racket/build-pkgs/racket/share/pkgs/sandbox-lib/racket/sandbox.rkt:379:0: call-with-limits