commit 2620e79135b94247e30d46acc22d771e42cc31e6
parent 1849a01a9f6e29f1648f2b6d498dfd3bb92c4e5f
Author: Eli Barzilay <eli@racket-lang.org>
Date: Mon, 18 Feb 2008 20:01:23 +0000
add #:indent to verbatim
svn: r8707
original commit: 6f0ce914614ae5a840bcdeed225583ad4f4b1692
Diffstat:
8 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/collects/scribble/manual.ss b/collects/scribble/manual.ss
@@ -187,7 +187,10 @@
(make-element "schemeinput" (list (substring s (cdar spaces) (caar end-spaces))))
(hspace (- (cdar end-spaces) (caar end-spaces)))))))))
- (define (verbatim s . more)
+ (define (verbatim #:indent [i 0] s . more)
+ (define indent (if (zero? i)
+ values
+ (let ([hs (hspace i)]) (lambda (x) (cons hs x)))))
(define strs (regexp-split #rx"\n" (apply string-append s more)))
(define (str->elts str)
(let ([spaces (regexp-match-positions #rx"(?:^| ) +" str)])
@@ -197,8 +200,9 @@
(str->elts (substring str (cdar spaces))))
(list (make-element 'tt (list str))))))
(define (make-line str)
- (list (make-flow (list (make-paragraph
- (list (make-element 'tt (str->elts str))))))))
+ (let* ([line (indent (str->elts str))]
+ [line (list (make-element 'tt line))])
+ (list (make-flow (list (make-paragraph line))))))
(make-table #f (map make-line strs)))
(define-syntax indexed-scheme
diff --git a/collects/scribblings/scribble/basic.scrbl b/collects/scribblings/scribble/basic.scrbl
@@ -35,7 +35,7 @@ called from Scheme as
or with an @elem["@"] expression as
-@verbatim|{
+@verbatim[#:indent 2]|{
@title[#:tag "how-to"]{How to Design @italic{Great} Programs}
}|
diff --git a/collects/scribblings/scribble/decode.scrbl b/collects/scribblings/scribble/decode.scrbl
@@ -36,7 +36,7 @@ Some functions @deftech{decode} a sequence of @scheme[_pre-flow] or
function accepts any number of @scheme[_pre-content] arguments, so
that in
-@verbatim|{ @bold{``apple''}}|
+@verbatim[#:indent 2]|{@bold{``apple''}}|
the @litchar{``apple''} argument is decoded to use fancy quotes, and
then it is bolded.
diff --git a/collects/scribblings/scribble/how-to.scrbl b/collects/scribblings/scribble/how-to.scrbl
@@ -25,7 +25,7 @@ To document a collection or @|PLaneT| package:
@filepath{manual.scrbl}.}
@item{Start @filepath{manual.scrbl} like this:
- @verbatim|{
+ @verbatim[#:indent 2]|{
#lang scribble/doc
@(require scribble/manual)
@@ -135,7 +135,7 @@ that precede text to typeset.
Thus,
-@verbatim|{
+@verbatim[#:indent 2]|{
@title{My Library}
@scheme[(list 'testing 1 2 3)]
@section[#:tag "here"]{You Are Here}
@@ -189,7 +189,7 @@ preferred mechanism for linking to information outside of a single
document. Such links require no information about where and how a
binding is documented elsewhere:
-@verbatim|{
+@verbatim[#:indent 2]|{
#lang scribble/doc
@(require scribble/manual
(for-label scheme))
@@ -204,7 +204,7 @@ so it ignores the source formatting of the expression. The
@scheme[schemeblock] form, in contrast, typesets inset Scheme code,
and it preserves the expression's formatting from the document source.
-@verbatim|{
+@verbatim[#:indent 2]|{
#lang scribble/doc
@(require scribble/manual
(for-label scheme))
@@ -234,7 +234,7 @@ hyperlink with text other than the section title.
The following example illustrates section hyperlinks:
-@verbatim|{
+@verbatim[#:indent 2]|{
#lang scribble/doc
@(require scribble/manual
(for-label scheme))
@@ -273,7 +273,7 @@ prefix, which is based on the target document's main source file. The
following example links to a section in the PLT Scheme reference
manual:
-@verbatim|{
+@verbatim[#:indent 2]|{
#lang scribble/doc
@(require scribble/manual
(for-label scheme))
@@ -307,7 +307,7 @@ to import the binding information of @filepath{helper.ss}. Then add a
binding with the module path as seen by a reader. Finally, use
@scheme[defproc] to document the procedure:
-@verbatim|{
+@verbatim[#:indent 2]|{
#lang scribble/doc
@(require scribble/manual
(for-label scheme
@@ -379,7 +379,7 @@ bindings introduced into the document source by
from the previous section, then @filepath{helper.ss} must be imported both
via @scheme[require-for-label] and @scheme[require]:
-@verbatim|{
+@verbatim[#:indent 2]|{
#lang scribble/doc
@(require scribble/manual
scribble/eval ; <--- added
@@ -415,7 +415,7 @@ as a sub-part of the enclosing part.
In @filepath{manual.scrbl}:
-@verbatim|{
+@verbatim[#:indent 2]|{
#lang scribble/doc
@(require scribble/manual)
@@ -430,7 +430,7 @@ In @filepath{manual.scrbl}:
In @filepath{cows.scrbl}:
-@verbatim|{
+@verbatim[#:indent 2]|{
#lang scribble/doc
@(require scribble/manual)
@@ -441,7 +441,7 @@ In @filepath{cows.scrbl}:
In @filepath{aardvarks.scrbl}:
-@verbatim|{
+@verbatim[#:indent 2]|{
#lang scribble/doc
@(require scribble/manual
(for-label scheme
@@ -471,7 +471,7 @@ sub-sections.
Revising @filepath{cows.scrbl} from the previous section:
-@verbatim|{
+@verbatim[#:indent 2]|{
#lang scribble/doc
@(require scribble/manual)
diff --git a/collects/scribblings/scribble/layers.scrbl b/collects/scribblings/scribble/layers.scrbl
@@ -27,7 +27,7 @@ alone, but @litchar["@"] forms can escape to S-expression mode.
A module written as
-@verbatim|{
+@verbatim[#:indent 2]|{
#lang scribble/doc
@(require scribble/manual)
diff --git a/collects/scribblings/scribble/manual.scrbl b/collects/scribblings/scribble/manual.scrbl
@@ -131,7 +131,8 @@ representation of literal text. Use this when you have to talk about
the individual characters in a stream of text, as as when documenting
a reader extension.}
-@defproc[(verbatim [str string?]) flow-element?]{Typesets @scheme[str]
+@defproc[(verbatim [#:indent indent integer? 0] [str string?] ...)
+ flow-element?]{Typesets @scheme[str]
as a table/paragraph in typewriter font with the linebreaks specified
by newline characters in @scheme[str]. ``Here strings'' are often
useful with @scheme[verbatim].}
diff --git a/collects/scribblings/scribble/reader.scrbl b/collects/scribblings/scribble/reader.scrbl
@@ -201,7 +201,7 @@ following spaces (or tabs) are part of the comment (similar to
Tip: if you're editing in a Scheme-aware editor (like DrScheme or
Emacs), it is useful to comment out blocks like this:
-@verbatim|==={
+@verbatim[#:indent 2]|==={
@;{
...
;}
diff --git a/collects/scribblings/scribble/style.scrbl b/collects/scribblings/scribble/style.scrbl
@@ -57,14 +57,14 @@ when using @scheme[scheme], especially outside of @scheme[defproc] or
@scheme[defform]. Prefix a meta-variable with @litchar{_}; for
example,
-@verbatim|{ @scheme[(rator-expr rand-expr ...)]}|
+@verbatim[#:indent 2]|{@scheme[(rator-expr rand-expr ...)]}|
would be the wrong way to refer to the grammar of a function call,
because it produces @scheme[(rator-expr rand-expr ...)], where
@schemeidfont{rator-expr} and @schemeidfont{rand-expr} are
typeset as variables. The correct description is
-@verbatim|{ @scheme[(_rator-expr _rand-expr ...)]}|
+@verbatim[#:indent 2]|{@scheme[(_rator-expr _rand-expr ...)]}|
which produces @scheme[(_rator-expr _rand-expr ...)], where
@schemeidfont{rator-expr} @schemeidfont{rand-expr} are typeset as