adjust Slideshow to not re-export printable<%>; improve docs for both Slideshow and Scribble

original commit: b072d85107355a3e2db3629a95195b928c891f16
This commit is contained in:
134 changed files with 3791 additions and 3218 deletions

View File

@ -1,10 +1,12 @@
#lang scheme/base
(require "search.ss" scheme/cmdline scheme/list scheme/string)
(require "search.ss" scheme/cmdline scheme/list scheme/string
raco/command-name)
;; Minimal command-line arguments, the query string can contain all
;; kinds of magic.
(command-line
#:program (short-program+command-name)
#:handlers
(lambda (_ . ts)
(if (null? ts)

View File

@ -638,7 +638,7 @@
;; the last round, and #f means no desc
(define desc-order '(part mod libs delayed #f))
;; this defines an imposed ordering for module names
(define lib-order '(#rx"^scheme(?:/|$)" #rx"^r.rs(?:/|$)" #rx"^lang(?:/|$)"))
(define lib-order '(#rx"^racket(?:/|$)" #rx"^r.rs(?:/|$)" #rx"^lang(?:/|$)"))
(define (lib<? lib1 lib2)
(define (lib-level lib)
(let loop ([i 0] [rxs lib-order])

View File

@ -0,0 +1,3 @@
#lang s-exp scribble/base/reader
scribble/base/lang
#:wrapper1 (lambda (t) (list* 'doc 'values '() (t)))

View File

@ -1,18 +0,0 @@
#lang s-exp syntax/module-reader
scribble/base/lang
#:read scribble:read-inside
#:read-syntax scribble:read-syntax-inside
#:whole-body-readers? #t
#:wrapper1 (lambda (t) (list* 'doc 'values '() (t)))
#:info
(lambda (key defval default)
(case key
[(color-lexer)
(dynamic-require 'syntax-color/scribble-lexer 'scribble-inside-lexer)]
[(drscheme:toolbar-buttons)
(dynamic-require 'scribble/tools/drscheme-buttons 'drscheme-buttons)]
[else (default key defval)]))
(require (prefix-in scribble: "../../reader.ss"))

View File

@ -0,0 +1,3 @@
#lang s-exp scribble/base/reader
scribble/doclang
#:wrapper1 (lambda (t) (list* 'doc 'values '() (t)))

View File

@ -1,13 +0,0 @@
#lang scheme/base
(require (prefix-in doc: scribble/doc/reader))
(provide (rename-out [doc:read read] [doc:read-syntax read-syntax])
get-info)
(define (get-info . args)
(lambda (key defval)
(case key
[(color-lexer)
(dynamic-require 'syntax-color/scribble-lexer 'scribble-inside-lexer)]
[(drscheme:toolbar-buttons)
(dynamic-require 'scribble/tools/drscheme-buttons 'drscheme-buttons)]
[else defval])))

View File

@ -0,0 +1 @@
#lang scheme/base

View File

@ -1,10 +0,0 @@
#lang s-exp syntax/module-reader
scribble/doclang
#:read scribble:read-inside
#:read-syntax scribble:read-syntax-inside
#:whole-body-readers? #t
#:wrapper1 (lambda (t) (list* 'doc 'values '() (t)))
(require (prefix-in scribble: "../reader.ss"))

View File

@ -1,20 +1,20 @@
(module eval scheme/base
(module eval racket/base
(require "manual.ss"
"struct.ss"
"scheme.ss"
"decode.ss"
scheme/file
scheme/sandbox
scheme/promise
mzlib/string
(for-syntax scheme/base))
racket/file
racket/sandbox
racket/promise
racket/string
(for-syntax racket/base))
(provide interaction
interaction-eval
interaction-eval-show
schemeblock+eval
schememod+eval
racketblock+eval (rename-out [racketblock+eval schemeblock+eval])
racketmod+eval (rename-out [racketmod+eval schememod+eval])
def+int
defs+int
examples
@ -38,8 +38,8 @@
(define maxlen 60)
(namespace-require 'scheme/base)
(namespace-require '(for-syntax scheme/base))
(namespace-require 'racket/base)
(namespace-require '(for-syntax racket/base))
(define (literal-string style s)
(let ([m (regexp-match #rx"^(.*)( +)(.*)$" s)])
@ -97,18 +97,24 @@
(map
(lambda (s)
(car (format-output s error-color)))
(let sloop ([s (caar val-list+outputs)])
(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))))
(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))))))
;; Normal result case:
(let ([val-list (caar val-list+outputs)])
(if (equal? val-list (list (void)))
@ -118,7 +124,7 @@
(list
(hspace 2)
(elem #:style result-color
(to-element/no-color v))))))))
(to-element/no-color v #:expr? (print-as-expression)))))))))
val-list))))
(loop (cdr expr-paras)
(cdr val-list+outputs)
@ -314,7 +320,7 @@
(define (show-val v)
(elem #:style result-color
(to-element/no-color v)))
(to-element/no-color v #:expr? (print-as-expression))))
(define (do-interaction-eval-show ev e)
(parameterize ([current-command-line-arguments #()])
@ -325,31 +331,31 @@
[(_ #:eval ev e) (do-interaction-eval-show ev (quote-expr e))]
[(_ e) (do-interaction-eval-show #f (quote-expr e))]))
(define-syntax schemeinput*
(define-syntax racketinput*
(syntax-rules (eval:alts code:comment)
[(_ (code:comment . rest)) (schemeblock (code:comment . rest))]
[(_ (eval:alts a b)) (schemeinput* a)]
[(_ e) (schemeinput e)]))
[(_ (code:comment . rest)) (racketblock (code:comment . rest))]
[(_ (eval:alts a b)) (racketinput* a)]
[(_ e) (racketinput e)]))
(define-code schemeblock+line (to-paragraph/prefix (hspace 2)
(define-code racketblock+line (to-paragraph/prefix (hspace 2)
(hspace 2)
(list " ")))
(define-syntax (schemedefinput* stx)
(define-syntax (racketdefinput* stx)
(syntax-case stx (define define-values define-struct)
[(_ (define . rest))
(syntax-case stx ()
[(_ e) #'(schemeblock+line e)])]
[(_ e) #'(racketblock+line e)])]
[(_ (define-values . rest))
(syntax-case stx ()
[(_ e) #'(schemeblock+line e)])]
[(_ e) #'(racketblock+line e)])]
[(_ (define-struct . rest))
(syntax-case stx ()
[(_ e) #'(schemeblock+line e)])]
[(_ e) #'(racketblock+line e)])]
[(_ (code:line (define . rest) . rest2))
(syntax-case stx ()
[(_ e) #'(schemeblock+line e)])]
[(_ e) #'(schemeinput* e)]))
[(_ e) #'(racketblock+line e)])]
[(_ e) #'(racketinput* e)]))
(define (do-titled-interaction ev t shows evals)
(interleave t
@ -358,41 +364,41 @@
(define-syntax titled-interaction
(syntax-rules ()
[(_ #:eval ev t schemeinput* e ...)
(do-titled-interaction ev t (list (schemeinput* e) ...) (list (quote-expr e) ...))]
[(_ t schemeinput* e ...)
(titled-interaction #:eval (make-base-eval) t schemeinput* e ...)]))
[(_ #: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 ...)]))
(define-syntax interaction
(syntax-rules ()
[(_ #:eval ev e ...) (titled-interaction #:eval ev #f schemeinput* e ...)]
[(_ e ...) (titled-interaction #f schemeinput* e ...)]))
[(_ #:eval ev e ...) (titled-interaction #:eval ev #f racketinput* e ...)]
[(_ e ...) (titled-interaction #f racketinput* e ...)]))
(define-syntax schemeblock+eval
(define-syntax racketblock+eval
(syntax-rules ()
[(_ #:eval ev e ...)
(let ([eva ev])
(#%expression
(begin (interaction-eval #:eval eva e) ...
(schemeblock e ...))))]
(racketblock e ...))))]
[(_ e ...)
(schemeblock+eval #:eval (make-base-eval) e ...)]))
(racketblock+eval #:eval (make-base-eval) e ...)]))
(define-syntax schememod+eval
(define-syntax racketmod+eval
(syntax-rules ()
[(_ #:eval ev name e ...)
(let ([eva ev])
(#%expression
(begin (interaction-eval #:eval eva e) ...
(schememod name e ...))))]
(racketmod name e ...))))]
[(_ name e ...)
(schememod+eval #:eval (make-base-eval) name e ...)]))
(racketmod+eval #:eval (make-base-eval) name e ...)]))
(define-syntax def+int
(syntax-rules ()
[(_ #:eval ev def e ...)
(let ([eva ev])
(column (list (schemeblock+eval #:eval eva def)
(column (list (racketblock+eval #:eval eva def)
blank-line
(interaction #:eval eva e ...))))]
[(_ def e ...)
@ -402,7 +408,7 @@
(syntax-rules ()
[(_ #:eval ev [def ...] e ...)
(let ([eva ev])
(column (list (schemeblock+eval #:eval eva def ...)
(column (list (racketblock+eval #:eval eva def ...)
blank-line
(interaction #:eval eva e ...))))]
[(_ [def ...] e ...)
@ -421,27 +427,27 @@
(define-syntax examples
(syntax-rules ()
[(_ #:eval ev e ...)
(titled-interaction #:eval ev (pick-example-title e ...) schemeinput* e ...)]
(titled-interaction #:eval ev (pick-example-title e ...) racketinput* e ...)]
[(_ e ...)
(titled-interaction (pick-example-title e ...) schemeinput* e ...)]))
(titled-interaction (pick-example-title e ...) racketinput* e ...)]))
(define-syntax examples*
(syntax-rules ()
[(_ #:eval ev example-title e ...)
(titled-interaction #:eval ev example-title schemeinput* e ...)]
(titled-interaction #:eval ev example-title racketinput* e ...)]
[(_ example-title e ...)
(titled-interaction example-title schemeinput* e ...)]))
(titled-interaction example-title racketinput* e ...)]))
(define-syntax defexamples
(syntax-rules ()
[(_ #:eval ev e ...)
(titled-interaction #:eval ev (pick-example-title e ...) schemedefinput* e ...)]
(titled-interaction #:eval ev (pick-example-title e ...) racketdefinput* e ...)]
[(_ e ...)
(titled-interaction (pick-example-title e ...) schemedefinput* e ...)]))
(titled-interaction (pick-example-title e ...) racketdefinput* e ...)]))
(define-syntax defexamples*
(syntax-rules ()
[(_ #:eval ev example-title e ...)
(titled-interaction #:eval ev example-title schemedefinput* e ...)]
(titled-interaction #:eval ev example-title racketdefinput* e ...)]
[(_ example-title e ...)
(titled-interaction example-title schemedefinput* e ...)]))
(titled-interaction example-title racketdefinput* e ...)]))
(define blank-line (make-paragraph (list 'nbsp)))

View File

@ -23,7 +23,15 @@
[else c]))
(define-for-syntax (extract orig-path stx)
(let ([path (resolve-path-spec orig-path orig-path stx)])
(let* ([n-path (resolve-path-spec orig-path orig-path stx)]
[path (if (regexp-match? #rx#"[.]rkt$" (path->bytes n-path))
(if (file-exists? n-path)
n-path
(let ([ss (path-replace-suffix n-path #".ss")])
(if (file-exists? ss)
ss
n-path)))
n-path)])
(let ([s-exp
(parameterize ([current-namespace (make-base-namespace)]
[read-accept-reader #t]

View File

@ -486,56 +486,67 @@
(table-blockss table)))
(define ps
((if (nearly-top? d) values cdr)
(let flatten ([d d])
(append*
;; don't include the section if it's in the TOC
(if (nearly-top? d) null (list d))
;; get internal targets:
(append-map block-targets (part-blocks d))
(map (lambda (p) (if (part-whole-page? p ri) null (flatten p)))
(part-parts d))))))
(define any-parts? (ormap part? ps))
(let flatten ([d d][prefixes null][top? #t])
(let ([prefixes (if (and (not top?) (part-tag-prefix d))
(cons (part-tag-prefix d) prefixes)
prefixes)])
(append*
;; don't include the section if it's in the TOC
(if (nearly-top? d) null (list (cons d prefixes)))
;; get internal targets:
(map (lambda (v) (cons v prefixes)) (append-map block-targets (part-blocks d)))
(map (lambda (p) (if (part-whole-page? p ri) null (flatten p prefixes #f)))
(part-parts d)))))))
(define any-parts? (ormap (compose part? car) ps))
(if (null? ps)
null
`((div ([class ,box-class])
,@(get-onthispage-label)
(table ([class "tocsublist"] [cellspacing "0"])
,@(map (lambda (p)
`(tr
(td
,@(if (part? p)
`((span ([class "tocsublinknumber"])
,@(format-number
(collected-info-number
(part-collected-info p ri))
'((tt nbsp)))))
'(""))
,@(if (toc-element? p)
(render-content (toc-element-toc-content p)
d ri)
(parameterize ([current-no-links #t]
[extra-breaking? #t])
`((a ([href
,(format
"#~a"
(anchor-name
(add-current-tag-prefix
(tag-key (if (part? p)
(car (part-tags p))
(target-element-tag p))
ri))))]
[class
,(cond
[(part? p) "tocsubseclink"]
[any-parts? "tocsubnonseclink"]
[else "tocsublink"])]
[pltdoc "x"])
,@(render-content
(if (part? p)
(or (part-title-content p)
"???")
(element-content p))
d ri))))))))
(let ([p (car p)]
[prefixes (cdr p)]
[add-tag-prefixes
(lambda (t prefixes)
(if (null? prefixes)
t
(cons (car t) (append prefixes (cdr t)))))])
`(tr
(td
,@(if (part? p)
`((span ([class "tocsublinknumber"])
,@(format-number
(collected-info-number
(part-collected-info p ri))
'((tt nbsp)))))
'(""))
,@(if (toc-element? p)
(render-content (toc-element-toc-content p)
d ri)
(parameterize ([current-no-links #t]
[extra-breaking? #t])
`((a ([href
,(format
"#~a"
(anchor-name
(add-tag-prefixes
(tag-key (if (part? p)
(car (part-tags p))
(target-element-tag p))
ri)
prefixes)))]
[class
,(cond
[(part? p) "tocsubseclink"]
[any-parts? "tocsubnonseclink"]
[else "tocsublink"])]
[pltdoc "x"])
,@(render-content
(if (part? p)
(or (part-title-content p)
"???")
(element-content p))
d ri)))))))))
ps))))))))
(define/public (extract-part-body-id d ri)

View File

@ -3,3 +3,7 @@
(define mzscheme-launcher-names '("scribble"))
(define mzscheme-launcher-libraries '("run.ss"))
(define compile-omit-paths '("test-reader.ss"))
(define raco-commands
'(("scribble" scribble/run "render a Scribble document" #f)))

View File

@ -0,0 +1,3 @@
#lang s-exp scribble/base/reader
scribble/jfp/lang
#:wrapper1 (lambda (t) (cons 'doc (t)))

View File

@ -1,15 +0,0 @@
#lang s-exp syntax/module-reader
scribble/jfp/lang
#:read scribble:read-inside
#:read-syntax scribble:read-syntax-inside
#:whole-body-readers? #t
#:wrapper1 (lambda (t) (cons 'doc (t)))
#:info (lambda (key defval default)
(case key
[(color-lexer)
(dynamic-require 'syntax-color/scribble-lexer 'scribble-inside-lexer)]
[else (default key defval)]))
(require (prefix-in scribble: "../../reader.ss"))

View File

@ -0,0 +1,16 @@
#lang s-exp syntax/module-reader
scribble/lp/lang/lang
#:read read-inside
#:read-syntax read-syntax-inside
#:whole-body-readers? #t
#:info (scribble-base-info)
#:language-info (scribble-base-language-info)
(require scribble/reader
(only-in scribble/base/reader
scribble-base-info
scribble-base-language-info))

View File

@ -1,9 +0,0 @@
#lang s-exp syntax/module-reader
scribble/lp/lang/lang
#:read read-inside
#:read-syntax read-syntax-inside
#:whole-body-readers? #t
(require scribble/reader)

View File

@ -23,8 +23,9 @@
"private/manual-bib.ss"
"private/manual-form.ss"
"private/manual-class.ss"
"private/manual-unit.ss"
"private/manual-vars.ss")
"private/manual-unit.ss")
(except-out (all-from-out "private/manual-vars.ss")
*deftogether)
(except-out (all-from-out "private/manual-proc.ss")
*defthing))

View File

@ -0,0 +1,3 @@
#lang s-exp scribble/base/reader
scribble/manual/lang
#:wrapper1 (lambda (t) (cons 'doc (t)))

View File

@ -1,17 +0,0 @@
#lang s-exp syntax/module-reader
scribble/manual/lang
#:read scribble:read-inside
#:read-syntax scribble:read-syntax-inside
#:whole-body-readers? #t
#:wrapper1 (lambda (t) (cons 'doc (t)))
#:info (lambda (key defval default)
(case key
[(color-lexer)
(dynamic-require 'syntax-color/scribble-lexer 'scribble-inside-lexer)]
[(drscheme:toolbar-buttons)
(dynamic-require 'scribble/tools/drscheme-buttons 'drscheme-buttons)]
[else (default key defval)]))
(require (prefix-in scribble: "../../reader.ss"))

View File

@ -20,12 +20,14 @@
(provide defform defform* defform/subs defform*/subs defform/none
defidform
defidform defidform/inline
specform specform/subs
specsubform specsubform/subs specspecsubform specspecsubform/subs
specsubform/inline
defsubform defsubform*
schemegrammar schemegrammar*
racketgrammar racketgrammar*
(rename-out [racketgrammar schemegrammar]
[racketgrammar* schemegrammar*])
var svar)
(define-syntax (defform*/subs stx)
@ -171,6 +173,12 @@
(syntax/loc stx
(fm #:literals () spec desc ...))]))
(define-syntax (defidform/inline stx)
(syntax-case stx ()
[(_ id)
(identifier? #'id)
#'(defform-site (quote-syntax id))]))
(define-syntax (defidform stx)
(syntax-case stx ()
[(_ spec-id desc ...)
@ -269,32 +277,32 @@
([form/maybe (#f spec)])
(*specsubform 'spec null #f null null null (lambda () (list desc ...)))))
(define-syntax schemegrammar
(define-syntax racketgrammar
(syntax-rules ()
[(_ #:literals (lit ...) id clause ...)
(with-scheme-variables
(lit ...)
([non-term (id clause ...)])
(*schemegrammar '(lit ...)
(*racketgrammar '(lit ...)
'(id clause ...)
(lambda ()
(list (list (scheme id)
(schemeblock0/form clause) ...)))))]
[(_ id clause ...) (schemegrammar #:literals () id clause ...)]))
[(_ id clause ...) (racketgrammar #:literals () id clause ...)]))
(define-syntax schemegrammar*
(define-syntax racketgrammar*
(syntax-rules ()
[(_ #:literals (lit ...) [id clause ...] ...)
(with-scheme-variables
(lit ...)
([non-term (id clause ...)] ...)
(*schemegrammar '(lit ...)
(*racketgrammar '(lit ...)
'(id ... clause ... ...)
(lambda ()
(list (list (scheme id) (schemeblock0/form clause) ...)
...))))]
[(_ [id clause ...] ...)
(schemegrammar* #:literals () [id clause ...] ...)]))
(racketgrammar* #:literals () [id clause ...] ...)]))
(define-syntax-rule (var id)
(*var 'id))
@ -305,6 +313,29 @@
(define (meta-symbol? s) (memq s '(... ...+ ?)))
(define (defform-site kw-id)
(let ([target-maker (id-to-form-target-maker kw-id #t)]
[content (list (definition-site (syntax-e kw-id)
kw-id #t))])
(if target-maker
(target-maker
content
(lambda (tag)
(make-toc-target-element
#f
(if kw-id
(list (make-index-element
#f content tag
(list (symbol->string (syntax-e kw-id)))
content
(with-exporting-libraries
(lambda (libs)
(make-form-index-desc (syntax-e kw-id)
libs)))))
content)
tag)))
(car content))))
(define (*defforms kw-id forms form-procs subs sub-procs contract-procs content-thunk)
(parameterize ([current-meta-list '(... ...+)])
(make-box-splice
@ -323,27 +354,7 @@
(list (to-element `(,x . ,(cdr form)))))))
(and kw-id
(eq? form (car forms))
(let ([target-maker (id-to-form-target-maker kw-id #t)]
[content (list (definition-site (syntax-e kw-id)
kw-id #t))])
(if target-maker
(target-maker
content
(lambda (tag)
(make-toc-target-element
#f
(if kw-id
(list (make-index-element
#f content tag
(list (symbol->string (syntax-e kw-id)))
content
(with-exporting-libraries
(lambda (libs)
(make-form-index-desc (syntax-e kw-id)
libs)))))
content)
tag)))
(car content)))))))))
(defform-site kw-id)))))))
forms form-procs)
(if (null? sub-procs)
null
@ -409,7 +420,7 @@
(define (*schemerawgrammar style nonterm clause1 . clauses)
(*schemerawgrammars style (list nonterm) (list (cons clause1 clauses))))
(define (*schemegrammar lits s-expr clauseses-thunk)
(define (*racketgrammar lits s-expr clauseses-thunk)
(let ([l (clauseses-thunk)])
(*schemerawgrammars #f
(map (lambda (x)

View File

@ -1,4 +1,4 @@
#lang scheme/base
#lang racket/base
(require "../decode.ss"
"../struct.ss"
"../scheme.ss"
@ -16,11 +16,11 @@
"on-demand.ss"
scheme/string
scheme/list
(for-syntax scheme/base)
(for-label scheme/base
scheme/class))
(for-syntax racket/base)
(for-label racket/base
racket/class))
(provide defproc defproc* defstruct
(provide defproc defproc* defstruct defstruct*
defparam defparam* defboolparam
defthing defthing*
defthing/proc ; XXX unknown contract
@ -485,42 +485,90 @@
;; ----------------------------------------
(define-syntax defstruct
(syntax-rules ()
[(_ name fields #:mutable #:inspector #f desc ...)
(**defstruct name fields #f #t #f desc ...)]
[(_ name fields #:mutable #:transparent desc ...)
(**defstruct name fields #f #t #f desc ...)]
[(_ name fields #:mutable #:prefab desc ...)
(**defstruct name fields #f #t #t desc ...)]
[(_ name fields #:mutable desc ...)
(**defstruct name fields #f #f #f desc ...)]
[(_ name fields #:inspector #f desc ...)
(**defstruct name fields #t #t #f desc ...)]
[(_ name fields #:transparent desc ...)
(**defstruct name fields #t #t #f desc ...)]
[(_ name fields #:prefab desc ...)
(**defstruct name fields #t #t #t desc ...)]
[(_ name fields desc ...)
(**defstruct name fields #t #f #f desc ...)]))
(define-syntax-rule (define-defstruct defstruct default-cname)
(...
(define-syntax defstruct
(syntax-rules ()
[(_ name fields #:constructor-name cname #:mutable #:inspector #f desc ...)
(**defstruct name fields #f #t #f cname #f desc ...)]
[(_ name fields #:extra-constructor-name cname #:mutable #:inspector #f desc ...)
(**defstruct name fields #f #t #f cname #t desc ...)]
[(_ name fields #:mutable #:inspector #f desc ...)
(**defstruct name fields #f #t #f default-cname #t desc ...)]
[(_ name fields #:constructor-name cname #:mutable #:transparent desc ...)
(**defstruct name fields #f #t #f cname #f desc ...)]
[(_ name fields #:extra-constructor-name cname #:mutable #:transparent desc ...)
(**defstruct name fields #f #t #f cname #t desc ...)]
[(_ name fields #:mutable #:transparent desc ...)
(**defstruct name fields #f #t #f default-cname #t desc ...)]
[(_ name fields #:constructor-name cname #:mutable #:prefab desc ...)
(**defstruct name fields #f #t #t cname #f desc ...)]
[(_ name fields #:extra-constructor-name cname #:mutable #:prefab desc ...)
(**defstruct name fields #f #t #t cname #t desc ...)]
[(_ name fields #:mutable #:prefab desc ...)
(**defstruct name fields #f #t #t default-cname #t desc ...)]
[(_ name fields #:constructor-name cname #:mutable desc ...)
(**defstruct name fields #f #f #f cname #f desc ...)]
[(_ name fields #:extra-constructor-name cname #:mutable desc ...)
(**defstruct name fields #f #f #f cname #t desc ...)]
[(_ name fields #:mutable desc ...)
(**defstruct name fields #f #f #f default-cname #f desc ...)]
[(_ name fields #:constructor-name cname #:inspector #f desc ...)
(**defstruct name fields #t #t #f cname #f desc ...)]
[(_ name fields #:extra-constructor-name cname #:inspector #f desc ...)
(**defstruct name fields #t #t #f cname #t desc ...)]
[(_ name fields #:inspector #f desc ...)
(**defstruct name fields #t #t #f default-cname #t desc ...)]
[(_ name fields #:constructor-name cname #:transparent desc ...)
(**defstruct name fields #t #t #f cname #f desc ...)]
[(_ name fields #:extra-constructor-name cname #:transparent desc ...)
(**defstruct name fields #t #t #f cname #t desc ...)]
[(_ name fields #:transparent desc ...)
(**defstruct name fields #t #t #f default-cname #t desc ...)]
[(_ name fields #:constructor-name cname #:prefab desc ...)
(**defstruct name fields #t #t #t cname #f desc ...)]
[(_ name fields #:extra-constructor-name cname #:prefab desc ...)
(**defstruct name fields #t #t #t cname #t desc ...)]
[(_ name fields #:prefab desc ...)
(**defstruct name fields #t #t #t default-cname #t desc ...)]
[(_ name fields #:constructor-name cname desc ...)
(**defstruct name fields #t #f #f cname #f desc ...)]
[(_ name fields #:extra-constructor-name cname desc ...)
(**defstruct name fields #t #f #f cname #t desc ...)]
[(_ name fields desc ...)
(**defstruct name fields #t #f #f default-cname #t desc ...)]))))
(define-defstruct defstruct #t)
(define-defstruct defstruct* #f)
(define-syntax-rule (**defstruct name ([field field-contract] ...) immutable?
transparent? prefab? desc ...)
transparent? prefab? cname extra-cname? desc ...)
(with-togetherable-scheme-variables
()
()
(*defstruct (quote-syntax/loc name) 'name
(*defstruct (quote-syntax/loc name) 'name (quote-syntax/loc cname) extra-cname?
'([field field-contract] ...)
(list (lambda () (schemeblock0 field-contract)) ...)
immutable? transparent? prefab? (lambda () (list desc ...)))))
(define (*defstruct stx-id name fields field-contracts immutable? transparent? prefab?
(define (*defstruct stx-id name alt-cname-id extra-cname?
fields field-contracts immutable? transparent? prefab?
content-thunk)
(define (field-name f) ((if (pair? (car f)) caar car) f))
(define (field-view f)
(if (pair? (car f)) (make-shaped-parens (car f) #\[) (car f)))
(make-box-splice
(cons
(define cname-id
(cond
[(identifier? alt-cname-id) alt-cname-id]
[(not (syntax-e alt-cname-id)) #f]
[else (let ([name-id (if (identifier? stx-id)
stx-id
(car (syntax-e stx-id)))])
(datum->syntax name-id
(string->symbol (format "make-~a" (syntax-e name-id)))
name-id
name-id))]))
(define main-table
(make-table
'boxed
(cons
@ -543,8 +591,10 @@
(list* (list 'info name)
(list 'type 'struct: name)
(list 'predicate name '?)
(list 'constructor 'make- name)
(append
(if cname-id
(list (list 'constructor (syntax-e cname-id)))
null)
(map (lambda (f)
(list 'accessor name '-
(field-name f)))
@ -560,11 +610,15 @@
#f))
fields)))))])
(if (pair? name)
(to-element (list just-name
(make-just-context
(cadr name)
(cadr (syntax-e stx-id)))))
just-name))]
(make-element
#f
(list just-name
(hspace 1)
(to-element
(make-just-context
(cadr name)
(cadr (syntax-e stx-id))))))
just-name))]
[short-width
(apply + (length fields) 8
(append
@ -580,93 +634,111 @@
fields)))])
(if (and (short-width . < . max-proto-width)
immutable?
(not transparent?))
(not transparent?)
(not cname-id))
(make-omitable-paragraph
(list
(to-element
`(,(schemeparenfont "struct")
`(,(scheme struct)
,the-name
,(map field-view fields)))))
(make-table
#f
(append
(list
(list (to-flow (schemeparenfont "(struct"))
flow-spacer
(to-flow the-name)
(if (or (null? fields)
(short-width . < . max-proto-width))
flow-spacer
(to-flow (make-element
#f (list spacer (schemeparenfont "(")))))
(to-flow (if (or (null? fields)
(short-width . < . max-proto-width))
(make-element
#f (cons (to-element (map field-view
fields))
(if (and immutable?
(not transparent?))
(list (schemeparenfont ")"))
null)))
(to-element (field-view (car fields)))))))
(if (short-width . < . max-proto-width)
null
(let loop ([fields (if (null? fields)
fields (cdr fields))])
(if (null? fields)
(let* ([one-right-column?
(or (null? fields)
(short-width . < . max-proto-width))]
[a-right-column
(lambda (c)
(if one-right-column?
(list flow-spacer flow-spacer c)
(list flow-spacer flow-spacer c 'cont 'cont)))])
(make-table
#f
(append
(list
(append
(list (to-flow (make-element #f
(list
(schemeparenfont "(")
(scheme struct))))
flow-spacer)
(if one-right-column?
(list (to-flow (make-element
#f
(list* the-name
spacer
(to-element (map field-view
fields))
(if (and immutable?
(not transparent?)
(not cname-id))
(list (schemeparenfont ")"))
null)))))
(list (to-flow the-name)
(to-flow (make-element
#f (list spacer (schemeparenfont "("))))
(to-flow (to-element (field-view (car fields))))))))
(if (short-width . < . max-proto-width)
null
(cons
(let ([fld (car fields)])
(list flow-spacer flow-spacer
flow-spacer flow-spacer
(to-flow
(let ([e (to-element (field-view fld))])
(if (null? (cdr fields))
(make-element
#f
(list e (schemeparenfont
(if (and immutable?
(not transparent?))
"))" ")"))))
e)))))
(loop (cdr fields))))))
(cond
[(and (not immutable?) transparent?)
(list
(list flow-spacer flow-spacer
(to-flow (to-element '#:mutable))
'cont
'cont)
(list flow-spacer flow-spacer
(to-flow (make-element
#f
(list (if prefab?
(to-element '#:prefab)
(to-element '#:transparent))
(schemeparenfont ")"))))
'cont
'cont))]
[(not immutable?)
(list
(list flow-spacer flow-spacer
(to-flow (make-element
#f
(list (to-element '#:mutable)
(schemeparenfont ")"))))
'cont
'cont))]
[transparent?
(list
(list flow-spacer flow-spacer
(to-flow (make-element
#f
(list (if prefab?
(to-element '#:prefab)
(to-element '#:transparent))
(schemeparenfont ")"))))
'cont
'cont))]
[else null]))))))))
(let loop ([fields (if (null? fields)
fields (cdr fields))])
(if (null? fields)
null
(cons
(let ([fld (car fields)])
(list flow-spacer flow-spacer
flow-spacer flow-spacer
(to-flow
(let ([e (to-element (field-view fld))])
(if (null? (cdr fields))
(make-element
#f
(list e (schemeparenfont
(if (and immutable?
(not transparent?)
(not cname-id))
"))"
")"))))
e)))))
(loop (cdr fields))))))
(if cname-id
(list (a-right-column
(to-flow (make-element
#f
(append
(list (to-element (if extra-cname?
'#:extra-constructor-name
'#:constructor-name))
(hspace 1)
(to-element cname-id))
(if (and immutable?
(not transparent?))
(list (schemeparenfont ")"))
null))))))
null)
(cond
[(and (not immutable?) transparent?)
(list
(a-right-column (to-flow (to-element '#:mutable)))
(a-right-column (to-flow (make-element
#f
(list (if prefab?
(to-element '#:prefab)
(to-element '#:transparent))
(schemeparenfont ")"))))))]
[(not immutable?)
(list
(a-right-column (to-flow (make-element
#f
(list (to-element '#:mutable)
(schemeparenfont ")"))))))]
[transparent?
(list
(a-right-column (to-flow (make-element
#f
(list (if prefab?
(to-element '#:prefab)
(to-element '#:transparent))
(schemeparenfont ")"))))))]
[else null])))))))))
(map (lambda (v field-contract)
(cond
[(pair? v)
@ -681,7 +753,10 @@
flow-spacer
(make-flow (list (field-contract))))))))]
[else null]))
fields field-contracts)))
fields field-contracts))))
(make-box-splice
(cons
main-table
(content-thunk))))
;; ----------------------------------------
@ -702,49 +777,87 @@
(list (schemeblock0 result) ...)
(lambda () (list desc ...)))))
(define (*defthing stx-ids names form? result-contracts content-thunk)
(define (*defthing stx-ids names form? result-contracts content-thunk
[result-values (map (lambda (x) #f) result-contracts)])
(make-box-splice
(cons
(make-table
'boxed
(map
(lambda (stx-id name result-contract)
(lambda (stx-id name result-contract result-value)
(list
(make-flow
(make-table-if-necessary
"argcontract"
(list
(let* ([result-block
(and result-value
(if (block? result-value)
result-value
(make-omitable-paragraph (list result-value))))]
[contract-block
(if (block? result-contract)
result-contract
(make-omitable-paragraph (list result-contract)))]
[total-width (+ (string-length (format "~a" name))
3
(block-width contract-block)
(if result-block
(+ (block-width result-block) 3)
0))])
(append
(list
(make-flow
(append
(list
(make-omitable-paragraph
(make-flow
(list
(let ([target-maker
((if form? id-to-form-target-maker id-to-target-maker)
stx-id #t)]
[content (list (definition-site name stx-id form?))])
(if target-maker
(target-maker
content
(lambda (tag)
(make-toc-target-element
#f
(list
(make-index-element
#f
content
tag
(list (symbol->string name))
content
(with-exporting-libraries
(lambda (libs) (make-thing-index-desc name libs)))))
tag)))
(car content)))
spacer ":" spacer))))
(make-flow (list (if (block? result-contract)
result-contract
(make-omitable-paragraph (list result-contract)))))))))))
stx-ids names result-contracts))
(make-omitable-paragraph
(list
(let ([target-maker
((if form? id-to-form-target-maker id-to-target-maker)
stx-id #t)]
[content (list (definition-site name stx-id form?))])
(if target-maker
(target-maker
content
(lambda (tag)
(make-toc-target-element
#f
(list
(make-index-element
#f
content
tag
(list (symbol->string name))
content
(with-exporting-libraries
(lambda (libs) (make-thing-index-desc name libs)))))
tag)))
(car content)))))))
(make-flow
(list
(make-omitable-paragraph
(list
spacer ":" spacer))))
(make-flow (list contract-block)))
(if (and result-value
(total-width . < . 60))
(list
(to-flow (make-element #f (list spacer "=" spacer)))
(make-flow (list result-block)))
null)))
(if (and result-value
(total-width . >= . 60))
(list
(list
(make-table-if-necessary
"argcontract"
(list
(list flow-spacer
(to-flow (make-element #f (list spacer "=" spacer)))
(make-flow (list result-block)))))
'cont))
null)))))))
stx-ids names result-contracts result-values))
(content-thunk))))
(define (defthing/proc id contract descs)

View File

@ -1,38 +1,57 @@
#lang scheme/base
#lang racket/base
(require "../decode.ss"
"../struct.ss"
"../scheme.ss"
"../search.ss"
"../basic.ss"
scheme/list
racket/list
"manual-utils.ss"
"manual-style.ss"
(for-syntax scheme/base)
(for-label scheme/base))
(for-syntax racket/base)
(for-label racket/base))
(provide schemeblock SCHEMEBLOCK schemeblock/form
schemeblock0 SCHEMEBLOCK0 schemeblock0/form
schemeblockelem
schemeinput
schememod
scheme SCHEME scheme/form schemeresult schemeid
schememodname
schememodlink indexed-scheme
schemelink)
(provide racketblock RACKETBLOCK racketblock/form
racketblock0 RACKETBLOCK0 racketblock0/form
racketblockelem
racketinput
racketmod
racket RACKET racket/form racketresult racketid
racketmodname
racketmodlink indexed-racket
racketlink
(rename-out [racketblock schemeblock]
[RACKETBLOCK SCHEMEBLOCK]
[racketblock/form schemeblock/form]
[racketblock0 schemeblock0]
[RACKETBLOCK0 SCHEMEBLOCK0]
[racketblock0/form schemeblock0/form]
[racketblockelem schemeblockelem]
[racketinput schemeinput]
[racketmod schememod]
[racket scheme]
[RACKET SCHEME]
[racket/form scheme/form]
[racketresult schemeresult]
[racketid schemeid]
[racketmodname schememodname]
[racketmodlink schememodlink]
[indexed-racket indexed-scheme]
[racketlink schemelink]))
(define-code schemeblock0 to-paragraph)
(define-code schemeblock (to-paragraph/prefix (hspace 2) (hspace 2) ""))
(define-code SCHEMEBLOCK (to-paragraph/prefix (hspace 2) (hspace 2) "")
(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 SCHEMEBLOCK0 to-paragraph UNSYNTAX)
(define-code RACKETBLOCK0 to-paragraph UNSYNTAX)
(define interaction-prompt (make-element 'tt (list "> " )))
(define-code schemeinput
(define-code racketinput
(to-paragraph/prefix
(make-element #f (list (hspace 2) interaction-prompt))
(hspace 4)
""))
(define-syntax (schememod stx)
(define-syntax (racketmod stx)
(syntax-case stx ()
[(_ #:file filename lang rest ...)
(with-syntax ([modtag (datum->syntax
@ -41,9 +60,11 @@
#f
(list (hash-lang)
spacer
(as-modname-link
',#'lang
(to-element ',#'lang)))))
,(if (identifier? #'lang)
`(as-modname-link
',#'lang
(to-element ',#'lang))
#'(racket lang)))))
#'lang)]
[(file ...)
(if (syntax-e #'filename)
@ -53,9 +74,9 @@
`(code:comment (unsyntax (t "In \"" ,(syntax-e #'filename) "\":")))
#'filename))
null)])
(syntax/loc stx (schemeblock file ... modtag rest ...)))]
(syntax/loc stx (racketblock file ... modtag rest ...)))]
[(_ lang rest ...)
(syntax/loc stx (schememod #:file #f lang rest ...))]))
(syntax/loc stx (racketmod #:file #f lang rest ...))]))
(define (to-element/result s)
(make-element result-color (list (to-element/no-color s))))
@ -89,25 +110,25 @@
(make-shaped-parens s val)
s))
(define-code schemeblockelem to-element)
(define-code racketblockelem to-element)
(define-code scheme to-element unsyntax keep-s-expr add-sq-prop)
(define-code SCHEME to-element UNSYNTAX keep-s-expr add-sq-prop)
(define-code schemeresult to-element/result unsyntax keep-s-expr add-sq-prop)
(define-code schemeid to-element/id unsyntax keep-s-expr add-sq-prop)
(define-code *schememodname to-element unsyntax keep-s-expr add-sq-prop)
(define-code racket to-element unsyntax keep-s-expr add-sq-prop)
(define-code RACKET to-element UNSYNTAX keep-s-expr add-sq-prop)
(define-code racketresult to-element/result unsyntax keep-s-expr add-sq-prop)
(define-code racketid to-element/id unsyntax keep-s-expr add-sq-prop)
(define-code *racketmodname to-element unsyntax keep-s-expr add-sq-prop)
(define-syntax schememodname
(define-syntax racketmodname
(syntax-rules (unsyntax)
[(schememodname #,n)
[(racketmodname #,n)
(let ([sym n])
(as-modname-link sym (to-element sym)))]
[(schememodname n)
(as-modname-link 'n (*schememodname n))]))
[(racketmodname n)
(as-modname-link 'n (*racketmodname n))]))
(define-syntax schememodlink
(define-syntax racketmodlink
(syntax-rules (unsyntax)
[(schememodlink n content ...)
[(racketmodlink n content ...)
(*as-modname-link 'n (elem #:style #f content ...))]))
(define (as-modname-link s e)
@ -120,10 +141,10 @@
(list e)
`(mod-path ,(format "~s" s))))
(define-syntax-rule (indexed-scheme x)
(add-scheme-index 'x (scheme x)))
(define-syntax-rule (indexed-racket x)
(add-racket-index 'x (racket x)))
(define (add-scheme-index s e)
(define (add-racket-index s e)
(let ([k (cond [(and (pair? s) (eq? (car s) 'quote)) (format "~s" (cadr s))]
[(string? s) s]
[else (format "~s" s)])])
@ -137,11 +158,11 @@
#'(let ([ellipses #f])
(base a)))])))
(define-/form schemeblock0/form schemeblock0)
(define-/form schemeblock/form schemeblock)
(define-/form scheme/form scheme)
(define-/form racketblock0/form racketblock0)
(define-/form racketblock/form racketblock)
(define-/form racket/form racket)
(define (*schemelink stx-id id . s)
(define (*racketlink stx-id id . s)
(let ([content (decode-content s)])
(make-delayed-element
(lambda (r p ri)
@ -149,11 +170,11 @@
(make-link-element
#f
content
(or (find-scheme-tag p ri stx-id #f)
(or (find-racket-tag p ri stx-id #f)
`(undef ,(format "--UNDEFINED:~a--" (syntax-e stx-id)))))))
(lambda () content)
(lambda () content))))
(define-syntax-rule (schemelink id . content)
(*schemelink (quote-syntax id) 'id . content))
(define-syntax-rule (racketlink id . content)
(*racketlink (quote-syntax id) 'id . content))

View File

@ -1,4 +1,4 @@
#lang scheme/base
#lang racket/base
(require "../decode.ss"
"../struct.ss"
"../base.ss"
@ -7,9 +7,9 @@
(only-in "../core.ss" make-style plain)
"manual-utils.ss"
"on-demand.ss"
scheme/list
scheme/contract
scheme/string)
racket/list
racket/contract
racket/string)
(provide (rename-out [hyperlink link])
(rename-out [other-doc other-manual])
@ -23,12 +23,26 @@
(() () #:rest (listof pre-content?) . ->* . element?))
(define-syntax-rule (provide-styling id ...)
(provide/contract [id styling-f/c] ...))
(provide-styling schememodfont schemeoutput
schemeerror schemefont schemevalfont schemeresultfont schemeidfont schemevarfont
schemeparenfont schemekeywordfont schememetafont
(provide-styling racketmodfont racketoutput
racketerror racketfont racketvalfont racketresultfont racketidfont racketvarfont
racketparenfont racketkeywordfont racketmetafont
onscreen defterm filepath exec envvar Flag DFlag PFlag DPFlag math
procedure
indexed-file indexed-envvar idefterm pidefterm)
(define-syntax-rule (provide-scheme-styling [rid sid] ...)
(provide/contract [rename rid sid styling-f/c] ...))
(provide-scheme-styling [racketmodfont schememodfont]
[racketoutput schemeoutput]
[racketerror schemeerror]
[racketfont schemefont]
[racketvalfont schemevalfont]
[racketresultfont schemeresultfont]
[racketidfont schemeidfont]
[racketvarfont schemevarfont]
[racketparenfont schemeparenfont]
[racketkeywordfont schemekeywordfont]
[racketmetafont schememetafont])
(provide void-const
undefined-const)
(provide/contract
@ -68,23 +82,23 @@
(define (idefterm . str)
(let ([c (decode-content str)])
(make-element 'italic c)))
(define (schemefont . str)
(define (racketfont . str)
(apply tt str))
(define (schemevalfont . str)
(define (racketvalfont . str)
(make-element value-color (decode-content str)))
(define (schemeresultfont . str)
(define (racketresultfont . str)
(make-element result-color (decode-content str)))
(define (schemeidfont . str)
(define (racketidfont . str)
(make-element symbol-color (decode-content str)))
(define (schemevarfont . str)
(define (racketvarfont . str)
(make-element variable-color (decode-content str)))
(define (schemeparenfont . str)
(define (racketparenfont . str)
(make-element paren-color (decode-content str)))
(define (schememetafont . str)
(define (racketmetafont . str)
(make-element meta-color (decode-content str)))
(define (schememodfont . str)
(define (racketmodfont . str)
(make-element module-color (decode-content str)))
(define (schemekeywordfont . str)
(define (racketkeywordfont . str)
(make-element keyword-color (decode-content str)))
(define (filepath . str)
(make-element 'tt (append (list "\"") (decode-content str) (list "\""))))
@ -124,9 +138,9 @@
(define (procedure . str)
(make-element result-color `("#<procedure:" ,@(decode-content str) ">")))
(define (schemeoutput . str)
(define (racketoutput . str)
(make-element output-color (decode-content str)))
(define (schemeerror . str)
(define (racketerror . str)
(make-element error-color (decode-content str)))
(define (t . str)
@ -150,13 +164,13 @@
(define (hash-lang)
(make-link-element
module-link-color
(list (schememodfont "#lang"))
(list (racketmodfont "#lang"))
`(part ,(doc-prefix '(lib "scribblings/guide/guide.scrbl") "hash-lang"))))
(define-on-demand void-const
(schemeresultfont "#<void>"))
(racketresultfont "#<void>"))
(define-on-demand undefined-const
(schemeresultfont "#<undefined>"))
(racketresultfont "#<undefined>"))
(define (link url
#:underline? [underline? #t]

View File

@ -14,7 +14,7 @@
(provide/contract
[struct (box-splice splice) ([run list?])]) ; XXX ugly copying
(provide deftogether
(provide deftogether *deftogether
with-scheme-variables
with-togetherable-scheme-variables)
@ -109,7 +109,7 @@
(define (*deftogether boxes body-thunk)
(make-splice
(make-box-splice
(cons
(make-table
'boxed

1254
collects/scribble/racket.rkt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
#lang scheme/base
#lang racket/base
(require "core.ss"
"base-render.ss"
@ -6,6 +6,7 @@
scheme/cmdline
scheme/file
scheme/class
raco/command-name
(prefix-in text: "text-render.ss")
(prefix-in html: "html-render.ss")
(prefix-in latex: "latex-render.ss")
@ -33,11 +34,14 @@
(let ([v (read i)])
(and (eof-object? (read i)) v)))))
(current-render-mixin html:render-mixin)
(define (run)
(command-line
#:program (short-program+command-name)
#:once-any
[("--text") "generate text-format output (the default)"
(void)]
(current-render-mixin text:render-mixin)]
[("--html") "generate HTML-format output file"
(current-render-mixin html:render-mixin)]
[("--htmls") "generate HTML-format output directory"

View File

@ -0,0 +1,3 @@
#lang racket/base
(require "racket.ss")
(provide (all-from-out "racket.ss"))

View File

@ -1,910 +0,0 @@
(module scheme scheme/base
(require "core.ss"
"basic.ss"
"search.ss"
"private/manual-sprop.ss"
"private/on-demand.ss"
mzlib/class
mzlib/for
syntax/modresolve
syntax/modcode
(for-syntax scheme/base))
(provide define-code
to-element
to-element/no-color
to-paragraph
to-paragraph/prefix
syntax-ize
syntax-ize-hook
current-keyword-list
current-variable-list
current-meta-list
input-color
output-color
input-background-color
no-color
reader-color
result-color
keyword-color
comment-color
paren-color
meta-color
value-color
symbol-color
variable-color
opt-color
error-color
syntax-link-color
value-link-color
module-color
module-link-color
block-color
highlighted-color
(struct-out var-id)
(struct-out shaped-parens)
(struct-out just-context)
(struct-out alternate-display)
(struct-out literal-syntax)
(for-syntax make-variable-id
variable-id?
make-element-id-transformer
element-id-transformer?))
(define (make-scheme-style s #:tt? [tt? #t])
(make-style s (if tt?
(cons 'tt-chars scheme-properties)
scheme-properties)))
(define-on-demand output-color (make-scheme-style "ScmOut"))
(define-on-demand input-color (make-scheme-style "ScmIn"))
(define-on-demand input-background-color (make-scheme-style "ScmInBG"))
(define-on-demand no-color (make-scheme-style "ScmPlain"))
(define-on-demand reader-color (make-scheme-style "ScmRdr"))
(define-on-demand result-color (make-scheme-style "ScmRes"))
(define-on-demand keyword-color (make-scheme-style "ScmKw"))
(define-on-demand comment-color (make-scheme-style "ScmCmt"))
(define-on-demand paren-color (make-scheme-style "ScmPn"))
(define-on-demand meta-color (make-scheme-style "ScmMeta"))
(define-on-demand value-color (make-scheme-style "ScmVal"))
(define-on-demand symbol-color (make-scheme-style "ScmSym"))
(define-on-demand variable-color (make-scheme-style "ScmVar"))
(define-on-demand opt-color (make-scheme-style "ScmOpt"))
(define-on-demand error-color (make-scheme-style "ScmErr" #:tt? #f))
(define-on-demand syntax-link-color (make-scheme-style "ScmStxLink"))
(define-on-demand value-link-color (make-scheme-style "ScmValLink"))
(define-on-demand module-color (make-scheme-style "ScmMod"))
(define-on-demand module-link-color (make-scheme-style "ScmModLink"))
(define-on-demand block-color (make-scheme-style "ScmBlk"))
(define-on-demand highlighted-color (make-scheme-style "highlighted" #:tt? #f))
(define current-keyword-list
(make-parameter null))
(define current-variable-list
(make-parameter null))
(define current-meta-list
(make-parameter null))
(define defined-names (make-hasheq))
(define-struct (sized-element element) (length))
(define-struct (spaces element) (cnt))
(define (literalize-spaces i)
(let ([m (regexp-match-positions #rx" +" i)])
(if m
(let ([cnt (- (cdar m) (caar m))])
(make-spaces #f
(list
(literalize-spaces (substring i 0 (caar m)))
(hspace cnt)
(literalize-spaces (substring i (cdar m))))
cnt))
i)))
(define line-breakable-space (make-element 'tt " "))
;; These caches intentionally record a key with the value.
;; That way, when the value is no longer used, the key
;; goes away, and the entry is gone.
(define id-element-cache (make-weak-hash))
(define element-cache (make-weak-hash))
(define-struct (cached-delayed-element delayed-element) (cache-key))
(define-struct (cached-element element) (cache-key))
(define (make-id-element c s)
(let* ([key (and id-element-cache
(let ([b (identifier-label-binding c)])
(vector (syntax-e c)
(module-path-index->taglet (caddr b))
(cadddr b)
(list-ref b 5))))])
(or (and key
(let ([b (hash-ref id-element-cache key #f)])
(and b
(weak-box-value b))))
(let ([e (make-cached-delayed-element
(lambda (renderer sec ri)
(let* ([tag (find-scheme-tag sec ri c #f)])
(if tag
(list
(case (car tag)
[(form)
(make-link-element syntax-link-color (list s) tag)]
[else
(make-link-element value-link-color (list s) tag)]))
(list
(make-element "badlink"
(make-element value-link-color s))))))
(lambda () s)
(lambda () s)
key)])
(when key
(hash-set! id-element-cache key (make-weak-box e)))
e))))
(define (make-element/cache style content)
(if (and element-cache
(string? content))
(let ([key (vector style content)])
(let ([b (hash-ref element-cache key #f)])
(or (and b (weak-box-value b))
(let ([e (make-cached-element style content key)])
(hash-set! element-cache key (make-weak-box e))
e))))
(make-element style content)))
(define (typeset-atom c out color? quote-depth)
(if (and (var-id? (syntax-e c))
(zero? quote-depth))
(out (format "~s" (let ([v (var-id-sym (syntax-e c))])
(if (syntax? v)
(syntax-e v)
v)))
variable-color)
(let*-values ([(is-var?) (and (identifier? c)
(memq (syntax-e c) (current-variable-list)))]
[(s it? sub?)
(let ([sc (syntax-e c)])
(let ([s (or (syntax-property c 'display-string)
(format "~s" (if (literal-syntax? sc)
(literal-syntax-stx sc)
(if (var-id? sc)
(var-id-sym sc)
sc))))])
(if (and (symbol? sc)
((string-length s) . > . 1)
(char=? (string-ref s 0) #\_)
(not (or (identifier-label-binding c)
is-var?)))
(values (substring s 1) #t #f)
(values s #f #f))))])
(if (or (element? (syntax-e c))
(delayed-element? (syntax-e c))
(part-relative-element? (syntax-e c)))
(out (syntax-e c) #f)
(out (if (and (identifier? c)
color?
(quote-depth . <= . 0)
(not (or it? is-var?)))
(if (pair? (identifier-label-binding c))
(make-id-element c s)
s)
(literalize-spaces s))
(cond
[(positive? quote-depth) value-color]
[(let ([v (syntax-e c)])
(or (number? v)
(string? v)
(bytes? v)
(char? v)
(regexp? v)
(byte-regexp? v)
(boolean? v)))
value-color]
[(identifier? c)
(cond
[is-var?
variable-color]
[(and (identifier? c)
(memq (syntax-e c) (current-keyword-list)))
keyword-color]
[(and (identifier? c)
(memq (syntax-e c) (current-meta-list)))
meta-color]
[it? variable-color]
[else symbol-color])]
[else paren-color])
(string-length s))))))
(define omitable (make-style #f '(omitable)))
(define (gen-typeset c multi-line? prefix1 prefix suffix color?)
(let* ([c (syntax-ize c 0)]
[content null]
[docs null]
[first (syntax-case c (code:line)
[(code:line e . rest) #'e]
[else c])]
[init-col (or (syntax-column first) 0)]
[src-col init-col]
[dest-col 0]
[highlight? #f]
[col-map (make-hash)]
[next-col-map (make-hash)]
[line (or (syntax-line first) 0)])
(define (finish-line!)
(when multi-line?
(set! docs (cons (make-paragraph omitable (reverse content))
docs))
(set! content null)))
(define out
(case-lambda
[(v cls)
(out v cls (let sz-loop ([v v])
(cond
[(string? v) (string-length v)]
[(list? v) (for/fold ([s 0]) ([v (in-list v)]) (+ s (sz-loop v)))]
[(sized-element? v) (sized-element-length v)]
[(element? v)
(sz-loop (element-content v))]
[(delayed-element? v)
(content-width v)]
[(part-relative-element? v)
(content-width v)]
[(spaces? v)
(+ (sz-loop (car (element-content v)))
(spaces-cnt v)
(sz-loop (caddr (element-content v))))]
[else 1])))]
[(v cls len)
(unless (equal? v "")
(cond
[(spaces? v)
(out (car (element-content v)) cls 0)
(out (cadr (element-content v)) #f 0)
(out (caddr (element-content v)) cls len)]
[(equal? v "\n")
(if multi-line?
(begin
(finish-line!)
(out prefix cls))
(out " " cls))]
[else
(set! content (cons ((if highlight?
(lambda (c)
(make-element highlighted-color c))
values)
(if (and color? cls)
(make-element/cache cls v)
v))
content))
(set! dest-col (+ dest-col len))]))]))
(define advance
(case-lambda
[(c init-line! delta)
(let ([c (+ delta (or (syntax-column c) 0))]
[l (syntax-line c)])
(let ([new-line? (and l (l . > . line))])
(when new-line?
(for ([i (in-range (- l line))])
(out "\n" no-color))
(set! line l)
(set! col-map next-col-map)
(set! next-col-map (make-hash))
(init-line!))
(let ([d-col (let ([def-val (+ dest-col (- c src-col))])
(if new-line?
(hash-ref col-map c def-val)
def-val))])
(let ([amt (- d-col dest-col)])
(when (positive? amt)
(let ([old-dest-col dest-col])
(out (if (and (= 1 amt) (not multi-line?))
line-breakable-space ; allows a line break to replace the space
(hspace amt))
#f)
(set! dest-col (+ old-dest-col amt))))))
(set! src-col c)
(hash-set! next-col-map src-col dest-col)))]
[(c init-line!) (advance c init-line! 0)]))
(define (convert-infix c quote-depth)
(let ([l (syntax->list c)])
(and l
((length l) . >= . 3)
((or (syntax-position (car l)) -inf.0)
. > .
(or (syntax-position (cadr l)) +inf.0))
(let ([a (car l)])
(let loop ([l (cdr l)]
[prev null])
(cond
[(null? l) #f] ; couldn't unwind
[else (let ([p2 (syntax-position (car l))])
(if (and p2
(p2 . > . (syntax-position a)))
(datum->syntax c
(append
(reverse prev)
(list
(datum->syntax
a
(let ([val? (positive? quote-depth)])
(make-sized-element
(if val? value-color #f)
(list
(make-element/cache (if val? value-color paren-color) '". ")
(typeset a #f "" "" "" (not val?))
(make-element/cache (if val? value-color paren-color) '" ."))
(+ (syntax-span a) 4)))
(list (syntax-source a)
(syntax-line a)
(- (syntax-column a) 2)
(- (syntax-position a) 2)
(+ (syntax-span a) 4))
a))
l)
c
c)
(loop (cdr l)
(cons (car l) prev))))]))))))
(define (no-fancy-chars s)
(cond
[(eq? s 'rsquo) "'"]
[else s]))
(define (loop init-line! quote-depth)
(lambda (c)
(cond
[(eq? 'code:blank (syntax-e c))
(advance c init-line!)]
[(and (pair? (syntax-e c))
(eq? (syntax-e (car (syntax-e c))) 'code:comment))
(let ([l (syntax->list c)])
(unless (and l (= 2 (length l)))
(raise-syntax-error
#f
"does not have a single sub-form"
c)))
(advance c init-line!)
(out ";" comment-color)
(out 'nbsp comment-color)
(let ([v (syntax->datum (cadr (syntax->list c)))])
(if (paragraph? v)
(map (lambda (v)
(let ([v (no-fancy-chars v)])
(if (or (string? v) (symbol? v))
(out v comment-color)
(out v #f))))
(paragraph-content v))
(out (no-fancy-chars v) comment-color)))]
[(and (pair? (syntax-e c))
(eq? (syntax-e (car (syntax-e c))) 'code:contract))
(advance c init-line!)
(out "; " comment-color)
(let* ([l (cdr (syntax->list c))]
[s-col (or (syntax-column (car l)) src-col)])
(set! src-col s-col)
(for-each (loop (lambda ()
(set! src-col s-col)
(set! dest-col 0)
(out "; " comment-color))
0)
l))]
[(and (pair? (syntax-e c))
(eq? (syntax-e (car (syntax-e c))) 'code:line))
(let ([l (cdr (syntax->list c))])
(for-each (loop init-line! quote-depth)
l))]
[(and (pair? (syntax-e c))
(eq? (syntax-e (car (syntax-e c))) 'code:hilite))
(let ([l (syntax->list c)]
[h? highlight?])
(unless (and l (= 2 (length l)))
(error "bad code:redex: ~e" (syntax->datum c)))
(advance c init-line!)
(set! src-col (syntax-column (cadr l)))
(hash-set! next-col-map src-col dest-col)
(set! highlight? #t)
((loop init-line! quote-depth) (cadr l))
(set! highlight? h?)
(set! src-col (add1 src-col)))]
[(and (pair? (syntax-e c))
(eq? (syntax-e (car (syntax-e c))) 'code:quote))
(advance c init-line!)
(out "(" (if (positive? quote-depth) value-color paren-color))
(set! src-col (+ src-col 1))
(hash-set! next-col-map src-col dest-col)
((loop init-line! quote-depth)
(datum->syntax #'here 'quote (car (syntax-e c))))
(for-each (loop init-line! (add1 quote-depth))
(cdr (syntax->list c)))
(out ")" (if (positive? quote-depth) value-color paren-color))
(set! src-col (+ src-col 1))
#;
(hash-set! next-col-map src-col dest-col)]
[(and (pair? (syntax-e c))
(memq (syntax-e (car (syntax-e c)))
'(quote quasiquote unquote unquote-splicing
quasisyntax syntax unsyntax unsyntax-splicing))
(let ([v (syntax->list c)])
(and v (= 2 (length v)))))
(advance c init-line!)
(let-values ([(str quote-delta)
(case (syntax-e (car (syntax-e c)))
[(quote) (values "'" +inf.0)]
[(unquote) (values "," -1)]
[(unquote-splicing) (values ",@" -1)]
[(quasiquote) (values "`" +1)]
[(syntax) (values "#'" 0)]
[(quasisyntax) (values "#`" 0)]
[(unsyntax) (values "#," 0)]
[(unsyntax-splicing) (values "#,@" 0)])])
(out str (if (positive? (+ quote-depth quote-delta))
value-color
reader-color))
(let ([i (cadr (syntax->list c))])
(set! src-col (or (syntax-column i) src-col))
(hash-set! next-col-map src-col dest-col)
((loop init-line! (+ quote-depth quote-delta)) i)))]
[(and (pair? (syntax-e c))
(convert-infix c quote-depth))
=> (lambda (converted)
((loop init-line! quote-depth) converted))]
[(or (pair? (syntax-e c))
(null? (syntax-e c))
(vector? (syntax-e c))
(and (struct? (syntax-e c))
(prefab-struct-key (syntax-e c))))
(let* ([sh (or (syntax-property c 'paren-shape)
#\()]
[quote-depth (if (and (zero? quote-depth)
(or (vector? (syntax-e c))
(struct? (syntax-e c))))
+inf.0
quote-depth)]
[p-color (if (positive? quote-depth)
value-color
(if (eq? sh #\?)
opt-color
paren-color))])
(advance c init-line!)
(when (vector? (syntax-e c))
(let ([vec (syntax-e c)])
(out "#" #;(format "#~a" (vector-length vec)) p-color)
(if (zero? (vector-length vec))
(set! src-col (+ src-col (- (syntax-span c) 2)))
(set! src-col (+ src-col (- (syntax-column (vector-ref vec 0))
(syntax-column c)
1))))))
(when (struct? (syntax-e c))
(out "#s" p-color)
(set! src-col (+ src-col 2)))
(out (case sh
[(#\[ #\?) "["]
[(#\{) "{"]
[else "("])
p-color)
(set! src-col (+ src-col 1))
(hash-set! next-col-map src-col dest-col)
(let lloop ([l (cond
[(vector? (syntax-e c))
(vector->short-list (syntax-e c) syntax-e)]
[(struct? (syntax-e c))
(let ([l (vector->list (struct->vector (syntax-e c)))])
;; Need to build key datum, syntax-ize it internally, and
;; set the overall width to fit right:
(cons (let ([key (syntax-ize (prefab-struct-key (syntax-e c))
(+ 3 (or (syntax-column c) 0))
(or (syntax-line c) 1))]
[end (if (pair? (cdr l))
(and (equal? (syntax-line c) (syntax-line (cadr l)))
(syntax-column (cadr l)))
(and (syntax-column c)
(+ (syntax-column c) (syntax-span c))))])
(if end
(datum->syntax #f
(syntax-e key)
(vector #f (syntax-line key)
(syntax-column key)
(syntax-position key)
(- end 1 (syntax-column key))))
end))
(cdr l)))]
[else c])])
(cond
[(and (syntax? l)
(pair? (syntax-e l))
(not (and (memq (syntax-e (car (syntax-e l)))
'(quote unquote syntax unsyntax quasiquote quasiunsyntax))
(let ([v (syntax->list l)])
(and v (= 2 (length v)))))))
(lloop (syntax-e l))]
[(or (null? l)
(and (syntax? l)
(null? (syntax-e l))))
(void)]
[(pair? l)
((loop init-line! quote-depth) (car l))
(lloop (cdr l))]
[else
(advance l init-line! -2)
(out ". " (if (positive? quote-depth) value-color paren-color))
(set! src-col (+ src-col 3))
(hash-set! next-col-map src-col dest-col)
((loop init-line! quote-depth) l)]))
(out (case sh
[(#\[ #\?) "]"]
[(#\{) "}"]
[else ")"])
p-color)
(set! src-col (+ src-col 1))
#;
(hash-set! next-col-map src-col dest-col))]
[(box? (syntax-e c))
(advance c init-line!)
(out "#&" value-color)
(set! src-col (+ src-col 2))
(hash-set! next-col-map src-col dest-col)
((loop init-line! +inf.0) (unbox (syntax-e c)))]
[(hash? (syntax-e c))
(advance c init-line!)
(let ([equal-table? (not (hash-eq? (syntax-e c)))])
(out (if equal-table?
"#hash"
"#hasheq")
value-color)
(let ([delta (+ 5 (if equal-table? 2 0))]
[orig-col src-col])
(set! src-col (+ src-col delta))
(hash-set! next-col-map src-col dest-col)
((loop init-line! +inf.0)
(syntax-ize (hash-map (syntax-e c) cons)
(+ (syntax-column c) delta)))
(set! src-col (+ orig-col (syntax-span c)))))]
[(graph-reference? (syntax-e c))
(advance c init-line!)
(out (format "#~a#" (unbox (graph-reference-bx (syntax-e c))))
(if (positive? quote-depth)
value-color
paren-color))
(set! src-col (+ src-col (syntax-span c)))]
[(graph-defn? (syntax-e c))
(advance c init-line!)
(let ([bx (graph-defn-bx (syntax-e c))])
(out (format "#~a=" (unbox bx))
(if (positive? quote-depth)
value-color
paren-color))
(set! src-col (+ src-col 3))
((loop init-line! quote-depth) (graph-defn-r (syntax-e c))))]
[else
(advance c init-line!)
(typeset-atom c out color? quote-depth)
(set! src-col (+ src-col (or (syntax-span c) 1)))
#;
(hash-set! next-col-map src-col dest-col)])))
(out prefix1 #f)
(set! dest-col 0)
(hash-set! next-col-map init-col dest-col)
((loop (lambda () (set! src-col init-col) (set! dest-col 0)) 0) c)
(if (list? suffix)
(map (lambda (sfx)
(finish-line!)
(out sfx #f))
suffix)
(out suffix #f))
(unless (null? content)
(finish-line!))
(if multi-line?
(if (= 1 (length docs))
(car docs)
(make-table block-color (map list (reverse docs))))
(make-sized-element #f (reverse content) dest-col))))
(define (typeset c multi-line? prefix1 prefix suffix color?)
(let* ([c (syntax-ize c 0)]
[s (syntax-e c)])
(if (or multi-line?
(eq? 'code:blank s)
(pair? s)
(vector? s)
(struct? s)
(box? s)
(null? s)
(hash? s)
(graph-defn? s)
(graph-reference? s))
(gen-typeset c multi-line? prefix1 prefix suffix color?)
(typeset-atom c
(letrec ([mk
(case-lambda
[(elem color)
(mk elem color (or (syntax-span c) 1))]
[(elem color len)
(if (and (string? elem)
(= len (string-length elem)))
(make-element/cache (and color? color) elem)
(make-sized-element (and color? color) elem len))])])
mk)
color? 0))))
(define (to-element c)
(typeset c #f "" "" "" #t))
(define (to-element/no-color c)
(typeset c #f "" "" "" #f))
(define (to-paragraph c)
(typeset c #t "" "" "" #t))
(define ((to-paragraph/prefix pfx1 pfx sfx) c)
(typeset c #t pfx1 pfx sfx #t))
(begin-for-syntax
(define-struct variable-id (sym)
#:omit-define-syntaxes
#:property prop:procedure (lambda (self stx)
(raise-syntax-error
#f
(string-append
"misuse of an identifier (not in `scheme', etc.) that is"
" bound as a code-typesetting variable")
stx)))
(define-struct element-id-transformer (proc)
#:omit-define-syntaxes
#:property prop:procedure (lambda (self stx)
(raise-syntax-error
#f
(string-append
"misuse of an identifier (not in `scheme', etc.) that is"
" bound as an code-typesetting element transformer")
stx))))
(define-syntax (define-code stx)
(syntax-case stx ()
[(_ code typeset-code uncode d->s stx-prop)
(syntax/loc stx
(define-syntax (code stx)
(define (wrap-loc v ctx e)
`(,#'d->s ,ctx
,e
#(code
,(syntax-line v)
,(syntax-column v)
,(syntax-position v)
,(syntax-span v))))
(define (stx->loc-s-expr v)
(let ([slv (and (identifier? v)
(syntax-local-value v (lambda () #f)))])
(cond
[(variable-id? slv)
(wrap-loc v #f `(,#'make-var-id ',(variable-id-sym slv)))]
[(element-id-transformer? slv)
(wrap-loc v #f ((element-id-transformer-proc slv) v))]
[(syntax? v)
(let ([mk (wrap-loc
v
`(quote-syntax ,(datum->syntax v 'defcode))
(syntax-case v (uncode)
[(uncode e) #'e]
[else (stx->loc-s-expr (syntax-e v))]))])
(let ([prop (syntax-property v 'paren-shape)])
(if prop
`(,#'stx-prop ,mk 'paren-shape ,prop)
mk)))]
[(null? v) 'null]
[(list? v) `(list . ,(map stx->loc-s-expr v))]
[(pair? v) `(cons ,(stx->loc-s-expr (car v))
,(stx->loc-s-expr (cdr v)))]
[(vector? v) `(vector ,@(map
stx->loc-s-expr
(vector->list v)))]
[(and (struct? v) (prefab-struct-key v))
`(make-prefab-struct (quote ,(prefab-struct-key v))
,@(map
stx->loc-s-expr
(cdr (vector->list (struct->vector v)))))]
[(box? v) `(box ,(stx->loc-s-expr (unbox v)))]
[else `(quote ,v)])))
(define (cvt s)
(datum->syntax #'here (stx->loc-s-expr s) #f))
(if (eq? (syntax-local-context) 'expression)
(syntax-case stx ()
[(_ expr) #`(typeset-code #,(cvt #'expr))]
[(_ expr (... ...))
#`(typeset-code #,(cvt #'(code:line expr (... ...))))])
(quasisyntax/loc stx
(#%expression #,stx)))))]
[(_ code typeset-code uncode d->s)
#'(define-code code typeset-code uncode d->s syntax-property)]
[(_ code typeset-code uncode)
#'(define-code code typeset-code uncode datum->syntax syntax-property)]
[(_ code typeset-code) #'(define-code code typeset-code unsyntax)]))
(define syntax-ize-hook (make-parameter (lambda (v col) #f)))
(define (vector->short-list v extract)
(vector->list v)
#;
(let ([l (vector->list v)])
(reverse (list-tail
(reverse l)
(- (vector-length v)
(let loop ([i (sub1 (vector-length v))])
(cond
[(zero? i) 1]
[(eq? (extract (vector-ref v i))
(extract (vector-ref v (sub1 i))))
(loop (sub1 i))]
[else (add1 i)])))))))
(define (short-list->vector v l)
(list->vector
(let ([n (length l)])
(if (n . < . (vector-length v))
(reverse (let loop ([r (reverse l)][i (- (vector-length v) n)])
(if (zero? i)
r
(loop (cons (car r) r) (sub1 i)))))
l))))
(define-struct var-id (sym))
(define-struct shaped-parens (val shape))
(define-struct just-context (val ctx))
(define-struct alternate-display (id string))
(define-struct literal-syntax (stx))
(define-struct graph-reference (bx))
(define-struct graph-defn (r bx))
(define (syntax-ize v col [line 1])
(do-syntax-ize v col line (box #hasheq()) #f))
(define (graph-count ht graph?)
(and graph?
(let ([n (hash-ref (unbox ht) '#%graph-count 0)])
(set-box! ht (hash-set (unbox ht) '#%graph-count (add1 n)))
n)))
(define (do-syntax-ize v col line ht graph?)
(cond
[((syntax-ize-hook) v col)
=> (lambda (r) r)]
[(shaped-parens? v)
(syntax-property (do-syntax-ize (shaped-parens-val v) col line ht #f)
'paren-shape
(shaped-parens-shape v))]
[(just-context? v)
(let ([s (do-syntax-ize (just-context-val v) col line ht #f)])
(datum->syntax (just-context-ctx v)
(syntax-e s)
s
s
(just-context-ctx v)))]
[(alternate-display? v)
(let ([s (do-syntax-ize (alternate-display-id v) col line ht #f)])
(syntax-property s
'display-string
(alternate-display-string v)))]
[(hash-ref (unbox ht) v #f)
=> (lambda (m)
(unless (unbox m)
(set-box! m #t))
(datum->syntax #f
(make-graph-reference m)
(vector #f line col (+ 1 col) 1)))]
[(and (list? v)
(pair? v)
(memq (let ([s (car v)])
(if (just-context? s)
(just-context-val s)
s))
'(quote unquote unquote-splicing)))
(let ([c (do-syntax-ize (cadr v) (+ col 1) line ht #f)])
(datum->syntax #f
(list (do-syntax-ize (car v) col line ht #f)
c)
(vector #f line col (+ 1 col)
(+ 1 (syntax-span c)))))]
[(or (list? v)
(vector? v)
(and (struct? v)
(prefab-struct-key v)))
(let ([orig-ht (unbox ht)]
[graph-box (box (graph-count ht graph?))])
(set-box! ht (hash-set (unbox ht) v graph-box))
(let* ([graph-sz (if graph?
(+ 2 (string-length (format "~a" (unbox graph-box))))
0)]
[vec-sz (cond
[(vector? v)
(+ 1 #;(string-length (format "~a" (vector-length v))))]
[(struct? v) 2]
[else 0])]
[r (let ([l (let loop ([col (+ col 1 vec-sz graph-sz)]
[v (cond
[(vector? v)
(vector->short-list v values)]
[(struct? v)
(cons (prefab-struct-key v)
(cdr (vector->list (struct->vector v))))]
[else v])])
(if (null? v)
null
(let ([i (do-syntax-ize (car v) col line ht #f)])
(cons i
(loop (+ col 1 (syntax-span i)) (cdr v))))))])
(datum->syntax #f
(cond
[(vector? v) (short-list->vector v l)]
[(struct? v)
(apply make-prefab-struct (prefab-struct-key v) (cdr l))]
[else l])
(vector #f line
(+ graph-sz col)
(+ 1 graph-sz col)
(+ 2
vec-sz
(if (zero? (length l))
0
(sub1 (length l)))
(apply + (map syntax-span l))))))])
(unless graph?
(set-box! ht (hash-set (unbox ht) v #f)))
(cond
[graph? (datum->syntax #f
(make-graph-defn r graph-box)
(vector #f (syntax-line r)
(- (syntax-column r) graph-sz)
(- (syntax-position r) graph-sz)
(+ (syntax-span r) graph-sz)))]
[(unbox graph-box)
;; Go again, this time knowing that there will be a graph:
(set-box! ht orig-ht)
(do-syntax-ize v col line ht #t)]
[else r])))]
[(pair? v)
(let ([orig-ht (unbox ht)]
[graph-box (box (graph-count ht graph?))])
(set-box! ht (hash-set (unbox ht) v graph-box))
(let* ([inc (if graph?
(+ 2 (string-length (format "~a" (unbox graph-box))))
0)]
[a (do-syntax-ize (car v) (+ col 1 inc) line ht #f)]
[sep (if (and (pair? (cdr v))
;; FIXME: what if it turns out to be a graph reference?
(not (hash-ref (unbox ht) (cdr v) #f)))
0
3)]
[b (do-syntax-ize (cdr v) (+ col 1 inc (syntax-span a) sep) line ht #f)])
(let ([r (datum->syntax #f
(cons a b)
(vector #f line (+ col inc) (+ 1 col inc)
(+ 2 sep (syntax-span a) (syntax-span b))))])
(unless graph?
(set-box! ht (hash-set (unbox ht) v #f)))
(cond
[graph? (datum->syntax #f
(make-graph-defn r graph-box)
(vector #f line col (+ 1 col)
(+ inc (syntax-span r))))]
[(unbox graph-box)
;; Go again...
(set-box! ht orig-ht)
(do-syntax-ize v col line ht #t)]
[else r]))))]
[(box? v)
(let ([a (do-syntax-ize (unbox v) (+ col 2) line ht #f)])
(datum->syntax #f
(box a)
(vector #f line col (+ 1 col)
(+ 2 (syntax-span a)))))]
[else
(datum->syntax #f v (vector #f line col (+ 1 col) 1))])))

View File

@ -54,8 +54,11 @@ function MergePageArgsIntoLink(a) {
// Cookies --------------------------------------------------------------------
function GetCookie(key, def) {
if (document.cookie.length <= 0) return def;
var i, cookiestrs = document.cookie.split(/; */);
var i, cookiestrs;
try {
if (document.cookie.length <= 0) return def;
cookiestrs = document.cookie.split(/; */);
} catch (e) { return def; }
for (i = 0; i < cookiestrs.length; i++) {
var cur = cookiestrs[i];
var eql = cur.indexOf('=');
@ -68,8 +71,10 @@ function GetCookie(key, def) {
function SetCookie(key, val) {
var d = new Date();
d.setTime(d.getTime()+(365*24*60*60*1000));
document.cookie =
key + "=" + escape(val) + "; expires="+ d.toGMTString() + "; path=/";
try {
document.cookie =
key + "=" + escape(val) + "; expires="+ d.toGMTString() + "; path=/";
} catch (e) {}
}
// note that this always stores a directory name, ending with a "/"

View File

@ -1,10 +1,11 @@
(module search scheme/base
(module search racket/base
(require "struct.ss"
"basic.ss"
setup/main-collects
syntax/modcode)
(provide find-scheme-tag)
(provide find-racket-tag
(rename-out [find-racket-tag find-scheme-tag]))
(define module-info-cache (make-hasheq))
@ -21,7 +22,7 @@
(with-handlers* ([exn:fail? (lambda (exn) (fail-thunk))])
(thunk)))
(define (find-scheme-tag part ri stx/binding phase-level)
(define (find-racket-tag part ri stx/binding phase-level)
;; The phase-level argument is used only when `stx/binding'
;; is an identifier.
;;
@ -169,7 +170,7 @@
;; have changed in inconsistent ways. So just say #f
;; for now.
#;
(error 'find-scheme-tag
(error 'find-racket-tag
"dead end when looking for binding source: ~e"
id)
(loop queue rqueue need-result?)))))

View File

@ -0,0 +1,3 @@
#lang s-exp scribble/base/reader
scribble/sigplan/lang
#:wrapper1 (lambda (t) (cons 'doc (t)))

View File

@ -1,15 +0,0 @@
#lang s-exp syntax/module-reader
scribble/sigplan/lang
#:read scribble:read-inside
#:read-syntax scribble:read-syntax-inside
#:whole-body-readers? #t
#:wrapper1 (lambda (t) (cons 'doc (t)))
#:info (lambda (key defval default)
(case key
[(color-lexer)
(dynamic-require 'syntax-color/scribble-lexer 'scribble-inside-lexer)]
[else (default key defval)]))
(require (prefix-in scribble: "../../reader.ss"))

View File

@ -0,0 +1,5 @@
#lang racket/base
(require racket/promise "text/output.ss" "text/syntax-utils.ss")
(provide (all-from-out racket/promise "text/output.ss")
begin/text include/text)

View File

@ -1,5 +0,0 @@
#lang scheme/base
(require scheme/promise "text/output.ss" "text/syntax-utils.ss")
(provide (all-from-out scheme/promise "text/output.ss")
begin/text include/text)

View File

@ -0,0 +1,12 @@
#lang s-exp syntax/module-reader
scribble/text/textlang
#:read scribble:read-inside
#:read-syntax scribble:read-syntax-inside
#:whole-body-readers? #t
#:info (scribble-base-reader-info)
(require (prefix-in scribble: "../../reader.ss")
(only-in scribble/base/reader
scribble-base-reader-info))

View File

@ -1,9 +0,0 @@
#lang s-exp syntax/module-reader
scribble/text/textlang
#:read scribble:read-inside
#:read-syntax scribble:read-syntax-inside
#:whole-body-readers? #t
(require (prefix-in scribble: "../../reader.ss"))

View File

@ -0,0 +1,9 @@
#lang racket/base
(require "syntax-utils.ss" "output.ss" racket/promise)
(provide (except-out (all-from-out racket/base) #%module-begin)
(all-from-out "output.ss" racket/promise)
begin/text
(rename-out [module-begin/text #%module-begin]
[include/text include]))

View File

@ -1,9 +0,0 @@
#lang scheme/base
(require "syntax-utils.ss" "output.ss" scheme/promise)
(provide (except-out (all-from-out scheme/base) #%module-begin)
(all-from-out "output.ss" scheme/promise)
begin/text
(rename-out [module-begin/text #%module-begin]
[include/text include]))

View File

@ -0,0 +1,10 @@
#lang racket/base
(provide (all-defined-out)
(rename-out [url:drracket url:drscheme]
[url:download-drracket url:download-drscheme]))
(define url:drracket "http://racket-lang.org/")
(define url:download-drracket "http://racket-lang.org/")
(define url:planet "http://planet.plt-scheme.org/")

View File

@ -1,8 +0,0 @@
(module urls mzscheme
(provide (all-defined))
(define url:drscheme "http://www.drscheme.org/")
(define url:download-drscheme "http://download.plt-scheme.org/drscheme/")
(define url:planet "http://planet.plt-scheme.org/"))

View File

@ -1,7 +1,7 @@
#lang scribble/doc
@(require scribble/manual
"utils.ss"
(for-syntax scheme/base)
(for-syntax racket/base)
(for-label setup/main-collects))
@(define-syntax def-section-like
@ -23,23 +23,26 @@
@(define-syntax def-style-proc
(syntax-rules ()
[(_ id)
@def-elem-proc[id]{Like @scheme[elem], but with style @scheme['id].}]))
@def-elem-proc[id]{Like @racket[elem], but with style @racket['id].}]))
@title[#:tag "base"]{Base Document Format}
@defmodulelang[scribble/base]{The @schememodname[scribble/base] language
provides functions and forms that can be used from code written either
in Scheme or with @elem["@"] expressions.
@defmodulelang[scribble/base]{The @racketmodname[scribble/base]
language provides functions and forms that can be used from code
written either in Racket or with @elem["@"] expressions. It
essentially extends @racketmodname[racket/base], except that top-level
forms within a module using the @racketmodname[scribble/base] language
are treated as document content (like @racketmodname[scribble/doclang]).
The @schememodname[scribble/base] name can also be used as a
library with @scheme[require], in which case it provides all of the same
bindings, but without setting the reader or setting the default
rendering format to the PLT Scheme manual format.}
The @racketmodname[scribble/base] name can also be used as a library
with @racket[require], in which case it provides only the bindings
defined in this section, and it also does not set the reader or
set the default rendering format to the Racket manual format.}
Functions provided by this library, such as @scheme[title] and
@scheme[italic], might be called from Scheme as
Functions provided by this library, such as @racket[title] and
@racket[italic], might be called from Racket as
@schemeblock[
@racketblock[
(title #:tag "how-to"
"How to Design " (italic "Great") " Programs")
]
@ -51,8 +54,8 @@ They can also be called with @elem["@"] notation as
}|
Although the procedures are mostly design to be used from @elem["@"]
mode, they are easier to document in Scheme mode (partly because we
have @schememodname[scribble/manual]).
mode, they are easier to document in Racket mode (partly because we
have @racketmodname[scribble/manual]).
@; ------------------------------------------------------------------------
@ -65,70 +68,70 @@ have @schememodname[scribble/manual]).
[pre-content pre-content?] ...+)
title-decl?]{
Generates a @scheme[title-decl] to be picked up by @scheme[decode] or
@scheme[decode-part]. The @tech{decode}d @scheme[pre-content] (i.e.,
parsed with @scheme[decode-content]) supplies the title content. If
@scheme[tag] is @scheme[#f], a tag string is generated automatically
Generates a @racket[title-decl] to be picked up by @racket[decode] or
@racket[decode-part]. The @tech{decode}d @racket[pre-content] (i.e.,
parsed with @racket[decode-content]) supplies the title content. If
@racket[tag] is @racket[#f], a tag string is generated automatically
from the content. The tag string is combined with the symbol
@scheme['part] to form the full tag.
@racket['part] to form the full tag.
The @scheme[style] argument can be a style structure, or it can be one
of the following: a @scheme[#f] that corresponds to a ``plain'' style,
The @racket[style] argument can be a style structure, or it can be one
of the following: a @racket[#f] that corresponds to a ``plain'' style,
a string that is used as a @tech{style name}, a symbol that is used as
a @tech{style property}, or a list of symbols to be used as @tech{style properties}.
For information on styles, see @scheme[part]. For example, a style of
@scheme['toc] causes sub-sections to be generated as separate pages in
For information on styles, see @racket[part]. For example, a style of
@racket['toc] causes sub-sections to be generated as separate pages in
multi-page HTML output.
The @scheme[tag-prefix] argument is propagated to the generated
structure (see @secref["tags"]). If @scheme[tag-prefix] is a module
The @racket[tag-prefix] argument is propagated to the generated
structure (see @secref["tags"]). If @racket[tag-prefix] is a module
path, it is converted to a string using
@scheme[module-path-prefix->string].
@racket[module-path-prefix->string].
The @scheme[vers] argument is propagated to the @scheme[title-decl]
structure. Use @scheme[""] as @scheme[vers] to suppress version
The @racket[vers] argument is propagated to the @racket[title-decl]
structure. Use @racket[""] as @racket[vers] to suppress version
rendering in the output.
The section title is automatically indexed by
@scheme[decode-part]. For the index key, leading whitespace and a
@racket[decode-part]. For the index key, leading whitespace and a
leading ``A'', ``An'', or ``The'' (followed by more whitespace) is
removed.}
@def-section-like[section part-start?]{ Like @scheme[title], but
generates a @scheme[part-start] of depth @scheme[0] to be by
@scheme[decode] or @scheme[decode-part].}
@def-section-like[section part-start?]{ Like @racket[title], but
generates a @racket[part-start] of depth @racket[0] to be by
@racket[decode] or @racket[decode-part].}
@def-section-like[subsection part-start?]{ Like @scheme[section], but
generates a @scheme[part-start] of depth @scheme[1].}
@def-section-like[subsection part-start?]{ Like @racket[section], but
generates a @racket[part-start] of depth @racket[1].}
@def-section-like[subsubsection part-start?]{ Like @scheme[section], but
generates a @scheme[part-start] of depth @scheme[2].}
@def-section-like[subsubsection part-start?]{ Like @racket[section], but
generates a @racket[part-start] of depth @racket[2].}
@def-section-like[subsubsub*section paragraph?]{ Similar to
@scheme[section], but merely generates a paragraph that looks like an
@racket[section], but merely generates a paragraph that looks like an
unnumbered section heading (for when the nesting gets too deep to
include in a table of contents).}
@defform[(include-section module-path)]{ Requires @scheme[module-path]
and returns its @scheme[doc] export (without making any imports
@defform[(include-section module-path)]{ Requires @racket[module-path]
and returns its @racket[doc] export (without making any imports
visible to the enclosing context). Since this form expands to
@scheme[require], it must be used in a module or top-level context.}
@racket[require], it must be used in a module or top-level context.}
@defproc[(author [auth content?] ...) block?]{
Generates a @scheme[paragraph] with style name @scheme['author] to
Generates a @racket[paragraph] with style name @racket['author] to
show the author(s) of a document, where each author is represented by
@tech{content}. Normally, this function is used after
@scheme[title] for the beginning of a document. See also
@scheme[author+email].}
@racket[title] for the beginning of a document. See also
@racket[author+email].}
@defproc[(author+email [author elem]
[email string?]
[#:obfuscate? obfuscate? any/c #f])
element?]{
Combines an author name with an e-mail address. If @scheme[obfuscate?]
Combines an author name with an e-mail address. If @racket[obfuscate?]
is true, then the result obscures the e-mail address slightly to avoid
address-harvesting robots.}
@ -140,23 +143,23 @@ address-harvesting robots.}
[pre-content pre-content?] ...) paragraph?]{
Creates a @tech{paragraph} containing the @tech{decode}d
@scheme[pre-content] (i.e., parsed with @scheme[decode-paragraph]).
@racket[pre-content] (i.e., parsed with @racket[decode-paragraph]).
The @scheme[style] argument can be a style, @scheme[#f] to indicate a
The @racket[style] argument can be a style, @racket[#f] to indicate a
``plain'' style, a string that is used as a @tech{style name}, or a
symbol that is used as a @tech{style name}. (Note that
@scheme[section] and @scheme[para] treat symbols differently as
@scheme[style] arguments.)}
@racket[section] and @racket[para] treat symbols differently as
@racket[style] arguments.)}
@defproc[(nested [#:style style (or/c style? string? symbol? #f)]
[pre-flow pre-flow?] ...) nested-flow?]{
Creates a @tech{nested flow} containing the @tech{decode}d
@scheme[pre-flow] (i.e., parsed with @scheme[decode-flow]).
@racket[pre-flow] (i.e., parsed with @racket[decode-flow]).
The @scheme[style] argument is handled the same as @scheme[para].
The @scheme['inset] style causes the nested flow to be inset compared
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.}
@ -175,25 +178,25 @@ of inlined.}
[#:style style (or/c style? string? symbol? #f) #f])
itemization?]{
Constructs an @scheme[itemization] given a sequence of items
constructed by @scheme[item].
Constructs an @racket[itemization] given a sequence of items
constructed by @racket[item].
The @scheme[style] argument is handled the same as @scheme[para]. The
@scheme['ordered] style numbers items, instead of just using a
The @racket[style] argument is handled the same as @racket[para]. The
@racket['ordered] style numbers items, instead of just using a
bullet.}
@defproc[(item [pre-flow pre-flow?] ...) item?]{
Creates an item for use with @scheme[itemlist]. The @tech{decode}d
@scheme[pre-flow] (i.e., parsed with @scheme[decode-flow]) is the item
Creates an item for use with @racket[itemlist]. The @tech{decode}d
@racket[pre-flow] (i.e., parsed with @racket[decode-flow]) is the item
content.}
@defproc[(item? [v any/c]) boolean?]{
Returns @scheme[#t] if @scheme[v] is an item produced by
@scheme[item], @scheme[#f] otherwise.}
Returns @racket[#t] if @racket[v] is an item produced by
@racket[item], @racket[#f] otherwise.}
@defproc[(tabular [cells (listof (listof (or/c block? content? 'cont)))]
@ -204,29 +207,29 @@ Creates a @tech{table} with the given content, which is supplies as a
list of rows, where each row has a list of cells. The length of all
rows must match.
Use @scheme['cont] as a cell to continue the content of the preceding
Use @racket['cont] as a cell to continue the content of the preceding
cell in a row in the space that would otherwise be used for a new
cell. A @scheme['cont] must not appear as the first cell in a row.
cell. A @racket['cont] must not appear as the first cell in a row.
The @scheme[style] argument is handled the same as @scheme[para].}
The @racket[style] argument is handled the same as @racket[para].}
@defproc[(verbatim [#:indent indent exact-nonnegative-integer? 0] [str string?] ...+)
block?]{
Typesets @scheme[str]s in typewriter font with the linebreaks
specified by newline characters in @scheme[str]. Consecutive spaces in
the @scheme[str]s are converted to @scheme[hspace] to ensure that they
Typesets @racket[str]s in typewriter font with the linebreaks
specified by newline characters in @racket[str]. Consecutive spaces in
the @racket[str]s are converted to @racket[hspace] to ensure that they
are all preserved in the output. Additional space (via
@scheme[hspace]) as specified by @scheme[indent] is added to the
@racket[hspace]) as specified by @racket[indent] is added to the
beginning of each line.
The @scheme[str]s are @emph{not} decoded with @scheme[decode-content],
so @scheme[(verbatim "---")] renders with three hyphens instead of an
em-dash. Beware, however, that @litchar["@"] for a @scheme[verbatim]
The @racket[str]s are @emph{not} decoded with @racket[decode-content],
so @racket[(verbatim "---")] renders with three hyphens instead of an
em-dash. Beware, however, that @litchar["@"] for a @racket[verbatim]
call performs some processing before delivering arguments to
@scheme[verbatim]. The @scheme[verbatim] form is typically used with
@racket[verbatim]. The @racket[verbatim] form is typically used with
@litchar["|{"]...@litchar["}|"] or similar brackets to disable
@litchar["@"] notation within the @scheme[verbatim] argument, like
@litchar["@"] notation within the @racket[verbatim] argument, like
this:
@verbatim[#:indent 2]|{
@ -245,7 +248,7 @@ Even with @litchar["|{"]...@litchar["}|"], beware that consistent
leading whitespace is removed; see @secref["alt-body-syntax"] for more
information.
See also @scheme[literal].}
See also @racket[literal].}
@; ------------------------------------------------------------------------
@ -255,8 +258,8 @@ See also @scheme[literal].}
[#:style style (or style? string? symbol? #f) #f])
element?]{
Wraps the @tech{decode}d @scheme[pre-content] as an element with style
@scheme[style].}
Wraps the @tech{decode}d @racket[pre-content] as an element with style
@racket[style].}
@def-style-proc[italic]
@ -265,35 +268,35 @@ Wraps the @tech{decode}d @scheme[pre-content] as an element with style
@def-style-proc[subscript]
@def-style-proc[superscript]
@def-elem-proc[smaller]{Like @scheme[elem], but with style
@scheme['smaller]. When uses of @scheme[smaller] are nested, text
@def-elem-proc[smaller]{Like @racket[elem], but with style
@racket['smaller]. When uses of @racket[smaller] are nested, text
gets progressively smaller.}
@def-elem-proc[larger]{Like @scheme[elem], but with style
@scheme['larger]. When uses of @scheme[larger] are nested, text
@def-elem-proc[larger]{Like @racket[elem], but with style
@racket['larger]. When uses of @racket[larger] are nested, text
gets progressively larger.}
@defproc[(emph [pre-content pre-content?] ...) element?]{
The same as @scheme[italic].}
The same as @racket[italic].}
@defproc[(linebreak) element?]{
Produces an element that forces a line break.}
@defproc[(hspace [n exact-nonnegative-integer?]) element?]{
Produces an element containing @scheme[n] spaces and style
@scheme['hspace].}
Produces an element containing @racket[n] spaces and style
@racket['hspace].}
@defproc[(literal [str string?] ...+) element?]{
Produces an element containing literally @scheme[str]s with no
decoding via @scheme[decode-content].
Produces an element containing literally @racket[str]s with no
decoding via @racket[decode-content].
Beware that @litchar["@"] for a @scheme[literal] call performs some
processing before delivering arguments to @scheme[literal]. The
@scheme[literal] form can be used with @litchar["|{"]...@litchar["}|"]
Beware that @litchar["@"] for a @racket[literal] call performs some
processing before delivering arguments to @racket[literal]. The
@racket[literal] form can be used with @litchar["|{"]...@litchar["}|"]
or similar brackets to disable @litchar["@"] notation within the
@scheme[literal] argument, like this:
@racket[literal] argument, like this:
@verbatim[#:indent 2]|{
@literal|{@bold{---}}|
@ -305,7 +308,7 @@ which renders as
@literal|{@bold{---}}|
}|
See also @scheme[verbatim].}
See also @racket[verbatim].}
@defproc[(image [path (or/c path-string? (cons/c 'collects (listof bytes?)))]
@ -315,21 +318,21 @@ See also @scheme[verbatim].}
element?]{
Creates an image element from the given path. The @tech{decode}d
@scheme[pre-content] serves as the alternate text for contexts where
@racket[pre-content] serves as the alternate text for contexts where
the image cannot be displayed.
The path is relative to the current directory, which is set by
@exec{setup-plt} and @exec{scribble} to the directory of the main
document file. The @scheme[path] argument also can be a result of
@scheme[path->main-collects-relative].
document file. The @racket[path] argument also can be a result of
@racket[path->main-collects-relative].
The strings in @scheme[suffixes] are filtered to those supported by
The strings in @racket[suffixes] are filtered to those supported by
given renderer, and then the acceptable suffixes are tried in
order. The HTML renderer supports @scheme[".png"] and
@scheme[".gif"], while the Latex renderer supports @scheme[".png"],
@scheme[".pdf"], and @scheme[".ps"] (but @scheme[".ps"] works only
when converting Latex output to DVI, and @scheme[".png"] and
@scheme[".pdf"] work only for converting Latex output to PDF).}
order. The HTML renderer supports @racket[".png"] and
@racket[".gif"], while the Latex renderer supports @racket[".png"],
@racket[".pdf"], and @racket[".ps"] (but @racket[".ps"] works only
when converting Latex output to DVI, and @racket[".png"] and
@racket[".pdf"] work only for converting Latex output to PDF).}
@; ------------------------------------------------------------------------
@ -340,9 +343,9 @@ See also @scheme[verbatim].}
[#:style style (or/c style? string? symbol? #f) (if underline? #f "plainlink")])
element?]{
The @tech{decode}d @scheme[pre-content] is hyperlinked to
@scheme[url]. If @scheme[style] is not supplied, then
@scheme[underline?] determines how the link is rendered.}
The @tech{decode}d @racket[pre-content] is hyperlinked to
@racket[url]. If @racket[style] is not supplied, then
@racket[underline?] determines how the link is rendered.}
@defproc[(url [dest string?]) element?]{
@ -356,27 +359,27 @@ Generates a literal hyperlinked URL.}
[#:underline? underline? any/c #t])
element?]{
Inserts the hyperlinked title of the section tagged @scheme[tag], but
elements in the title content with the @scheme['aux] @tech{style property}
Inserts the hyperlinked title of the section tagged @racket[tag], but
elements in the title content with the @racket['aux] @tech{style property}
are omitted in the hyperlink label.
If @scheme[#:doc module-path] is provided, the @scheme[tag] refers to
a tag with a prefix determined by @scheme[module-path]. When
If @racket[#:doc module-path] is provided, the @racket[tag] refers to
a tag with a prefix determined by @racket[module-path]. When
@exec{setup-plt} renders documentation, it automatically adds a tag
prefix to the document based on the source module. Thus, for example,
to refer to a section of the PLT Scheme reference,
@scheme[module-path] would be @scheme['(lib
to refer to a section of the Racket reference,
@racket[module-path] would be @racket['(lib
"scribblings/reference/reference.scrbl")].
The @scheme[#:tag-prefixes prefixes] argument similarly supports
The @racket[#:tag-prefixes prefixes] argument similarly supports
selecting a particular section as determined by a path of tag
prefixes. When a @scheme[#:doc] argument is provided, then
@scheme[prefixes] should trace a path of tag-prefixed subsections to
reach the @scheme[tag] section. When @scheme[#:doc] is not provided,
the @scheme[prefixes] path is relative to any enclosing section (i.e.,
prefixes. When a @racket[#:doc] argument is provided, then
@racket[prefixes] should trace a path of tag-prefixed subsections to
reach the @racket[tag] section. When @racket[#:doc] is not provided,
the @racket[prefixes] path is relative to any enclosing section (i.e.,
the youngest ancestor that produces a match).
If @scheme[underline?] is @scheme[#f], then the hyperlink is rendered
If @racket[underline?] is @racket[#f], then the hyperlink is rendered
in HTML without an underline.}
@ -386,37 +389,37 @@ in HTML without an underline.}
[#:underline? underline? any/c #t]
[pre-content pre-content?] ...) element?]{
Like @scheme[secref], but the link label is the @tech{decode}d
@scheme[pre-content] instead of the target section's name.}
Like @racket[secref], but the link label is the @tech{decode}d
@racket[pre-content] instead of the target section's name.}
@defproc[(other-doc [module-path module-path?]
[#:underline? underline? any/c #t])
element?]{
Like @scheme[secref] for the document's implicit @scheme["top"]
Like @racket[secref] for the document's implicit @racket["top"]
tag. Use this function to refer to a whole manual instead of
@scheme[secref], in case a special style in the future is used for
@racket[secref], in case a special style in the future is used for
manual titles.}
@defproc[(elemtag [t (or/c tag? string?)] [pre-content pre-content?] ...) element?]{
The tag @scheme[t] refers to the content form of
@scheme[pre-content].}
The tag @racket[t] refers to the content form of
@racket[pre-content].}
@defproc[(elemref [t (or/c tag? string?)] [pre-content pre-content?] ...
[#:underline? underline? any/c #t]) element?]{
The @tech{decode}d @scheme[pre-content] is hyperlinked to @scheme[t],
which is normally defined using @scheme[elemtag].}
The @tech{decode}d @racket[pre-content] is hyperlinked to @racket[t],
which is normally defined using @racket[elemtag].}
@defproc[(module-path-prefix->string [mod-path module-path?])
string?]{
Converts a module path to a string by resolving it to a path, and
using @scheme[path->main-collects-relative].}
using @racket[path->main-collects-relative].}
@; ------------------------------------------------------------------------
@ -427,16 +430,16 @@ using @scheme[path->main-collects-relative].}
index-element?]{
Creates an index element given a plain-text string---or list of
strings for a hierarchy, such as @scheme['("strings" "plain")] for a
strings for a hierarchy, such as @racket['("strings" "plain")] for a
``plain'' entry below a more general ``strings'' entry. As index keys,
the strings are ``cleaned'' using @scheme[clean-up-index-strings]. The
the strings are ``cleaned'' using @racket[clean-up-index-strings]. The
strings (without clean-up) also serve as the text to render in the
index. The @tech{decode}d @scheme[pre-content] is the text to appear
index. The @tech{decode}d @racket[pre-content] is the text to appear
inline as the index target.
Use @scheme[index] when an index entry should point to a specific word
Use @racket[index] when an index entry should point to a specific word
or phrase within the typeset document (i.e., the
@scheme[pre-content]). Use @scheme[section-index], instead, to create
@racket[pre-content]). Use @racket[section-index], instead, to create
an index entry that leads to a section, instead of a specific word or
phrase within the section.}
@ -445,23 +448,23 @@ phrase within the section.}
[word-contents (listof list?)]
[pre-content pre-content?] ...)
index-element?]{
Like @scheme[index], except that @scheme[words] must be a list, and
Like @racket[index], except that @racket[words] must be a list, and
the list of contents render in the index (in parallel to
@scheme[words]) is supplied as @scheme[word-contents].
@racket[words]) is supplied as @racket[word-contents].
}
@defproc[(as-index [pre-content pre-content?] ...)
index-element?]{
Like @scheme[index], but the word to index is determined by applying
@scheme[content->string] on the @tech{decode}d @scheme[pre-content].}
Like @racket[index], but the word to index is determined by applying
@racket[content->string] on the @tech{decode}d @racket[pre-content].}
@defproc[(section-index [word string?] ...)
part-index-decl?]{
Creates a @scheme[part-index-decl] to be associated with the enclosing
section by @scheme[decode]. The @scheme[word]s serve as both the keys
Creates a @racket[part-index-decl] to be associated with the enclosing
section by @racket[decode]. The @racket[word]s serve as both the keys
and as the rendered forms of the keys within the index.}
@ -469,7 +472,7 @@ and as the rendered forms of the keys within the index.}
part?]{
Produces a part that shows the index the enclosing document. The
optional @scheme[tag] argument is used as the index section's tag.}
optional @racket[tag] argument is used as the index section's tag.}
@; ------------------------------------------------------------------------
@ -491,10 +494,10 @@ for the enclosing section, depending on the output type. For
multi-page HTML output, the flow element is a table of contents; for
Latex output, the flow element is empty.
The meaning of the @scheme[style] argument depends on the output type,
but @scheme['immediate-only] normally creates a table of contents that
The meaning of the @racket[style] argument depends on the output type,
but @racket['immediate-only] normally creates a table of contents that
contains only immediate sub-sections of the enclosing section. See
also the @scheme['quiet] style of @scheme[part] (i.e., in a
@scheme[part] structure, not supplied as the @scheme[style] argument
to @scheme[local-table-of-contents]), which normally suppresses
also the @racket['quiet] style of @racket[part] (i.e., in a
@racket[part] structure, not supplied as the @racket[style] argument
to @racket[local-table-of-contents]), which normally suppresses
sub-part entries in a table of contents.}

View File

@ -7,15 +7,15 @@
@title[#:tag "basic"]{Compatibility Basic Functions}
@defmodule[scribble/basic]{The @schememodname[scribble/basic]
@defmodule[scribble/basic]{The @racketmodname[scribble/basic]
compatibility library mostly just re-exports
@schememodname[scribble/base].}
@racketmodname[scribble/base].}
@defproc[(span-class [style-name string?] [pre-content any/c] ...)
element?]{
@compat[] Wraps the @tech{decode}d
@scheme[pre-content] as an element with style @scheme[style-name].}
@racket[pre-content] as an element with style @racket[style-name].}
@ -23,5 +23,5 @@ compatibility library mostly just re-exports
[#:style style (or/c style? string? symbol? #f) #f])
itemization?]{
@compat[] Like @scheme[itemlist], but whitespace strings among the
@scheme[itm]s are ignored.}
@compat[] Like @racket[itemlist], but whitespace strings among the
@racket[itm]s are ignored.}

View File

@ -5,17 +5,17 @@
@title[#:tag "bnf"]{BNF Grammars}
@defmodule[scribble/bnf]{The @scheme[scribble/bnf] library
@defmodule[scribble/bnf]{The @racket[scribble/bnf] library
provides utilities for typesetting grammars.}
See also @scheme[schemegrammar].
See also @racket[racketgrammar].
@defproc[(BNF [prod (cons element? (listof element?))] ...) table?]{
Typesets a grammar table. Each production starts with an element
(typically constructed with @scheme[nonterm]) for the non-terminal
(typically constructed with @racket[nonterm]) for the non-terminal
being defined, and then a list of possibilities (typically constructed
with @scheme[BNF-seq], etc.) to show on separate lines.}
with @racket[BNF-seq], etc.) to show on separate lines.}
@defproc[(nonterm (pre-content any/c) ...) element?]{
@ -44,15 +44,15 @@ Typesets a 1-or-more repetition.}
@defproc[(kleenerange [n any/c] [m any/c] [pre-content any/c] ...) element?]{
Typesets a @scheme[n]-to-@scheme[m] repetition. The @scheme[n] and
@scheme[m] arguments are converted to a string using @scheme[(format
"~a" n)] and @scheme[(format "~a" m)].}
Typesets a @racket[n]-to-@racket[m] repetition. The @racket[n] and
@racket[m] arguments are converted to a string using @racket[(format
"~a" n)] and @racket[(format "~a" m)].}
@defproc[(BNF-alt [elem element?] ...) element?]{
Typesets alternatives for a production's right-hand side to appear on
a single line. The result is normally used as a single possibility in
a production list for @scheme[BNF].}
a production list for @racket[BNF].}
@defthing[BNF-etc string?]{

View File

@ -5,7 +5,7 @@
scribble/html-properties
scribble/latex-properties
"utils.ss"
(for-label scheme/base))
(for-label racket/base))
@(define (fake-title . str) (apply bold str))
@ -20,16 +20,16 @@ extend or configure Scribble fall into two groups:
@item{You may need to drop into the back-end ``language'' of CSS or
Latex to create a specific output effect. For this kind of
extension, you will mostly likely attach a
@scheme[css-addition] or @scheme[tex-addition] @tech{style property}
@racket[css-addition] or @racket[tex-addition] @tech{style property}
to style, where the addition implements the style name. This
kind of extension is described in @secref["extra-style"].}
@item{You may need to produce a document whose page layout is
different from the PLT Scheme documentation style. For that
different from the Racket documentation style. For that
kind of configuration, you can run the @exec{scribble} command-line
tool and supply flags like @DFlag{prefix} or @DPFlag{style}, or
you can associate a @scheme[html-defaults] or
@scheme[latex-defaults] @tech{style property} to the main document's
you can associate a @racket[html-defaults] or
@racket[latex-defaults] @tech{style property} to the main document's
style. This kind of configuration is described in
@secref["config-style"].}
@ -42,46 +42,46 @@ extend or configure Scribble fall into two groups:
(make-tex-addition "inbox.tex")))
]{Implementing Styles}
When a string is uses as a style in an @scheme[element],
a @scheme[multiarg-element], @scheme[paragraph], @scheme[table],
@scheme[itemization], @scheme[nested-flow], or
@scheme[compound-paragraph], it corresponds to a CSS class for HTML
When a string is uses as a style in an @racket[element],
a @racket[multiarg-element], @racket[paragraph], @racket[table],
@racket[itemization], @racket[nested-flow], or
@racket[compound-paragraph], it corresponds to a CSS class for HTML
output or a Latex macro/environment for Latex output. In Latex output,
the string is used as a command name for a @scheme[paragraph]
and an environment name for a @scheme[table], @scheme[itemization],
@scheme[nested-flow], or @scheme[compound-paragraph]; the if style has
a @scheme['command] @tech{style property} for a @scheme[nested-flow] or
@scheme[compound-paragraph], then the style name is used as a command
the string is used as a command name for a @racket[paragraph]
and an environment name for a @racket[table], @racket[itemization],
@racket[nested-flow], or @racket[compound-paragraph]; the if style has
a @racket['command] @tech{style property} for a @racket[nested-flow] or
@racket[compound-paragraph], then the style name is used as a command
instead of an environment. In addition, for an itemization, the style
string is suffixed with @scheme["Item"] and used as a CSS class or Latex
string is suffixed with @racket["Item"] and used as a CSS class or Latex
macro name to use for the itemization's items (in place of @tt{item}
in the case of Latex).
To add a mapping from your own style name to a CSS configuration, add
a @scheme[css-addition] structure instance to a style's @tech{style property}
a @racket[css-addition] structure instance to a style's @tech{style property}
list. To map a style name to a Latex macro or environment, add a
@scheme[tex-addition] structure instance. A @scheme[css-addition] or
@scheme[tex-addition] is normally associated with the style whose name
@racket[tex-addition] structure instance. A @racket[css-addition] or
@racket[tex-addition] is normally associated with the style whose name
is implemented by the adition, but it can also be added to the style
for an enclosing part.
Scribble includes a number of predefined styles that are used by the
exports of @scheme[scribble/base]. You can use them or redefine
exports of @racket[scribble/base]. You can use them or redefine
them. The styles are specified by @filepath{scribble.css} and
@filepath{scribble.tex} in the @filepath{scribble} collection.
The styles used by @schememodname[scribble/manual] are implemented by
@filepath{scheme.css} and @filepath{scheme.tex} in the
The styles used by @racketmodname[scribble/manual] are implemented by
@filepath{racket.css} and @filepath{racket.tex} in the
@filepath{scribble} collection. Other libraries, such as
@schememodname[scriblib/autobib], similarly implement styles through files
that are associated by @scheme[css-addition] and @scheme[tex-addition]
@racketmodname[scriblib/autobib], similarly implement styles through files
that are associated by @racket[css-addition] and @racket[tex-addition]
@tech{style properties}.
To avoid collisions with future additions to Scribble, start your
style name with an uppercase letter that is not @litchar{S}. An
uppercase letter helps to avoid collisions with macros defined by
Latex packages, and future styles needed by @schememodname[scribble/base] and
@schememodname[scribble/manual] will start with @litchar{S}.
Latex packages, and future styles needed by @racketmodname[scribble/base] and
@racketmodname[scribble/manual] will start with @litchar{S}.
For example, a Scribble document
@ -136,9 +136,9 @@ set of page-layout and font properties that are used by other
commands. The style-replacement kind of configuration corresponds to
re-defining Latex macros or overriding CSS class attributes. When
@exec{setup-plt} builds PDF documentation, it uses both kinds of
configuration to produce a standard layout for PLT Scheme manuals;
configuration to produce a standard layout for Racket manuals;
that is, it selects a particular page layout, and it replaces some
@schememodname[scheme/base] styles.
@racketmodname[racket/base] styles.
Two kinds of files implement the two kinds of configuration:
@ -155,7 +155,7 @@ Two kinds of files implement the two kinds of configuration:
@item{A @deftech{style file} refines the implementation of styles
nused in the document---typically just the ``built-in'' styles
used by @schememodname[scribble/base].
used by @racketmodname[scribble/base].
The default style files, @filepath{scribble-style.css} and
@filepath{scribble-style.tex} in the @filepath{scribble}
@ -185,30 +185,30 @@ accompanying files:
flag. Add additional style definitions and re-definitions using
the @as-index{@DPFlag{style}} flag.}
@item{Add additional accompanying files with @as-index{@DFlag{extra}}.}
@item{Add additional accompanying files with @as-index{@DPFlag{extra}}.}
]
When using the @exec{scribble} command-line utility, a document can
declare its default style, prefix, and extra files through a
@scheme[html-defaults] and/or @scheme[latex-defaults]
@racket[html-defaults] and/or @racket[latex-defaults]
@tech{style property}. In particular, when using the @exec{scribble}
command-line tool to generate Latex or PDF a document whose main part
is implemented with @scheme[#, @hash-lang[] #,
@schememodname[scribble/manual]], the result has the standard PLT
Scheme manual configuration, because @schememodname[scribble/manual]
associates a @scheme[latex-defaults] @tech{style property} with the exported
document. The @schememodname[scribble/sigplan] language similarly
is implemented with @racket[#, @hash-lang[] #,
@racketmodname[scribble/manual]], the result has the standard
Racket manual configuration, because @racketmodname[scribble/manual]
associates a @racket[latex-defaults] @tech{style property} with the exported
document. The @racketmodname[scribble/sigplan] language similarly
associates a default configuration with an exported document. As
libraries imported with @scheme[require], however,
@schememodname[scribble/manual] and @schememodname[scribble/sigplan]
libraries imported with @racket[require], however,
@racketmodname[scribble/manual] and @racketmodname[scribble/sigplan]
simply implement new styles in a composable way.
Whether or not a document has a default prefix- and style-file
configuration through a @tech{style property}, the defaults can be
overridden using @exec{scribble} command-line flags. Furthermore,
languages like @schememodname[scribble/manual] and
@schememodname[scribble/sigplan] add a @scheme[html-defaults] and/or
@scheme[latex-defaults] @tech{style property} to a main-document part only if
languages like @racketmodname[scribble/manual] and
@racketmodname[scribble/sigplan] add a @racket[html-defaults] and/or
@racket[latex-defaults] @tech{style property} to a main-document part only if
it does not already have such a property added through the
@scheme[#:style] argument of @scheme[title].
@racket[#:style] argument of @racket[title].

File diff suppressed because it is too large Load Diff

View File

@ -4,11 +4,11 @@
@title[#:tag "decode"]{Decoding Text}
@defmodule[scribble/decode]{The @schememodname[scribble/decode]
@defmodule[scribble/decode]{The @racketmodname[scribble/decode]
library helps you write document content in a natural way---more like
plain text, except for @litchar["@"] escapes. Roughly, it processes a
stream of strings to produces instances of the
@schememodname[scribble/struct] datatypes (see @secref["struct"]).}
@racketmodname[scribble/struct] datatypes (see @secref["struct"]).}
At the @tech{flow} level, decoding recognizes a blank line as a
@tech{paragraph} separator. Blocks and paragraphs without blank lines
@ -19,24 +19,24 @@ special text conversions:
@itemize[
@item{@litchar{---}: converted to @scheme['mdash], which the HTML render
@item{@litchar{---}: converted to @racket['mdash], which the HTML render
outputs as an en-dash surrounded by space (so don't put spaces around
@litchar{---} in a document)}
@item{@litchar{--}: converted to @scheme['ndash]}
@item{@litchar{--}: converted to @racket['ndash]}
@item{@litchar{``}: converted to @scheme['ldquo], which is fancy open quotes: ``}
@item{@litchar{``}: converted to @racket['ldquo], which is fancy open quotes: ``}
@item{@litchar{''}: converted to @scheme['rdquo], which is fancy closing quotes: ''}
@item{@litchar{''}: converted to @racket['rdquo], which is fancy closing quotes: ''}
@item{@litchar{'}: converted to @scheme['rsquo], which is a fancy apostrophe: '}
@item{@litchar{'}: converted to @racket['rsquo], which is a fancy apostrophe: '}
]
Some functions @deftech{decode} a sequence of @scheme[_pre-flow] or
@scheme[_pre-content] arguments using @scheme[decode-flow] or
@scheme[decode-content], respectively. For example, the @scheme[bold]
function accepts any number of @scheme[_pre-content] arguments, so
Some functions @deftech{decode} a sequence of @racket[_pre-flow] or
@racket[_pre-content] arguments using @racket[decode-flow] or
@racket[decode-content], respectively. For example, the @racket[bold]
function accepts any number of @racket[_pre-content] arguments, so
that in
@verbatim[#:indent 2]|{@bold{``apple''}}|
@ -47,52 +47,52 @@ then it is bolded.
@defproc[(pre-content? [v any/c]) boolean?]{
Returns @scheme[#t] if @scheme[v] is a @deftech{pre-content} value: a
string or other non-list @scheme[content], or a @scheme[splice]
Returns @racket[#t] if @racket[v] is a @deftech{pre-content} value: a
string or other non-list @racket[content], or a @racket[splice]
containing a list of @tech{pre-content} values; otherwise returns
@scheme[#f].
@racket[#f].
Pre-content is decoded into @tech{content} by functions like
@scheme[decode-content] and @scheme[decode-paragraph].}
@racket[decode-content] and @racket[decode-paragraph].}
@defproc[(pre-flow? [v any/c]) boolean?]{
Returns @scheme[#t] if @scheme[v] is a @deftech{pre-flow} value: a
string or other non-list @scheme[content], a @scheme[block],
@|void-const|, or a @scheme[splice] containing a list of
@tech{pre-flow} values; otherwise returns @scheme[#f].
Returns @racket[#t] if @racket[v] is a @deftech{pre-flow} value: a
string or other non-list @racket[content], a @racket[block],
@|void-const|, or a @racket[splice] containing a list of
@tech{pre-flow} values; otherwise returns @racket[#f].
Pre-flow is decoded into a @tech{flow} (i.e., a list of @tech{blocks})
by functions like @scheme[decode-flow].}
by functions like @racket[decode-flow].}
@defproc[(pre-part? [v any/c]) boolean?]{
Returns @scheme[#t] if @scheme[v] is a @deftech{pre-part} value: a
string or other non-list @scheme[content], a @scheme[block], a
@scheme[part], a @scheme[title-decl], a @scheme[part-start], a
@scheme[part-index-decl], a @scheme[part-collect-decl], a
@scheme[part-tag-decl], @|void-const|, or a @scheme[splice] containing
a list of @tech{pre-part} values; otherwise returns @scheme[#f].
Returns @racket[#t] if @racket[v] is a @deftech{pre-part} value: a
string or other non-list @tech{content}, a @tech{block}, a
@racket[part], a @racket[title-decl], a @racket[part-start], a
@racket[part-index-decl], a @racket[part-collect-decl], a
@racket[part-tag-decl], @|void-const|, or a @racket[splice] containing
a list of @tech{pre-part} values; otherwise returns @racket[#f].
A pre-part sequences is decoded into a @scheme[part] by functions like
@scheme[decode] and @scheme[decode-part].}
A pre-part sequence is decoded into a @racket[part] by functions like
@racket[decode] and @racket[decode-part].}
@defproc[(decode [lst (listof pre-part?)]) part?]{
Decodes a document, producing a part. In @scheme[lst], instances of
@scheme[splice] are inlined into the list. An instance of
@scheme[title-decl] supplies the title for the part, plus tag, style
and version information. Instances of @scheme[part-index-decl] (that
Decodes a document, producing a part. In @racket[lst], instances of
@racket[splice] are inlined into the list. An instance of
@racket[title-decl] supplies the title for the part, plus tag, style
and version information. Instances of @racket[part-index-decl] (that
precede any sub-part) add index entries that point to the
section. Instances of @scheme[part-collect-decl] add elements to the
section. Instances of @racket[part-collect-decl] add elements to the
part that are used only during the @techlink{collect pass}. Instances
of @scheme[part-tag-decl] add hyperlink tags to the section
title. Instances of @scheme[part-start] at level 0 trigger sub-part
parsing. Instances of @scheme[section] trigger are used as-is as
subsections, and instances of @scheme[paragraph] and other
of @racket[part-tag-decl] add hyperlink tags to the section
title. Instances of @racket[part-start] at level 0 trigger sub-part
parsing. Instances of @racket[section] trigger are used as-is as
subsections, and instances of @racket[paragraph] and other
flow-element datatypes are used as-is in the enclosing flow.}
@ -102,9 +102,9 @@ flow-element datatypes are used as-is in the enclosing flow.}
[depth exact-nonnegative-integer?])
part?]{
Like @scheme[decode], but given a list of tag string for the part, a
title (if @scheme[#f], then a @scheme[title-decl] instance is used if
found), and a depth for @scheme[part-start]s to trigger sub-part
Like @racket[decode], but given a list of tag string for the part, a
title (if @racket[#f], then a @racket[title-decl] instance is used if
found), and a depth for @racket[part-start]s to trigger sub-part
parsing.
}
@ -112,9 +112,9 @@ parsing.
@defproc[(decode-flow [lst (listof pre-flow?)]) flow?]{
Decodes a flow. A sequence of two or more newlines separated only by
whitespace counts is parsed as a paragraph separator. In @scheme[lst],
instances of @scheme[splice] are inlined into the list. Instances of
@scheme[paragraph] and other flow-element datatypes are used as-is in
whitespace counts is parsed as a paragraph separator. In @racket[lst],
instances of @racket[splice] are inlined into the list. Instances of
@racket[paragraph] and other flow-element datatypes are used as-is in
the enclosing flow.
}
@ -123,7 +123,7 @@ the enclosing flow.
Decodes a compound paragraph. If the compound paragraph contains a
single block, the block is returned without a
@scheme[compound-paragraph] wrapper.
@racket[compound-paragraph] wrapper.
}
@ -141,7 +141,7 @@ Decodes @tech{content}.
@defproc[(decode-elements [lst (listof pre-content?)]) list?]{
An alias for @scheme[decode-content].
An alias for @racket[decode-content].
}
@defproc[(decode-string [s string?]) (listof content?)]{
@ -153,7 +153,7 @@ Decodes a single string to produce @tech{content}.
@defproc[(whitespace? [s string?]) boolean?]{
Returns @scheme[#t] if @scheme[s] contains only whitespace, @scheme[#f]
Returns @racket[#t] if @racket[s] contains only whitespace, @racket[#f]
otherwise.
}
@ -164,9 +164,9 @@ otherwise.
[style any/c]
[content content?])]{
See @scheme[decode] and @scheme[decode-part]. The @scheme[tag-prefix]
and @scheme[style] fields are propagated to the resulting
@scheme[part].
See @racket[decode] and @racket[decode-part]. The @racket[tag-prefix]
and @racket[style] fields are propagated to the resulting
@racket[part].
}
@ -176,33 +176,33 @@ and @scheme[style] fields are propagated to the resulting
[style any/c]
[title content?])]{
Like @scheme[title-decl], but for a sub-part. See @scheme[decode] and
@scheme[decode-part].
Like @racket[title-decl], but for a sub-part. See @racket[decode] and
@racket[decode-part].
}
@defstruct[part-index-decl ([plain-seq (listof string?)]
[entry-seq list?])]{
See @scheme[decode]. The two fields are as for @scheme[index-element].
See @racket[decode]. The two fields are as for @racket[index-element].
}
@defstruct[part-collect-decl ([element element?])]{
See @scheme[decode].
See @racket[decode].
}
@defstruct[part-tag-decl ([tag tag?])]{
See @scheme[decode].
See @racket[decode].
}
@defstruct[splice ([run list?])]{
See @scheme[decode], @scheme[decode-part], and @scheme[decode-flow].
See @racket[decode], @racket[decode-part], and @racket[decode-flow].
}

View File

@ -3,16 +3,16 @@
@title[#:tag "doclang"]{Document Language}
@defmodulelang[scribble/doclang]{The @schememodname[scribble/doclang]
language provides everything from @scheme[scheme/base], except that it
replaces the @scheme[#%module-begin] form.}
@defmodulelang[scribble/doclang]{The @racketmodname[scribble/doclang]
language provides everything from @racket[racket/base], except that it
replaces the @racket[#%module-begin] form.}
The @schememodname[scribble/doclang] @scheme[#%module-begin]
The @racketmodname[scribble/doclang] @racket[#%module-begin]
essentially packages the body of the module into a call to
@scheme[decode], binds the result to @scheme[doc], and exports
@scheme[doc].
@racket[decode], binds the result to @racket[doc], and exports
@racket[doc].
Any module-level form other than an expression (e.g., a
@scheme[require] or @scheme[define]) remains at the top level, and
the @scheme[doc] binding is put at the end of the module. As usual, a
module-top-level @scheme[begin] slices into the module top level.
@racket[require] or @racket[define]) remains at the top level, and
the @racket[doc] binding is put at the end of the module. As usual, a
module-top-level @racket[begin] slices into the module top level.

View File

@ -5,8 +5,8 @@
@title[#:tag "docreader"]{Document Reader}
@defmodulelang[scribble/doc]{The @schememodname[scribble/doc] language is
the same as @schememodname[scribble/doclang], except that
@scheme[read-syntax-inside] is used to read the body of the module. In
@defmodulelang[scribble/doc]{The @racketmodname[scribble/doc] language is
the same as @racketmodname[scribble/doclang], except that
@racket[read-syntax-inside] is used to read the body of the module. In
other words, the module body starts in Scribble ``text'' mode instead
of S-expression mode.}

View File

@ -1,11 +1,11 @@
#lang scribble/doc
@(require scribble/manual
"utils.ss"
(for-label scheme/sandbox))
(for-label racket/sandbox))
@title[#:tag "eval"]{Evaluation and Examples}
@defmodule[scribble/eval]{The @scheme[scribble/eval] library provides
@defmodule[scribble/eval]{The @racket[scribble/eval] library provides
utilities for evaluating code at document-build time and incorporating
the results in the document, especially to show example uses of
defined procedures and syntax.}
@ -13,106 +13,106 @@ defined procedures and syntax.}
@defform*[[(interaction datum ...)
(interaction #:eval eval-expr datum ...)]]{
Like @scheme[schemeinput], except that the result for each input
@scheme[datum] is shown on the next line. The result is determined by
evaluating the @scheme[quote]d form of the @scheme[datum] using the
evaluator produced by @scheme[eval-expr], if provided.
Like @racket[racketinput], except that the result for each input
@racket[datum] is shown on the next line. The result is determined by
evaluating the @racket[quote]d form of the @racket[datum] using the
evaluator produced by @racket[eval-expr], if provided.
The @scheme[eval-expr] must produce a sandbox evaluator via
@scheme[make-evaluator] or @scheme[make-module-evaluator] with the
@scheme[sandbox-output] and @scheme[sandbox-error-output] parameters
set to @scheme['string]. If @scheme[eval] is not provided, an
evaluator is created using @scheme[make-base-eval]. See also
@scheme[make-eval-factory].
The @racket[eval-expr] must produce a sandbox evaluator via
@racket[make-evaluator] or @racket[make-module-evaluator] with the
@racket[sandbox-output] and @racket[sandbox-error-output] parameters
set to @racket['string]. If @racket[eval] is not provided, an
evaluator is created using @racket[make-base-eval]. See also
@racket[make-eval-factory].
Uses of @scheme[code:comment] and @schemeidfont{code:blank} are
stipped from each @scheme[datum] before evaluation.
Uses of @racket[code:comment] and @racketidfont{code:blank} are
stipped from each @racket[datum] before evaluation.
If a @scheme[datum] has the form @scheme[(eval:alts #,(svar
show-datum) #,(svar eval-datum))], then @svar[show-datum] is typeset,
while @svar[eval-datum] is evaluated.}
If a @racket[datum] has the form @racket[(@#,indexed-racket[eval:alts]
#,(svar show-datum) #,(svar eval-datum))], then @svar[show-datum] is
typeset, while @svar[eval-datum] is evaluated.}
@defform*[[(interaction-eval datum)
(interaction-eval #:eval eval-expr datum)]]{
Like @scheme[interaction], evaluates the @scheme[quote]d form of
@scheme[datum], but returns the empty string.}
Like @racket[interaction], evaluates the @racket[quote]d form of
@racket[datum], but returns the empty string.}
@defform*[[(interaction-eval-show datum)
(interaction-eval-show #:eval eval-expr datum)]]{
Like @scheme[interaction-eval], but produces an element representing
Like @racket[interaction-eval], but produces an element representing
the printed form of the evaluation result.}
@defform*[[(schemeblock+eval datum ...)
(schemeblock+eval #:eval eval-expr datum ...)]]{
@defform*[[(racketblock+eval datum ...)
(racketblock+eval #:eval eval-expr datum ...)]]{
Combines @scheme[schemeblock] and @scheme[interaction-eval].}
Combines @racket[racketblock] and @racket[interaction-eval].}
@defform*[[(schememod+eval name datum ...)
(schememod+eval #:eval eval-expr name datum ...)]]{
@defform*[[(racketmod+eval name datum ...)
(racketmod+eval #:eval eval-expr name datum ...)]]{
Combines @scheme[schememod] and @scheme[interaction-eval].}
Combines @racket[racketmod] and @racket[interaction-eval].}
@defform*[[(def+int defn-datum expr-datum ...)
(def+int #:eval eval-expr defn-datum expr-datum ...)]]{
Like @scheme[interaction], except the @scheme[defn-datum] is
typeset as for @scheme[schemeblock] (i.e., no prompt) and a line of
space is inserted before the @scheme[expr-datum]s.}
Like @racket[interaction], except the @racket[defn-datum] is
typeset as for @racket[racketblock] (i.e., no prompt) and a line of
space is inserted before the @racket[expr-datum]s.}
@defform*[[(defs+int (defn-datum ...) expr-datum ...)
(defs+int #:eval eval-expr (defn-datum ...) expr-datum ...)]]{
Like @scheme[def+int], but for multiple leading definitions.}
Like @racket[def+int], but for multiple leading definitions.}
@defform*[[(examples datum ...)
(examples #:eval eval-expr datum ...)]]{
Like @scheme[interaction], but with an ``Examples:'' label prefixed.}
Like @racket[interaction], but with an ``Examples:'' label prefixed.}
@defform*[[(defexamples datum ...)
(defexamples #:eval eval-expr datum ...)]]{
Like @scheme[examples], but each definition using @scheme[define] or
@scheme[define-struct] among the @scheme[datum]s is typeset without a
Like @racket[examples], but each definition using @racket[define] or
@racket[define-struct] among the @racket[datum]s is typeset without a
prompt, and with line of space after it.}
@defproc[(make-base-eval) (any/c . -> . any)]{
Creates an evaluator using @scheme[(make-evaluator 'scheme/base)],
Creates an evaluator using @racket[(make-evaluator 'racket/base)],
setting sandbox parameters to disable limits, set the outputs to
@scheme['string], and not add extra security guards.}
@racket['string], and not add extra security guards.}
@defproc[(make-base-eval-factory [mod-paths (listof module-path?)]) (-> (any/c . -> . any))]{
Produces a function that is like @scheme[make-base-eval], except that
each module in @scheme[mod-paths] is attached to the evaluator's
Produces a function that is like @racket[make-base-eval], except that
each module in @racket[mod-paths] is attached to the evaluator's
namespace. The modules are loaded and instantiated once (when the
returned @scheme[make-base-eval]-like function is called the first
returned @racket[make-base-eval]-like function is called the first
time) and then attached to each evaluator that is created.}
@defproc[(make-eval-factory [mod-paths (listof module-path?)]) (-> (any/c . -> . any))]{
Like @scheme[make-base-eval-factor], but each module in @scheme[mod-paths] is
Like @racket[make-base-eval-factor], but each module in @racket[mod-paths] is
also required into the top-level environment for each generated evaluator.}
@defproc[(close-eval [eval (any/c . -> . any)]) (one-of/c "")]{
Shuts down an evaluator produced by @scheme[make-base-eval]. Use
@scheme[close-eval] when garbage collection cannot otherwise reclaim
Shuts down an evaluator produced by @racket[make-base-eval]. Use
@racket[close-eval] when garbage collection cannot otherwise reclaim
an evaluator (e.g., because it is defined in a module body).}
@ -122,5 +122,5 @@ an evaluator (e.g., because it is defined in a module body).}
A parameter that serves as a hook for evaluation. The evaluator to use
is supplied as the first argument to the parameter's value, and the
second argument is the form to evaluate. The last argument is
@scheme[#t] if exceptions are being captured (to display exception
results), @scheme[#f] otherwise.}
@racket[#t] if exceptions are being captured (to display exception
results), @racket[#f] otherwise.}

Some files were not shown because too many files have changed in this diff Show More