{"size": 1891, "ext": "scrbl", "max_stars_repo_path": "scribble-code-examples/scribblings/scribble-code-examples.scrbl", "max_stars_repo_name": "AlexKnauth/scribble-code-examples", "max_stars_repo_stars_event_min_datetime": "2018-01-27T18:26:13.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-21T09:35:03.000Z", "max_issues_repo_path": "scribble-code-examples/scribblings/scribble-code-examples.scrbl", "max_issues_repo_name": "AlexKnauth/scribble-code-examples", "max_issues_repo_issues_event_min_datetime": "2015-05-13T02:41:03.000Z", "max_issues_repo_issues_event_max_datetime": "2019-02-07T01:21:13.000Z", "max_forks_repo_path": "scribble-code-examples/scribblings/scribble-code-examples.scrbl", "max_forks_repo_name": "AlexKnauth/scribble-code-examples", "max_forks_repo_forks_event_min_datetime": "2015-05-13T04:01:36.000Z", "max_forks_repo_forks_event_max_datetime": "2019-02-02T01:02:33.000Z"}
{"max_stars_count": 6, "max_issues_count": 10, "max_forks_count": 4, "avg_line_length": 25.904109589, "max_line_length": 90, "alphanum_fraction": 0.5875198308}
#lang scribble/manual

@(require scribble-code-examples
          (for-label scribble-code-examples
                     racket/base
                     racket/contract/base
                     scribble/decode
                     scribble/core
                     ))

@title{scribble-code-examples}

source code: @url["https://github.com/AlexKnauth/scribble-code-examples"]

@defmodule[scribble-code-examples]

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

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

And this:
@verbatim|{
@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:
@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]
}|
}|
}

@defproc[(make-code-eval [#:lang language string?]) evaluator?]{
Creates a sandbox evaluator that can be used as the @racket[#:eval]
argument for @racket[code-examples].

Examples:
@code-examples[#:lang "racket" #:context #'here]{
(require scribble-code-examples)
(define ev (make-code-eval #:lang "racket"))
(ev '(+ 1 2))
(ev "(+ 1 2)")
}
}

