From 742843af7b3ac29dd1a32bb9213d859ab69a5074 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Wed, 30 Mar 2011 12:57:10 -0600 Subject: [PATCH] Scribble: change the way `racketblock' etc. indent/inset works - introduce 'code-inset style for nested blocks - use style instead of spaces for code indentation - sigplanconf adds vertical space around 'code-inset - more ...0 variants to compose better original commit: bbc5533938b1dac8f14005210fa9fe552dfa7e8c --- collects/scribble/eval.rkt | 228 +++++++++++--------- collects/scribble/html-render.rkt | 10 +- collects/scribble/latex-render.rkt | 3 +- collects/scribble/private/manual-code.rkt | 16 +- collects/scribble/private/manual-scheme.rkt | 51 +++-- collects/scribble/scribble.css | 8 + collects/scribble/scribble.tex | 8 +- collects/scribble/sigplan/style.tex | 8 + collects/scribblings/scribble/base.scrbl | 5 +- collects/scribblings/scribble/core.scrbl | 3 + collects/scribblings/scribble/eval.scrbl | 10 + collects/scribblings/scribble/manual.scrbl | 37 +++- collects/scribblings/scribble/srcdoc.scrbl | 16 +- 13 files changed, 253 insertions(+), 150 deletions(-) diff --git a/collects/scribble/eval.rkt b/collects/scribble/eval.rkt index 1d9d1c57..006e57af 100644 --- a/collects/scribble/eval.rkt +++ b/collects/scribble/eval.rkt @@ -13,9 +13,11 @@ (for-syntax racket/base)) (provide interaction + interaction0 interaction-eval interaction-eval-show racketblock+eval (rename-out [racketblock+eval schemeblock+eval]) + racketblock0+eval racketmod+eval (rename-out [racketmod+eval schememod+eval]) def+int defs+int @@ -68,14 +70,12 @@ (if (= 1 (length s)) (make-paragraph (list - (hspace 2) (literal-string style (car s)))) (make-table #f (map (lambda (s) (list (make-flow (list (make-paragraph (list - (hspace 2) (literal-string style s))))))) s)))))))))) @@ -88,13 +88,11 @@ (define (add-line line-accum flow-accum) (if line-accum (cons (make-paragraph - (cons - (hspace 2) - (map (lambda (s) - (if (string? s) - (literal-string style s) - s)) - (reverse line-accum)))) + (map (lambda (s) + (if (string? s) + (literal-string style s) + s)) + (reverse line-accum))) flow-accum) flow-accum)) (let loop ([string-accum #f] [line-accum #f] [flow-accum null]) @@ -123,65 +121,76 @@ (loop #f (cons v (or (add-string string-accum line-accum) null)) flow-accum)])))) - (define (interleave title expr-paras val-list+outputs) - (make-table - #f - (append - (if title (list (list (make-flow (list title)))) null) - (let loop ([expr-paras expr-paras] - [val-list+outputs val-list+outputs] - [first? #t]) - (if (null? expr-paras) - null - (append - (list (list (let ([p (car expr-paras)]) - (if (flow? p) - p - (make-flow (list p)))))) - (format-output (cadar val-list+outputs) output-color) - (format-output (caddar val-list+outputs) error-color) - (cond - [(string? (caar val-list+outputs)) - ;; Error result case: - (map - (lambda (s) - (car (format-output s error-color))) - (filter - (lambda (s) (not (equal? s ""))) - (let sloop ([s (caar val-list+outputs)]) - (apply - append - (map (lambda (s) - (if ((string-length s) . > . maxlen) - ;; break the error message into multiple lines: - (let loop ([pos (sub1 maxlen)]) - (cond - [(zero? pos) (cons (substring s 0 maxlen) - (sloop (substring s maxlen)))] - [(char-whitespace? (string-ref s pos)) - (cons (substring s 0 pos) - (sloop (substring s (add1 pos))))] - [else (loop (sub1 pos))])) - (list s))) - (regexp-split #rx"\n" s))))))] - [(box? (caar val-list+outputs)) - ;; Output witten to a port - (format-output-stream (unbox (caar val-list+outputs)) result-color)] - [else - ;; Normal result case: - (let ([val-list (caar val-list+outputs)]) - (if (equal? val-list (list (void))) - null - (map (lambda (v) - (list (make-flow (list (make-paragraph - (list - (hspace 2) - (elem #:style result-color - (to-element/no-color v #:expr? (print-as-expression))))))))) - val-list)))]) - (loop (cdr expr-paras) - (cdr val-list+outputs) - #f))))))) + (define (interleave inset? title expr-paras val-list+outputs) + (let ([lines + (let loop ([expr-paras expr-paras] + [val-list+outputs val-list+outputs] + [first? #t]) + (if (null? expr-paras) + null + (append + (list (list (let ([p (car expr-paras)]) + (if (flow? p) + p + (make-flow (list p)))))) + (format-output (cadar val-list+outputs) output-color) + (format-output (caddar val-list+outputs) error-color) + (cond + [(string? (caar val-list+outputs)) + ;; Error result case: + (map + (lambda (s) + (car (format-output s error-color))) + (filter + (lambda (s) (not (equal? s ""))) + (let sloop ([s (caar val-list+outputs)]) + (apply + append + (map (lambda (s) + (if ((string-length s) . > . maxlen) + ;; break the error message into multiple lines: + (let loop ([pos (sub1 maxlen)]) + (cond + [(zero? pos) (cons (substring s 0 maxlen) + (sloop (substring s maxlen)))] + [(char-whitespace? (string-ref s pos)) + (cons (substring s 0 pos) + (sloop (substring s (add1 pos))))] + [else (loop (sub1 pos))])) + (list s))) + (regexp-split #rx"\n" s))))))] + [(box? (caar val-list+outputs)) + ;; Output witten to a port + (format-output-stream (unbox (caar val-list+outputs)) result-color)] + [else + ;; Normal result case: + (let ([val-list (caar val-list+outputs)]) + (if (equal? val-list (list (void))) + null + (map (lambda (v) + (list (make-flow (list (make-paragraph + (list + (elem #:style result-color + (to-element/no-color v #:expr? (print-as-expression))))))))) + val-list)))]) + (loop (cdr expr-paras) + (cdr val-list+outputs) + #f))))]) + (if inset? + (let ([p (code-inset (make-table #f lines))]) + (if title + (make-table + #f + (list + (list (make-flow (list title))) + (list (make-flow (list p))))) + p)) + (make-table #f + (append + (if title + (list (list (make-flow (list title)))) + null) + lines))))) ;; extracts from a datum or syntax object --- while keeping the ;; syntax-objectness of the original intact, instead of always @@ -428,46 +437,52 @@ (define-syntax racketinput* (syntax-rules (eval:alts code:comment) - [(_ (code:comment . rest)) (racketblock (code:comment . rest))] + [(_ (code:comment . rest)) (racketblock0 (code:comment . rest))] [(_ (eval:alts a b)) (racketinput* a)] - [(_ e) (racketinput e)])) + [(_ e) (racketinput0 e)])) - (define-code racketblock+line (to-paragraph/prefix (hspace 2) - (hspace 2) - (list " "))) + (define-code racketblock0+line (to-paragraph/prefix "" "" (list " "))) (define-syntax (racketdefinput* stx) (syntax-case stx (define define-values define-struct) [(_ (define . rest)) (syntax-case stx () - [(_ e) #'(racketblock+line e)])] + [(_ e) #'(racketblock0+line e)])] [(_ (define-values . rest)) (syntax-case stx () - [(_ e) #'(racketblock+line e)])] + [(_ e) #'(racketblock0+line e)])] [(_ (define-struct . rest)) (syntax-case stx () - [(_ e) #'(racketblock+line e)])] + [(_ e) #'(racketblock0+line e)])] [(_ (code:line (define . rest) . rest2)) (syntax-case stx () - [(_ e) #'(racketblock+line e)])] + [(_ e) #'(racketblock0+line e)])] [(_ e) #'(racketinput* e)])) - (define (do-titled-interaction ev t shows evals) - (interleave t + (define (do-titled-interaction inset? ev t shows evals) + (interleave inset? + t shows (map (do-eval ev) evals))) (define-syntax titled-interaction (syntax-rules () - [(_ #:eval ev t racketinput* e ...) - (do-titled-interaction ev t (list (racketinput* e) ...) (list (quote-expr e) ...))] - [(_ t racketinput* e ...) - (titled-interaction #:eval (make-base-eval) t racketinput* e ...)])) + [(_ inset? #:eval ev t racketinput* e ...) + (do-titled-interaction inset? ev t (list (racketinput* e) ...) (list (quote-expr e) ...))] + [(_ inset? t racketinput* e ...) + (titled-interaction inset? #:eval (make-base-eval) t racketinput* e ...)])) + + (define (code-inset p) + (make-blockquote 'code-inset (list p))) (define-syntax interaction (syntax-rules () - [(_ #:eval ev e ...) (titled-interaction #:eval ev #f racketinput* e ...)] - [(_ e ...) (titled-interaction #f racketinput* e ...)])) + [(_ e ...) (code-inset (interaction0 e ...))])) + + (define-syntax interaction0 + (syntax-rules () + [(_ #:eval ev e ...) (titled-interaction #f #:eval ev #f racketinput* e ...)] + [(_ e ...) (titled-interaction #f #f racketinput* e ...)])) (define-syntax racketblock+eval (syntax-rules () @@ -479,6 +494,16 @@ [(_ e ...) (racketblock+eval #:eval (make-base-eval) e ...)])) + (define-syntax racketblock0+eval + (syntax-rules () + [(_ #:eval ev e ...) + (let ([eva ev]) + (#%expression + (begin (interaction-eval #:eval eva e) ... + (racketblock0 e ...))))] + [(_ e ...) + (racketblock0+eval #:eval (make-base-eval) e ...)])) + (define-syntax racketmod+eval (syntax-rules () [(_ #:eval ev name e ...) @@ -493,9 +518,9 @@ (syntax-rules () [(_ #:eval ev def e ...) (let ([eva ev]) - (column (list (racketblock+eval #:eval eva def) + (column (list (racketblock0+eval #:eval eva def) blank-line - (interaction #:eval eva e ...))))] + (interaction0 #:eval eva e ...))))] [(_ def e ...) (def+int #:eval (make-base-eval) def e ...)])) @@ -503,9 +528,9 @@ (syntax-rules () [(_ #:eval ev [def ...] e ...) (let ([eva ev]) - (column (list (racketblock+eval #:eval eva def ...) + (column (list (racketblock0+eval #:eval eva def ...) blank-line - (interaction #:eval eva e ...))))] + (interaction0 #:eval eva e ...))))] [(_ [def ...] e ...) (defs+int #:eval (make-base-eval) [def ...] e ...)])) @@ -522,35 +547,36 @@ (define-syntax examples (syntax-rules () [(_ #:eval ev e ...) - (titled-interaction #:eval ev (pick-example-title e ...) racketinput* e ...)] + (titled-interaction #t #:eval ev (pick-example-title e ...) racketinput* e ...)] [(_ e ...) - (titled-interaction (pick-example-title e ...) racketinput* e ...)])) + (titled-interaction #t (pick-example-title e ...) racketinput* e ...)])) (define-syntax examples* (syntax-rules () [(_ #:eval ev example-title e ...) - (titled-interaction #:eval ev example-title racketinput* e ...)] + (titled-interaction #t #:eval ev example-title racketinput* e ...)] [(_ example-title e ...) - (titled-interaction example-title racketinput* e ...)])) + (titled-interaction #t example-title racketinput* e ...)])) (define-syntax defexamples (syntax-rules () [(_ #:eval ev e ...) - (titled-interaction #:eval ev (pick-example-title e ...) racketdefinput* e ...)] + (titled-interaction #t #:eval ev (pick-example-title e ...) racketdefinput* e ...)] [(_ e ...) - (titled-interaction (pick-example-title e ...) racketdefinput* e ...)])) + (titled-interaction #t (pick-example-title e ...) racketdefinput* e ...)])) (define-syntax defexamples* (syntax-rules () [(_ #:eval ev example-title e ...) - (titled-interaction #:eval ev example-title racketdefinput* e ...)] + (titled-interaction #t #:eval ev example-title racketdefinput* e ...)] [(_ example-title e ...) - (titled-interaction example-title racketdefinput* e ...)])) + (titled-interaction #t example-title racketdefinput* e ...)])) (define blank-line (make-paragraph (list 'nbsp))) (define (column l) - (make-table #f (map - (lambda (t) - (list (make-flow (list t)))) - l))) + (code-inset + (make-table #f (map + (lambda (t) + (list (make-flow (list t)))) + l)))) (define (do-splice l) (cond diff --git a/collects/scribble/html-render.rkt b/collects/scribble/html-render.rkt index d92f5a9d..bd1527ba 100644 --- a/collects/scribble/html-render.rkt +++ b/collects/scribble/html-render.rkt @@ -1254,10 +1254,12 @@ (define/override (render-nested-flow t part ri) `((blockquote [,@(style->attribs (nested-flow-style t)) - ,@(if (and (not (string? (style-name (nested-flow-style t)))) - (not (eq? 'inset (style-name (nested-flow-style t))))) - `([class "SubFlow"]) - null)] + ,@(if (eq? 'code-inset (style-name (nested-flow-style t))) + `([class "SCodeFlow"]) + (if (and (not (string? (style-name (nested-flow-style t)))) + (not (eq? 'inset (style-name (nested-flow-style t))))) + `([class "SubFlow"]) + null))] ,@(append-map (lambda (i) (render-block i part ri #f)) (nested-flow-blocks t))))) diff --git a/collects/scribble/latex-render.rkt b/collects/scribble/latex-render.rkt index c95ca7a3..3b22c210 100644 --- a/collects/scribble/latex-render.rkt +++ b/collects/scribble/latex-render.rkt @@ -550,7 +550,8 @@ (define/private (do-render-nested-flow t part ri single-column?) (let* ([kind (or (let ([s (style-name (nested-flow-style t))]) (or (and (string? s) s) - (and (eq? s 'inset) "quote"))) + (and (eq? s 'inset) "quote") + (and (eq? s 'code-inset) "SCodeFlow"))) "Subflow")] [props (style-properties (nested-flow-style t))] [command? (memq 'command props)] diff --git a/collects/scribble/private/manual-code.rkt b/collects/scribble/private/manual-code.rkt index 6c083517..8eb052b4 100644 --- a/collects/scribble/private/manual-code.rkt +++ b/collects/scribble/private/manual-code.rkt @@ -5,19 +5,21 @@ "../core.rkt" "../base.rkt" "manual-scheme.rkt" + scribble/core (for-syntax racket/base syntax/parse)) (provide codeblock + codeblock0 typeset-code) -(define-syntax (codeblock stx) +(define-for-syntax (do-codeblock stx) (syntax-parse stx [(_ (~seq (~or (~optional (~seq #:expand expand-expr:expr) #:defaults ([expand-expr #'#f]) #:name "#:expand keyword") (~optional (~seq #:indent indent-expr:expr) - #:defaults ([indent-expr #'2]) + #:defaults ([indent-expr #'0]) #:name "#:expand keyword") (~optional (~seq #:keep-lang-line? keep-lang-line?-expr:expr) #:defaults ([keep-lang-line?-expr #'#t]) @@ -38,6 +40,12 @@ #`#'#,(car (syntax-e v)))) #'#f)))])) +(define (code-inset p) + (make-nested-flow (make-style 'code-inset '()) (list p))) + +(define-syntax (codeblock stx) #`(code-inset #,(do-codeblock stx))) +(define-syntax (codeblock0 stx) (do-codeblock stx)) + (define (typeset-code #:context [context #f] #:expand [expand #f] #:indent [indent 2] @@ -199,7 +207,9 @@ (define (make-line accum-line) (list (paragraph omitable (cons indent-elem (reverse accum-line))))) - (define indent-elem (hspace indent-amt)) + (define indent-elem (if (zero? indent-amt) + "" + (hspace indent-amt))) (let loop ([l l] [accum-line null]) (cond [(null? l) (if (null? accum-line) diff --git a/collects/scribble/private/manual-scheme.rkt b/collects/scribble/private/manual-scheme.rkt index c9cea903..e2d7f600 100644 --- a/collects/scribble/private/manual-scheme.rkt +++ b/collects/scribble/private/manual-scheme.rkt @@ -15,8 +15,10 @@ racketresultblock racketresultblock0 RACKETRESULTBLOCK RACKETRESULTBLOCK0 racketblockelem - racketinput RACKETINPUT - racketmod + racketinput RACKETINPUT + racketinput0 RACKETINPUT0 + racketmod + racketmod0 racket RACKET racket/form racketresult racketid racketmodname racketmodlink indexed-racket @@ -42,11 +44,16 @@ [racketlink schemelink])) (define-code racketblock0 to-paragraph) -(define-code racketblock (to-paragraph/prefix (hspace 2) (hspace 2) "")) -(define-code RACKETBLOCK (to-paragraph/prefix (hspace 2) (hspace 2) "") - UNSYNTAX) +(define-code racketblock to-block-paragraph) +(define-code RACKETBLOCK to-block-paragraph UNSYNTAX) (define-code RACKETBLOCK0 to-paragraph UNSYNTAX) +(define (code-inset b) + (make-blockquote 'code-inset (list b))) + +(define (to-block-paragraph v) + (code-inset (to-paragraph v))) + (define (to-result-paragraph v) (to-paragraph v #:color? #f @@ -67,19 +74,22 @@ (define-code RACKETRESULTBLOCK0 to-result-paragraph UNSYNTAX) (define interaction-prompt (make-element 'tt (list "> " ))) -(define-code racketinput - (to-paragraph/prefix - (make-element #f (list (hspace 2) interaction-prompt)) - (hspace 4) - "")) -(define-code RACKETINPUT - (to-paragraph/prefix - (make-element #f (list (hspace 2) interaction-prompt)) - (hspace 4) - "") - UNSYNTAX) +(define-code racketinput to-input-paragraph/inset) +(define-code RACKETINPUT to-input-paragraph/inset) +(define-code racketinput0 to-input-paragraph) +(define-code RACKETINPUT0 to-input-paragraph) -(define-syntax (racketmod stx) +(define to-input-paragraph + (to-paragraph/prefix + (make-element #f interaction-prompt) + (hspace 2) + "")) + +(define to-input-paragraph/inset + (lambda (v) + (code-inset (to-input-paragraph v)))) + +(define-syntax (racketmod0 stx) (syntax-case stx () [(_ #:file filename lang rest ...) (with-syntax ([modtag (datum->syntax @@ -99,9 +109,12 @@ (filebox filename #,(syntax/loc stx (racketblock0 modtag rest ...)))) - (syntax/loc stx (racketblock modtag rest ...))))] + (syntax/loc stx (racketblock0 modtag rest ...))))] [(_ lang rest ...) - (syntax/loc stx (racketmod #:file #f lang rest ...))])) + (syntax/loc stx (racketmod0 #:file #f lang rest ...))])) + +(define-syntax-rule (racketmod rest ...) + (code-inset (racketmod0 rest ...))) (define (to-element/result s) (make-element result-color (list (to-element/no-color s)))) diff --git a/collects/scribble/scribble.css b/collects/scribble/scribble.css index 1e38f357..dcd7bde9 100644 --- a/collects/scribble/scribble.css +++ b/collects/scribble/scribble.css @@ -359,6 +359,14 @@ ol ol ol ol { list-style-type: upper-alpha; } i { } +.SCodeFlow { + display: block; + margin-left: 1em; + margin-bottom: 0em; + margin-right: 0em; + margin-top: 0em; +} + .SubFlow { display: block; margin: 0em; diff --git a/collects/scribble/scribble.tex b/collects/scribble/scribble.tex index cbfbddb6..e9affd92 100644 --- a/collects/scribble/scribble.tex +++ b/collects/scribble/scribble.tex @@ -74,6 +74,7 @@ \newcommand{\atItemizeStart}[0]{\addtolength{\stabLeft}{\labelsep} \addtolength{\stabLeft}{\labelwidth}} + % For a single-column table in simple environments, it's better to % use the `list' environment instead of `stabular'. \newenvironment{SingleColumn}{\begin{list}{}{\topsep=0pt\partopsep=0pt% @@ -92,7 +93,12 @@ \listparindent=0pt\itemindent=0pt\labelwidth=0pt\leftmargin=0pt\rightmargin=0pt% \itemsep=0pt}\item}{\end{list}} -% The 'inset neested-flow style uses the `quote' environment +% The 'inset nested-flow style uses the `quote' environment + +% Indent a 'code-inset nested flow: +\newenvironment{SCodeFlow}{\begin{list}{}{\topsep=0pt\partopsep=0pt% +\listparindent=0pt\itemindent=0pt\labelwidth=0pt\leftmargin=2ex\rightmargin=0pt% +\itemsep=0pt\parsep=0pt}\item}{\end{list}} % The 'compact itemization style: \newenvironment{compact}{\begin{itemize}}{\end{itemize}} diff --git a/collects/scribble/sigplan/style.tex b/collects/scribble/sigplan/style.tex index 39f4f6b9..65966ba2 100644 --- a/collects/scribble/sigplan/style.tex +++ b/collects/scribble/sigplan/style.tex @@ -18,3 +18,11 @@ \renewcommand{\SCategoryPlus}[4]{\category{#1}{#2}{#3}[#4]} \renewcommand{\STerms}[1]{\terms{#1}} \renewcommand{\SKeywords}[1]{\keywords{#1}} + +% Add space around code insets: +% Indent a 'code-inset nested flow: +\newcommand{\SCodePreSkip}{\vskip\medskipamount} +\newcommand{\SCodePostSkip}{\vskip\medskipamount} +\renewenvironment{SCodeFlow}{\SCodePreSkip\begin{list}{}{\topsep=0pt\partopsep=0pt% +\listparindent=0pt\itemindent=0pt\labelwidth=0pt\leftmargin=2ex\rightmargin=0pt% +\itemsep=0pt\parsep=0pt}\item}{\end{list}\SCodePostSkip} diff --git a/collects/scribblings/scribble/base.scrbl b/collects/scribblings/scribble/base.scrbl index 41ad4c03..95a39c1f 100644 --- a/collects/scribblings/scribble/base.scrbl +++ b/collects/scribblings/scribble/base.scrbl @@ -159,8 +159,9 @@ address-harvesting robots.} @racket[pre-flow] (i.e., parsed with @racket[decode-flow]). The @racket[style] argument is handled the same as @racket[para]. - The @racket['inset] style causes the nested flow to be inset compared - to surrounding text.} + The @racket['inset] and @racket['code-inset] styles cause the nested + flow to be inset compared to surrounding text, with the latter + particularly intended for insetting code.} @defproc[(centered [pre-flow pre-flow?] ...) nested-flow?]{ diff --git a/collects/scribblings/scribble/core.scrbl b/collects/scribblings/scribble/core.scrbl index 9b072f0a..72c2ab94 100644 --- a/collects/scribblings/scribble/core.scrbl +++ b/collects/scribblings/scribble/core.scrbl @@ -540,6 +540,9 @@ names are recognized: @item{@racket['inset] --- Insets the nested flow relative to surrounding text.} + @item{@racket['code-inset] --- Insets the nested flow relative to + surrounding text in a way suitable for code.} + ] The following @tech{style properties} are currently recognized: diff --git a/collects/scribblings/scribble/eval.scrbl b/collects/scribblings/scribble/eval.scrbl index 302d8ffd..68f7cc79 100644 --- a/collects/scribblings/scribble/eval.scrbl +++ b/collects/scribblings/scribble/eval.scrbl @@ -47,6 +47,10 @@ If a @racket[datum] has the form expect-datum))], then both @svar[eval-datum] and @svar[check-datum] are evaluated, and an error is raised if they are not @racket[equal?].} +@defform*[[(interaction0 datum ...) + (interaction0 #:eval eval-expr datum ...)]]{ +Like @racket[interaction], but without insetting the code via +@racket[nested].} @defform*[[(interaction-eval datum) (interaction-eval #:eval eval-expr datum)]]{ @@ -68,6 +72,12 @@ the printed form of the evaluation result.} Combines @racket[racketblock] and @racket[interaction-eval].} +@defform*[[(racketblock0+eval datum ...) + (racketblock0+eval #:eval eval-expr datum ...)]]{ + +Combines @racket[racketblock0] and @racket[interaction-eval].} + + @defform*[[(racketmod+eval name datum ...) (racketmod+eval #:eval eval-expr name datum ...)]]{ diff --git a/collects/scribblings/scribble/manual.scrbl b/collects/scribblings/scribble/manual.scrbl index 776e858f..6cd220e9 100644 --- a/collects/scribblings/scribble/manual.scrbl +++ b/collects/scribblings/scribble/manual.scrbl @@ -42,13 +42,16 @@ includes a @racket[latex-defaults] @tech{style property}. Parses the code formed by the strings produced by the @racket[str-expr]s as a Racket module (roughly) and produces a -@tech{block} that typesets the code. The @racket[str-expr]s should -normally start with @hash-lang[] to determine the reader syntax for -the module, but the resulting ``module'' need not expand or -compile---except as needed by @racket[expand-expr]. If -@racket[expand-expr] is omitted or produces false, then the input -formed by @racket[str-expr] is read until an end-of-file is -encountered, otherwise a single form is read from the input. +@tech{block} that typesets the code inset via @racket[nested] with the +style @racket['code-inset]. + +The @racket[str-expr]s should normally start with @hash-lang[] to +determine the reader syntax for the module, but the resulting +``module'' need not expand or compile---except as needed by +@racket[expand-expr]. If @racket[expand-expr] is omitted or produces +false, then the input formed by @racket[str-expr] is read until an +end-of-file is encountered, otherwise a single form is read from the +input. When @racket[keep-expr] produces a true value (the default), the first line in the input (which is typically @hash-lang[]) is preserved in @@ -94,8 +97,9 @@ produces the typeset result @defform[(racketblock datum ...)]{ Typesets the @racket[datum] sequence as a table of Racket code inset -by two spaces. The source locations of the @racket[datum]s determine -the generated layout. For example, +inset via @racket[nested] with the style @racket['code-inset]. The +source locations of the @racket[datum]s determine the generated +layout. For example, @racketblock[ (racketblock @@ -196,10 +200,10 @@ See also @racketmodname[scribble/comment-reader]. the expression escape @racket[UNSYNTAX] instead of @racket[unsyntax].} @defform[(racketblock0 datum ...)]{Like @racket[racketblock], but -without insetting the code.} +without insetting the code via @racket[nested].} @defform[(RACKETBLOCK0 datum ...)]{Like @racket[RACKETBLOCK], but -without insetting the code.} +without insetting the code via @racket[nested].} @deftogether[( @defform[(racketresultblock datum ...)] @@ -217,6 +221,13 @@ result (i.e., a single color with no hyperlinks) instead of code.} )]{Like @racket[racketblock] and @racket[RACKETBLOCK], but the @racket[datum]s are typeset after a prompt representing a REPL.} +@deftogether[( +@defform[(racketinput0 datum ...)] +@defform[(RACKETINPUT0 datum ...)] +)]{ +Like @racket[racketinput] and @racket[RACKETINPUT], but +without insetting the code via @racket[nested].} + @defform/subs[(racketmod maybe-file lang datum ...) ([maybe-file code:blank (code:line #:file filename-expr)])]{ @@ -233,6 +244,10 @@ If @racket[#:file] is provided, then the code block is typeset using @racket[filebox] with @racket[filename-expr] as the filename argument.} +@defform[(racketmod0 maybe-file lang datum ...)]{ +Like @racket[racketmod], but +without insetting the code via @racket[nested].} + @defform[(racket datum ...)]{Like @racket[racketblock], but typeset on a single line and wrapped with its enclosing paragraph, independent of the formatting of @racket[datum].} diff --git a/collects/scribblings/scribble/srcdoc.scrbl b/collects/scribblings/scribble/srcdoc.scrbl index 5968c39d..28d8c006 100644 --- a/collects/scribblings/scribble/srcdoc.scrbl +++ b/collects/scribblings/scribble/srcdoc.scrbl @@ -71,18 +71,18 @@ to get core Racket forms and basic Scribble functions to use in documentation expressions.} @defform*/subs[#:literals (-> ->* case->) - [(proc-doc/names id contract ((arg-id ...) ((arg-id default-expr) ...)) desc-expr) - (proc-doc/names id case-contract ((arg-id ...) ((arg-id default-expr) ...)) desc-expr)] + [(proc-doc/names id contract ((arg-id ...) ((arg-id default-expr) ...)) + desc-expr)] ([contract (-> arg ... result) - (->* (mandatory ...) (optional ...) result)] + (->* (mandatory ...) (optional ...) result) + (case-> (-> arg ... result) ...)] [mandatory contract-expr (code:line keyword contract-expr)] [optional contract-expr - (code:line keyword contract-expr)] - [case-contract (case-> (-> arg ... result) ...)])]{ + (code:line keyword contract-expr)])]{ When used in @racket[provide/doc], exports @racket[id] with the -contract described by @racket[contract] or @racket[case-contract], +contract described by @racket[contract] just like using @racket[provide/contract]. The @racket[arg-id]s specify the names of arguments, which are not @@ -108,9 +108,9 @@ form.} (proc-doc id contract desc-expr) ([contract (-> result) (->d (arg ...) () (values [id result] ...)) - (->d (arg ...) () #:pre-cond expression (values [id result] ...)) + (->d (arg ...) () #:pre-cond expr (values [id result] ...)) (->d (arg ...) () [id result]) - (->d (arg ...) () #:pre-cond expression [id result]) + (->d (arg ...) () #:pre-cond expr [id result]) (->d (arg ...) () #:rest id rest [id result])])]{ Like @racket[proc-doc], but supporting contract forms that embed