► |  | Scribble: PLT Documentation Tool

1 | Getting Started
2 | @ Syntax
3 | High-Level Scribble API
4 | Scribbling Documentation
5 | Literate Programming
6 | Text Preprocessing
7 | Low-Level Scribble API
| Index

► | 4 | Scribbling Documentation

4.1 | Getting Started with Documentation
4.2 | Manual Forms
4.3 | Scheme
4.4 | Evaluation and Examples
4.5 | In-Source Documentation
4.6 | BNF Grammars
4.7 | Compatibility Libraries

▼ | 4.2 | Manual Forms

4.2.1 | Typesetting Code
4.2.2 | Documenting Modules
4.2.3 | Documenting Forms, Functions, Structure Types, and Values
4.2.4 | Documenting Classes and Interfaces
4.2.5 | Documenting Signatures
4.2.6 | Various String Forms
4.2.7 | Links
4.2.8 | Indexing
4.2.9 | Images
4.2.10 | Bibliography
4.2.11 | Miscellaneous
4.2.12 | Index-Entry Descriptions

► | 4.2.1 | Typesetting Code

4.2.1.1 | Typesetting Comments

On this page:

schemeblock
SCHEMEBLOCK
schemeblock0
SCHEMEBLOCK0
schemeinput
schememod
scheme
SCHEME
schemeresult
schemeid
schememodname
schememodlink
litchar
schemefont
schemevalfont
schemeresultfont
schemeidfont
schemevarfont
schemekeywordfont
schemeparenfont
schememetafont
schemeerror
schememodfont
schemeoutput
procedure
var
svar
4.2.1.1`` Typesetting Comments

top← prev up next →

##### 4.2.1`` Typesetting Code

(schemeblock datum ...)

Typesets the datum sequence as a table of Scheme code inset by two spaces. The source locations of the datums determine the generated layout. For example,

(schemeblock
(define (loop x)
(loop (not x))))

produces the output

(define (loop x)
(loop (not x)))

with the (loop (not x)) indented under define, because that’s the way it is idented the use of schemeblock.

Furthermore, define is typeset as a keyword (bold and black) and as a hyperlink to define’s definition in the reference manual, because this document was built using a for-label binding of define (in the source) that matches a definition in the reference manual. Similarly, not is a hyperlink to the its definition in the reference manual.

Use unsyntax to escape back to an expression that produces an element. For example,

