add #:indent to verbatim

svn: r8707
This commit is contained in:
Eli Barzilay 2008-02-18 20:01:23 +00:00
parent 0f99e937fd
commit 6f0ce91461
25 changed files with 90 additions and 82 deletions

View File

@ -39,7 +39,7 @@ contain Scheme strings, and since escape characters are difficult for
people to read, a @litchar{|} character in @scheme[sexpr] is
converted to a @litchar{"} character before it is parsed. Thus,
@verbatim{
@verbatim[#:indent 2]{
<A MZSCHEME="|This goes nowhere.|">Nowhere</A>
}
@ -61,7 +61,7 @@ is executed immediately during HTML rendering. If the result is a
string, the comment is replaced in the input HTML stream with the
content of the string. Thus,
@verbatim{
@verbatim[#:indent 2]{
<!-- MZSCHEME="(format |<B>Here</B>: ~a| (current-directory))" -->
}

View File

@ -48,7 +48,7 @@ re-exported by @schememodname[net/url].}
The basic structure for all URLs, hich is explained in RFC 3986
@cite["RFC3986"]. The following diagram illustrates the parts:
@verbatim|{
@verbatim[#:indent 2]|{
http://sky@www:801/cgi-bin/finger;xyz?name=shriram;host=nw#top
{-1} {2} {3} {4}{---5---------} {6} {----7-------------} {8}

View File

@ -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

View File

@ -634,7 +634,7 @@ control can be placed into struct fields.
As an example, consider the following C code:
@verbatim{
@verbatim[#:indent 2]{
typedef struct { int x; char y; } A;
typedef struct { A a; int z; } B;

View File

@ -330,7 +330,7 @@ The built-in container classes include horizontal panels (and panes),
vertical containers, a programmer can achieve most any layout. For
example, we can construct a dialog with the following shape:
@verbatim{
@verbatim[#:indent 2]{
------------------------------------------------------
| ------------------------------------- |
| Your name: | | |

View File

@ -21,7 +21,10 @@ When @exec{mzscheme} is run with no command-line arguments (other than
confguration options, like @Flag{j}), then it starts a @tech{REPL}
with a @litchar{> } prompt:
@verbatim{ Welcome to MzScheme\n > }
@verbatim[#:indent 2]{
Welcome to MzScheme
>
}
@margin-note{For information on GNU Readline support, see
@schememodname[readline/rep].}

View File

@ -18,7 +18,7 @@ executable followed by a module declaration. For example, if
@exec{mzscheme} is installed in @filepath{/usr/local/bin}, then a file
containing the following text acts as a ``hello world'' script:
@verbatim{
@verbatim[#:indent 2]{
#! /usr/local/bin/mzscheme
#lang scheme/base
"Hello, world!"
@ -39,7 +39,7 @@ executable, a popular alternative is to require that @exec{mzscheme}
is in the user's command path, and then ``trampoline'' using
@exec{/usr/bin/env}:
@verbatim{
@verbatim[#:indent 2]{
#! /usr/bin/env mzscheme
#lang scheme/base
"Hello, world!"
@ -48,7 +48,7 @@ is in the user's command path, and then ``trampoline'' using
In either case, command-line arguments to a script are available via
@scheme[current-command-line-arguments]:
@verbatim{
@verbatim[#:indent 2]{
#! /usr/bin/env mzscheme
#lang scheme/base
(printf "Given arguments: ~s\n"
@ -65,7 +65,7 @@ them using the @scheme[command-line] form provided by
command-line arguments from @scheme[(current-command-line-arguments)]
by default:
@verbatim{
@verbatim[#:indent 2]{
#! /usr/bin/env mzscheme
#lang scheme
@ -91,7 +91,7 @@ that are comments in one language and expressions in the other. This
trampoline is more complicated, but it provides more control over
command-line arguments to @scheme{mzscheme}:
@verbatim|{
@verbatim[#:indent 2]|{
#! /bin/sh
#|
exec mzscheme -cu "$0" ${1+"$@"}

View File

@ -84,7 +84,7 @@ Installs a function to be called on each custodian-registered item and
its closer when MzScheme is about to exit. The registered function
has the type
@verbatim{
@verbatim[#:indent 2]{
typedef
void (*Scheme_Exit_Closer_Func)(Scheme_Object *o,
Scheme_Close_Custodian_Client *f,

View File

@ -18,7 +18,7 @@ in @cpp{scheme_current_thread->error_buf}. The macro
@cppi{scheme_error_buf} is a shorthand for
@cpp{*scheme_current_thread->error_buf}.
@verbatim{
@verbatim[#:indent 2]{
mz_jmp_buf * volatile save, fresh;
...
save = scheme_current_thread->error_buf;
@ -84,7 +84,7 @@ visible when implementing a new primitive procedure. When
request by chaining to the previously saved error buffer; otherwise,
call @cppi{scheme_clear_escape}.
@verbatim{
@verbatim[#:indent 2]{
mz_jmp_buf * volatile save, fresh;
save = scheme_current_thread->error_buf;
scheme_current_thread->error_buf = &fresh;
@ -120,7 +120,7 @@ exceptions in a variety of situations. It implements the function
application of a thunk. (This code is in
@filepath{collects/mzscheme/examples/catch.c} in the distribution.)
@verbatim{
@verbatim[#:indent 2]{
static Scheme_Object *exn_catching_apply, *exn_p, *exn_message;
static void init_exn_catching_apply()
@ -183,7 +183,7 @@ application of a thunk. (This code is in
In the following example, the above code is used to catch exceptions
that occur during while evaluating source code from a string.
@verbatim{
@verbatim[#:indent 2]{
static Scheme_Object *do_eval(void *s, int noargc, Scheme_Object **noargv)
{
return scheme_eval_string((char *)s, scheme_get_env(scheme_config));

View File

@ -206,7 +206,7 @@ pointer within a function call at any point when a collection can be
triggered. Beware that nested function calls can hide temporary
pointers; for example, in
@verbatim{
@verbatim[#:indent 2]{
scheme_make_pair(scheme_make_pair(scheme_true, scheme_false),
scheme_make_pair(scheme_false, scheme_true))
}
@ -216,7 +216,7 @@ a register during the other call to @cpp{scheme_make_pair}; this
pointer must be exposed to the garbage collection and made subject to
update. Simply changing the code to
@verbatim{
@verbatim[#:indent 2]{
tmp = scheme_make_pair(scheme_true, scheme_false);
scheme_make_pair(tmp,
scheme_make_pair(scheme_false, scheme_true))
@ -226,7 +226,7 @@ does not expose all pointers, since @cpp{tmp} must be evaluated before
the second call to @cpp{scheme_make_pair}. In general, the above code
must be converted to the form
@verbatim{
@verbatim[#:indent 2]{
tmp1 = scheme_make_pair(scheme_true, scheme_false);
tmp2 = scheme_make_pair(scheme_true, scheme_false);
scheme_make_pair(tmp1, tmp2);
@ -235,7 +235,7 @@ must be converted to the form
and this is converted form must be instrumented to register @cpp{tmp1}
and @cpp{tmp2}. The final result might be
@verbatim{
@verbatim[#:indent 2]{
{
Scheme_Object *tmp1 = NULL, *tmp2 = NULL, *result;
MZ_GC_DECL_REG(2);
@ -269,7 +269,7 @@ whereas registering an array of pointers requires three slots. For
example, to register a pointer @cpp{tmp} and an array of 10
@cpp{char*}s:
@verbatim{
@verbatim[#:indent 2]{
{
Scheme_Object *tmp1 = NULL;
char *a[10];
@ -300,7 +300,7 @@ must be registered with the collector during the entire call to
The name used for a variable need not be immediate. Structure members
can be supplied as well:
@verbatim{
@verbatim[#:indent 2]{
{
struct { void *s; int v; void *t; } x = {NULL, 0, NULL};
MZ_GC_DECL_REG(2);
@ -330,7 +330,7 @@ example also illustrates how @cpp{MZ_GC_UNREG} is not needed when
control escapes from the function, such as when
@cpp{scheme_signal_error} escapes.
@verbatim{
@verbatim[#:indent 2]{
{
Scheme_Object *tmp1 = NULL, *tmp2 = NULL;
mzchar *a, *b;
@ -372,7 +372,7 @@ declarations for the block's variables. In that case, the nested
@cpp{MZ_GC_DECL_REG} must have its own @cpp{MZ_GC_REG} and
@cpp{MZ_GC_UNREG} calls.
@verbatim{
@verbatim[#:indent 2]{
{
Scheme_Object *accum = NULL;
MZ_GC_DECL_REG(1);
@ -404,7 +404,7 @@ must be unregistered before it goes out of scope. The
@cppi{MZ_GC_NO_VAR_IN_REG} macro can be used to unregister a variable
or to initialize a slot as having no variable.
@verbatim{
@verbatim[#:indent 2]{
{
Scheme_Object *accum = NULL;
MZ_GC_DECL_REG(2);
@ -527,7 +527,7 @@ The following macros can be used (with care!) to navigate
Example:
@verbatim{
@verbatim[#:indent 2]{
int foo(int c, ...) {
int r = 0;
XFORM_START_SKIP;
@ -555,7 +555,7 @@ The following macros can be used (with care!) to navigate
Example:
@verbatim{
@verbatim[#:indent 2]{
int foo(int c, ...) {
int r = 0;
{
@ -699,7 +699,7 @@ Overrides the GC's auto-determined stack base, and/or disables the
The following example shows a typical use for setting the stack base:
@verbatim{
@verbatim[#:indent 4]{
int main(int argc, char **argv) {
int dummy;
scheme_set_stack_base(&dummy, 0);
@ -777,7 +777,7 @@ finalizers are registered for @var{p}.
The @cpp{fnl_proc} type is not actually defined, but it is equivalent
to
@verbatim{ typedef void (*fnl_proc)(void *p, void *data)}
@verbatim[#:indent 2]{typedef void (*fnl_proc)(void *p, void *data)}
The @var{f} argument is the callback function; when it is called, it
will be passed the value @var{p} and the data pointer @var{data};
@ -896,7 +896,7 @@ Forces an immediate garbage-collection.}
Each of the three procedures takes a pointer and returns an integer:
@verbatim{
@verbatim[#:indent 2]{
typedef int (*Size_Proc)(void *obj);
typedef int (*Mark_Proc)(void *obj);
typedef int (*Fixup_Proc)(void *obj);

View File

@ -168,7 +168,7 @@ tables) can be anything.
The public portion of the @cppi{Scheme_Hash_Table} type is defined
roughly as follows:
@verbatim{
@verbatim[#:indent 2]{
typedef struct Scheme_Hash_Table {
Scheme_Object so; /* so.type == scheme_hash_table_type */
/* ... */
@ -234,7 +234,7 @@ two are the same as for hash tables. The last is like
The public portion of the @cppi{Scheme_Bucket_Table} type is defined
roughly as follows:
@verbatim{
@verbatim[#:indent 2]{
typedef struct Scheme_Bucket_Table {
Scheme_Object so; /* so.type == scheme_variable_type */
/* ... */
@ -286,7 +286,7 @@ Returns the current value for @var{key} in @var{table}, or @cpp{NULL}
Returns the bucket for @var{key} in @var{table}. The
@cppi{Scheme_Bucket} structure is defined as:
@verbatim{
@verbatim[#:indent 2]{
typedef struct Scheme_Bucket {
Scheme_Object so; /* so.type == scheme_bucket_type */
/* ... */

View File

@ -78,7 +78,7 @@ the global variable is undefined.
The @cppi{Scheme_Bucket} structure is defined as:
@verbatim{
@verbatim[#:indent 2]{
typedef struct Scheme_Bucket {
Scheme_Object so; /* so.type = scheme_variable_type */
void *key;

View File

@ -160,7 +160,7 @@ registered using @cppi{scheme_register_extension_global} (see
As an example, the following C code defines an extension that returns
@scheme["hello world"] when it is loaded:
@verbatim{
@verbatim[#:indent 2]{
#include "escheme.h"
Scheme_Object *scheme_initialize(Scheme_Env *env) {
return scheme_make_utf8_string("hello world");

View File

@ -47,7 +47,7 @@ substantial or unbounded work should occasionally call
Creates a primitive procedure value, given the C function pointer
@var{prim}. The form of @var{prim} is defined by:
@verbatim{
@verbatim[#:indent 2]{
typedef Scheme_Object *(Scheme_Prim)(int argc,
Scheme_Object **argv);
}
@ -94,7 +94,7 @@ in @var{vals}; when the C function @var{prim} is invoked, the
generated primitive is passed as the last parameter. The form of
@var{prim} is defined by:
@verbatim{
@verbatim[#:indent 2]{
typedef
Scheme_Object *(Scheme_Prim_Closure_Proc)(int argc,
Scheme_Object **argv,
@ -117,7 +117,7 @@ Creates an old-style primitive procedure value; when the C function
@var{prim} is invoked, @var{data} is passed as the first parameter.
The form of @var{prim} is defined by:
@verbatim{
@verbatim[#:indent 2]{
typedef
Scheme_Object *(Scheme_Closed_Prim)(void *data, int argc,
Scheme_Object **argv);

View File

@ -85,7 +85,7 @@ of ``fuel'' that has been consumed since the last call to
@scheme[vector->list] consumes a unit of fuel for each created cons
cell:
@verbatim{
@verbatim[#:indent 2]{
Scheme_Object *scheme_vector_to_list(Scheme_Object *vec)
{
int i;
@ -173,7 +173,7 @@ class. (Any regular event-loop-based callback is appropriate.) The
@cpp{scheme_notify_multithread} pointer is set to
@cpp{MrEdInstallThreadTimer}. (MrEd no longer work this way, however.)
@verbatim{
@verbatim[#:indent 2]{
class MrEdThreadTimer : public wxTimer
{
public:
@ -240,7 +240,7 @@ ready on any of those file descriptors, the callbacks are removed and
For example, the X Windows version of MrEd formerly set
@cpp{scheme_wakeup_on_input} to this @cpp{MrEdNeedWakeup}:
@verbatim{
@verbatim[#:indent 2]{
static XtInputId *scheme_cb_ids = NULL;
static int num_cbs;
@ -350,7 +350,7 @@ The following function @cpp{mzsleep} is an appropriate
@cpp{scheme_sleep} function for most any Unix or Windows application.
(This is approximately the built-in sleep used by Scheme.)
@verbatim{
@verbatim[#:indent 2]{
void mzsleep(float v, void *fds)
{
if (v) {
@ -472,7 +472,7 @@ Returns @cpp{1} if a break from @scheme[break-thread] or @cpp{scheme_break_threa
The @cpp{Scheme_Ready_Fun} and @cpp{Scheme_Needs_Wakeup_Fun}
types are defined as follows:
@verbatim{
@verbatim[#:indent 2]{
typedef int (*Scheme_Ready_Fun)(Scheme_Object *data);
typedef void (*Scheme_Needs_Wakeup_Fun)(Scheme_Object *data,
void *fds);
@ -623,7 +623,7 @@ Under Unix, and Mac OS X, this function has no effect.}
The argument types are defined as follows:
@verbatim{
@verbatim[#:indent 2]{
typedef int (*Scheme_Ready_Fun)(Scheme_Object *data);
typedef void (*Scheme_Needs_Wakeup_Fun)(Scheme_Object *data,
void *fds);
@ -649,7 +649,7 @@ Like @cpp{scheme_add_evt}, but for objects where waiting is based
on a semaphore. Instead of @var{ready} and @var{wakeup} functions,
the @var{getsema} function extracts a semaphore for a given object:
@verbatim{
@verbatim[#:indent 2]{
typedef
Scheme_Object *(*Scheme_Wait_Sema_Fun)(Scheme_Object *data,
int *repost);

View File

@ -684,7 +684,7 @@ Installs a printer to be used for printing (or writing or displaying)
The type of @var{printer} is defined as follows:\cppIndex{scheme_Type_Printer}
@verbatim{
@verbatim[#:indent 2]{
typedef void (*Scheme_Type_Printer)(Scheme_Object *v, int dis,
Scheme_Print_Params *pp);
}
@ -732,7 +732,7 @@ is only applied to values that both have tag @var{type}.
The type of @var{equalp}, @var{hash1}, and @var{hash2} are defined as
follows:
@verbatim{
@verbatim[#:indent 2]{
typedef int (*Scheme_Equal_Proc)(Scheme_Object* obj1,
Scheme_Object* obj2,
void* cycle_data);

View File

@ -69,7 +69,7 @@ DrScheme.}
@link[url:download-drscheme]{Download PLT Scheme}, install, and then
start @exec{mzscheme} with no command-line arguments:
@verbatim{
@verbatim[#:indent 2]{
$ mzscheme
Welcome to MzScheme
>

View File

@ -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}
}|

View File

@ -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.

View File

@ -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)

View File

@ -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)

View File

@ -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].}

View File

@ -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]|==={
@;{
...
;}

View File

@ -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

View File

@ -34,7 +34,7 @@ offset of an embedded pict in a larger pict.
In addition to its drawing part, a pict has the following
@deftech{bounding box} structure:
@verbatim{
@verbatim[#:indent 7]{
w
------------------
| | a \