diff --git a/collects/scribble/doc.txt b/collects/scribble/doc.txt index f35ed7c470..37d0eadd65 100644 --- a/collects/scribble/doc.txt +++ b/collects/scribble/doc.txt @@ -7,14 +7,35 @@ example, the reader can be used in any situation that requires lots of free-form text, or you can use the rendering portion directly to generate documents. + +Running Scribble +---------------- + +To process a Scribble document, use the `scribble' command-line utility +(use `scribble -h' to see usage information). This is implemented by +the "run-scribble.ss" module, which can be used directly: + +> (render-file input output format) + +Renders the given `input' file to the `output' file using the given +format specification. The input and output files are used as is (no +suffixes are added). The `output' argument can be #f, which will render +the input to the current output port. `format' is a symbol that +specifies the kind of output rendering (use the `scribble' commad to +find the list of available formatters). + +A Scribble document is a MzScheme module file, which provides a `content' +binding. + + The Scribble Reader ------------------- +------------------- *** Introduction The @-reader is designed to be a convenient facility for using free-form text in Scheme code. "@" is chosen as one of the least-used characters -in Scheme code (the options are: "&" (969 uses in the collects +in Scheme code (reasonable options are: "&" (969 uses in the collects hierarchy), "|" (1676), "@" (2105) "^" (2257) "$" (2259)). To use this file, you can use MzScheme's #reader form: diff --git a/collects/scribble/run-scribble.ss b/collects/scribble/run-scribble.ss index 5ad7ae98cd..4f107e81a2 100644 --- a/collects/scribble/run-scribble.ss +++ b/collects/scribble/run-scribble.ss @@ -22,15 +22,14 @@ [else (error* "unknown format ~e (use -L for a list of formats)" format)])) + (provide render-file) (define (render-file input output format) (unless (file-exists? input) (error* "cannot find input file: ~e" input)) (let* ([contents (dynamic-require `(file ,input) 'contents)] [renderer (format->renderer format)] [render (lambda () (renderer contents))]) - (if (equal? output "-") - (render) - (with-output-to-file output render 'truncate)))) + (if output (with-output-to-file output render 'truncate) (render)))) (provide main) (define (main args) @@ -55,7 +54,8 @@ => (lambda (m) (string->symbol (cadr m)))] [else default-format])] [output (or *output-name (path-replace-suffix - input-file (symbol->string fmt)))]) + input-file (symbol->string fmt)))] + [output (and (not (equal? "-" output)) output)]) (render-file input-file output fmt))])) (main (cons (symbol->string exe-name)