(schemeblock
(+ 1 #,(elem (scheme x) (subscript "2"))))

produces

(+ 1 x 2)

The unsyntax form is regonized via free-identifier=?, so if you want to typeset code that includes unsyntax, you can simply hide the usual binding:

(schemeblock
(let ([unsyntax #f])
(schemeblock
#'(+ 1 #,x))))

Or use SCHEMEBLOCK, whose escape form is UNSYNTAX instead of unsyntax.

A few other escapes are recognized symbolically:

- (code:line datum ...) typesets as the sequence of datums (i.e., without the code:line wrapper).

- (code:comment datum) typesets like datum, but colored as a comment and prefixed with a semi-colon. A typical datum escapes from Scheme-typesetting mode using unsyntax and produces a paragraph using t:

  (code:comment @#,t{this is a comment})

  (Note that @#,foo{...} reads as #,(foo "...").)

- code:blank typesets as a blank space.

- _id typesets as id, but colored as a variable (like schemevarfont); this escape applies only if _id has no for-label binding and is not specifically colored as a subform non-terminal via defform, a variable via defproc, etc.

See also scribble/comment-reader.

(SCHEMEBLOCK datum ...)

Like schemeblock, but with the expression escape UNSYNTAX instead of unsyntax.

(schemeblock0 datum ...)

Like schemeblock, but without insetting the code.

(SCHEMEBLOCK0 datum ...)

Like SCHEMEBLOCK, but without insetting the code.

(schemeinput datum ...)

Like schemeblock, but the datum are typeset after a prompt representing a REPL.

(schememod lang datum ...)

Like schemeblock, but the datum are typeset inside a #lang-form module whose language is lang. The source location of lang (relative to the body datums) determines the relative positioning of the #lang line in the typeset output.

(scheme datum ...)

Like schemeblock, but typeset on a single line and wrapped with its enclosing paragraph, independent of the formatting of datum.

(SCHEME datum ...)

Like scheme, but with the UNSYNTAX escape like schemeblock.

(schemeresult datum ...)

Like scheme, but typeset as a REPL value (i.e., a single color with no hyperlinks).

(schemeid datum ...)

Like scheme, but typeset as an unbound identifier (i.e., no coloring or hyperlinks).

(schememodname datum)
(schememodname (unsyntax expr))

Like scheme, but typeset as a module path. If datum is an identifier or expr produces a symbol, then it is hyperlinked to the module path’s definition as created by defmodule.

(schememodlink datum pre-content-expr ...)

Like schememod, but separating the module path to link from the content to be linked. The datum module path is always linked, even if it is not an identifier.

(litchar str ...) → element?
str : string?

Typesets strs as a 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.

(schemefont pre-content ...) → element?
pre-content : pre-content?

Typesets decoded pre-content as uncolored, unhyperlinked Scheme. This procedure is useful for typesetting things like #lang, which are not readable by themselves.

(schemevalfont pre-content ...) → element?
pre-content : pre-content?

Like schemefont, but colored as a value.

(schemeresultfont pre-content ...) → element?
pre-content : pre-content?

Like schemefont, but colored as a REPL result.

(schemeidfont pre-content ...) → element?
pre-content : pre-content?

Like schemefont, but colored as an identifier.

(schemevarfont pre-content ...) → element?
pre-content : pre-content?

Like schemefont, but colored as a variable (i.e., an argument or sub-form in a procedure being documented).

(schemekeywordfont pre-content ...) → element?
pre-content : pre-content?

Like schemefont, but colored as a syntactic form name.

(schemeparenfont pre-content ...) → element?
pre-content : pre-content?

Like schemefont, but colored like parentheses.

(schememetafont pre-content ...) → element?
pre-content : pre-content?

Like schemefont, but colored as meta-syntax, such as backquote or unquote.

(schemeerror pre-content ...) → element?
pre-content : pre-content?

Like schemefont, but colored as error-message text.

(schememodfont pre-content ...) → element?
pre-content : pre-content?

Like schemefont, but colored as module name.

(schemeoutput pre-content ...) → element?
pre-content : pre-content?

Like schemefont, but colored as output.

(procedure pre-content ...) → element?
pre-content : pre-content?

Typesets decoded pre-content as a procedure name in a REPL result (e.g., in typewriter font with a #<procedure: prefix and > suffix.).

(var datum)

Typesets datum as an identifier that is an argument or sub-form in a procedure being documented. Normally, the defproc and defform arrange for scheme to format such identifiers automatically in the description of the procedure, but use var if that cannot work for some reason.

(svar datum)

Like var, but for subform non-terminals in a form definition.

##### 4.2.1.1`` Typesetting Comments

#reader scribble/comment-reader

As a reader module, scribble/comment-reader reads a single S-expression that contains ;-based comment lines, and it wraps the comments with code:comment for use with forms like schemeblock. More precisely, scribble/comment-reader extends the current reader to adjust the parsing of ;.

For example, within a Scribble document that imports scribble/manual,

@#reader scribble/comment-reader
(schemeblock
;; This is not a pipe
(make-pipe)
)

generates

; This is not a pipe
(make-pipe)

The initial @ is needed above to shift into S-expression mode, so that #reader is recognized as a reader declaration instead of literal text. Also, the example uses (schemeblock ....) instead of @schemeblock[....] because the @-reader would drop comments within the schemeblock before giving scribble/comment-reader a chance to convert them.

top← prev up next →