partly rackety guide
original commit: 1fedf0473951b9531c9735417adea1b0dd647b9a
This commit is contained in:
commit
6f85ed0e8f
|
@ -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)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"scheme.ss"
|
||||
"decode.ss"
|
||||
racket/file
|
||||
scheme/sandbox
|
||||
racket/sandbox
|
||||
racket/promise
|
||||
mzlib/string
|
||||
(for-syntax racket/base))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
(define mzscheme-launcher-libraries '("run.ss"))
|
||||
(define compile-omit-paths '("test-reader.ss"))
|
||||
|
||||
(define racket-tools
|
||||
(define raco-commands
|
||||
'(("scribble" scribble/run "render a Scribble document" #f)))
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
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)
|
||||
|
@ -269,32 +271,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))
|
||||
|
@ -409,7 +411,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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -118,6 +118,8 @@
|
|||
(define-struct (cached-delayed-element delayed-element) (cache-key))
|
||||
(define-struct (cached-element element) (cache-key))
|
||||
|
||||
(define qq-ellipses (string->uninterned-symbol "..."))
|
||||
|
||||
(define (make-id-element c s)
|
||||
(let* ([key (and id-element-cache
|
||||
(let ([b (identifier-label-binding c)])
|
||||
|
@ -201,7 +203,7 @@
|
|||
is-var?)))
|
||||
(values (substring s 1) #t #f)
|
||||
(values s #f #f))))])
|
||||
(let ([quote-depth (if (and qq? (identifier? c))
|
||||
(let ([quote-depth (if (and qq? (identifier? c) (not (eq? qq-ellipses (syntax-e c))))
|
||||
(let ([quote-depth
|
||||
(if (and (quote-depth . < . 2)
|
||||
(memq (syntax-e c) '(unquote unquote-splicing)))
|
||||
|
@ -519,7 +521,7 @@
|
|||
(set! src-col (+ src-col (- (syntax-span c) 2)))
|
||||
(set! src-col (+ src-col (- (syntax-column (vector-ref vec 0))
|
||||
(syntax-column c)
|
||||
1)))))))
|
||||
1))))))
|
||||
(when (struct? (syntax-e c))
|
||||
(out "#s" p-color)
|
||||
(set! src-col (+ src-col 2)))
|
||||
|
@ -532,7 +534,7 @@
|
|||
(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)]
|
||||
(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
|
||||
|
@ -599,7 +601,7 @@
|
|||
p-color)
|
||||
(set! src-col (+ src-col 1))
|
||||
#;
|
||||
(hash-set! next-col-map src-col dest-col))]
|
||||
(hash-set! next-col-map src-col dest-col)))]
|
||||
[(box? (syntax-e c))
|
||||
(advance c init-line!)
|
||||
(let ([quote-depth (to-quoted "`" qq? quote-depth out color? inc-src-col)])
|
||||
|
@ -609,43 +611,64 @@
|
|||
((loop init-line! (if qq? quote-depth +inf.0) qq?) (unbox (syntax-e c))))]
|
||||
[(hash? (syntax-e c))
|
||||
(advance c init-line!)
|
||||
(let ([equal-table? (not (hash-eq? (syntax-e c)))]
|
||||
(let ([equal-table? (hash-equal? (syntax-e c))]
|
||||
[eqv-table? (hash-eq? (syntax-e c))]
|
||||
[quote-depth (to-quoted "`" qq? quote-depth out color? inc-src-col)])
|
||||
(out (if equal-table?
|
||||
"#hash"
|
||||
"#hasheq")
|
||||
(if eqv-table?
|
||||
"#hasheqv"
|
||||
"#hasheq"))
|
||||
value-color)
|
||||
(let ([delta (+ 5 (if equal-table? 2 0))]
|
||||
(let ([delta (+ 5 (if equal-table? 0 (if eqv-table? 3 2)))]
|
||||
[orig-col src-col])
|
||||
(set! src-col (+ src-col delta))
|
||||
(hash-set! next-col-map src-col dest-col)
|
||||
((loop init-line! (if qq? quote-depth +inf.0) qq?)
|
||||
(let* ([l (sort (hash-map (syntax-e c) cons)
|
||||
(lambda (a b)
|
||||
(< (or (syntax-position (cdr a)) -inf.0)
|
||||
(or (syntax-position (cdr b)) -inf.0))))]
|
||||
[l2 (for/list ([p (in-list l)])
|
||||
(let* ([tentative (syntax-ize (car p) 0)]
|
||||
[width (syntax-span tentative)])
|
||||
(datum->syntax
|
||||
#f
|
||||
(make-forced-pair
|
||||
(syntax-ize (car p)
|
||||
(max 0 (- (syntax-column (cdr p))
|
||||
width
|
||||
3))
|
||||
(syntax-line (cdr p)))
|
||||
(cdr p))
|
||||
(vector 'here
|
||||
(syntax-line (cdr p))
|
||||
(max 0 (- (syntax-column (cdr p)) width 4))
|
||||
(max 1 (- (syntax-position (cdr p)) width 4))
|
||||
(+ (syntax-span (cdr p)) width 5)))))])
|
||||
(datum->syntax #f l2 (vector (syntax-source c)
|
||||
(syntax-line c)
|
||||
(+ (syntax-column c) delta)
|
||||
(+ (syntax-position c) delta)
|
||||
(max 1 (- (syntax-span c) delta))))))
|
||||
(let*-values ([(l) (sort (hash-map (syntax-e c) cons)
|
||||
(lambda (a b)
|
||||
(< (or (syntax-position (cdr a)) -inf.0)
|
||||
(or (syntax-position (cdr b)) -inf.0))))]
|
||||
[(col0) (+ (syntax-column c) delta 2)]
|
||||
[(l2 pos line) (for/fold ([l2 null][col col0][line (syntax-line c)])
|
||||
([p (in-list l)])
|
||||
(let* ([tentative (syntax-ize (car p) 0)]
|
||||
[width (syntax-span tentative)]
|
||||
[col (if (= line (syntax-line (cdr p)))
|
||||
col
|
||||
col0)])
|
||||
(let ([key
|
||||
(let ([e (syntax-ize (car p)
|
||||
(max 0 (- (syntax-column (cdr p))
|
||||
width
|
||||
3))
|
||||
(syntax-line (cdr p)))])
|
||||
(if ((syntax-column e) . <= . col)
|
||||
e
|
||||
(datum->syntax #f
|
||||
(syntax-e e)
|
||||
(vector (syntax-source e)
|
||||
(syntax-line e)
|
||||
col
|
||||
(syntax-position e)
|
||||
(+ (syntax-span e) (- (syntax-column e) col))))))])
|
||||
(let ([elem
|
||||
(datum->syntax
|
||||
#f
|
||||
(make-forced-pair key (cdr p))
|
||||
(vector 'here
|
||||
(syntax-line (cdr p))
|
||||
(max 0 (- (syntax-column key) 1))
|
||||
(max 1 (- (syntax-position key) 1))
|
||||
(+ (syntax-span (cdr p)) (syntax-span key) 5)))])
|
||||
(values (cons elem l2)
|
||||
(+ (syntax-column elem) (syntax-span elem) 2)
|
||||
(syntax-line elem))))))])
|
||||
(datum->syntax #f (reverse l2) (vector (syntax-source c)
|
||||
(syntax-line c)
|
||||
(+ (syntax-column c) delta)
|
||||
(+ (syntax-position c) delta)
|
||||
(max 1 (- (syntax-span c) delta))))))
|
||||
(set! src-col (+ orig-col (syntax-span c)))))]
|
||||
[(graph-reference? (syntax-e c))
|
||||
(advance c init-line!)
|
||||
|
@ -663,6 +686,11 @@
|
|||
paren-color))
|
||||
(set! src-col (+ src-col 3))
|
||||
((loop init-line! quote-depth qq?) (graph-defn-r (syntax-e c))))]
|
||||
[(and (keyword? (syntax-e c)) qq?)
|
||||
(advance c init-line!)
|
||||
(let ([quote-depth (to-quoted "`" qq? quote-depth out color? inc-src-col)])
|
||||
(typeset-atom c out color? quote-depth qq?)
|
||||
(set! src-col (+ src-col (or (syntax-span c) 1))))]
|
||||
[else
|
||||
(advance c init-line!)
|
||||
(typeset-atom c out color? quote-depth qq?)
|
||||
|
@ -700,7 +728,9 @@
|
|||
(hash? s)
|
||||
(graph-defn? s)
|
||||
(graph-reference? s)
|
||||
(struct-proxy? s))
|
||||
(struct-proxy? s)
|
||||
(and qq? (or (identifier? c)
|
||||
(keyword? (syntax-e c)))))
|
||||
(gen-typeset c multi-line? prefix1 prefix suffix color? qq?)
|
||||
(typeset-atom c
|
||||
(letrec ([mk
|
||||
|
@ -949,7 +979,7 @@
|
|||
(if pf
|
||||
(prefab-struct-key v)
|
||||
(object-name v)))
|
||||
(cdr (vector->list (struct->vector v))))]
|
||||
(cdr (vector->list (struct->vector v qq-ellipses))))]
|
||||
[else v])])
|
||||
(if (null? v)
|
||||
null
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
scheme/cmdline
|
||||
scheme/file
|
||||
scheme/class
|
||||
tool/command-name
|
||||
raco/command-name
|
||||
(prefix-in text: "text-render.ss")
|
||||
(prefix-in html: "html-render.ss")
|
||||
(prefix-in latex: "latex-render.ss")
|
||||
|
@ -34,12 +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"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#lang scheme/base
|
||||
#lang racket/base
|
||||
|
||||
(require scheme/promise "text/output.ss" "text/syntax-utils.ss")
|
||||
(provide (all-from-out scheme/promise "text/output.ss")
|
||||
(require racket/promise "text/output.ss" "text/syntax-utils.ss")
|
||||
(provide (all-from-out racket/promise "text/output.ss")
|
||||
begin/text include/text)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#lang scheme/base
|
||||
#lang racket/base
|
||||
|
||||
(require "syntax-utils.ss" "output.ss" scheme/promise)
|
||||
(require "syntax-utils.ss" "output.ss" racket/promise)
|
||||
|
||||
(provide (except-out (all-from-out scheme/base) #%module-begin)
|
||||
(all-from-out "output.ss" scheme/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]))
|
||||
|
|
|
@ -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}
|
||||
|
@ -191,24 +191,24 @@ accompanying files:
|
|||
|
||||
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].
|
||||
|
|
|
@ -617,19 +617,28 @@ Like @scheme[defparam], but the contract on a parameter argument is
|
|||
|
||||
Like @scheme[defproc], but for a non-procedure binding.}
|
||||
|
||||
|
||||
@defform/subs[(defstruct struct-name ([field-name contract-expr-datum] ...)
|
||||
flag-keywords
|
||||
pre-flow ...)
|
||||
([struct-name id
|
||||
(id super-id)]
|
||||
[flag-keywords code:blank
|
||||
#:mutable
|
||||
(code:line #:inspector #f)
|
||||
(code:line #:mutable #:inspector #f)])]{
|
||||
@deftogether[(
|
||||
@defform[ (defstruct* struct-name ([field-name contract-expr-datum] ...)
|
||||
maybe-mutable maybe-non-opaque maybe-constructor
|
||||
pre-flow ...)]
|
||||
@defform/subs[ (defstruct struct-name ([field-name contract-expr-datum] ...)
|
||||
maybe-mutable maybe-non-opaque maybe-constructor
|
||||
pre-flow ...)
|
||||
([struct-name id
|
||||
(id super-id)]
|
||||
[maybe-mutable code:blank
|
||||
#:mutable]
|
||||
[maybe-non-opaque code:blank
|
||||
#:prefab
|
||||
#:transparent]
|
||||
[maybe-constructor code:blank
|
||||
(code:line #:constructor-name constructor-id)
|
||||
(code:line #:extra-constructor-name constructor-id)])]
|
||||
)]{
|
||||
|
||||
Similar to @scheme[defform] or @scheme[defproc], but for a structure
|
||||
definition.}
|
||||
definition. The @scheme[defstruct*] form corresponds to @scheme[struct],
|
||||
while @scheme[defstruct] corresponds to @scheme[define-struct].}
|
||||
|
||||
|
||||
@defform[(deftogether [def-expr ...] pre-flow ...)]{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
@(require scribble/manual
|
||||
scribble/core scribble/html-properties scribble/latex-properties
|
||||
"utils.ss"
|
||||
(for-label scheme/base
|
||||
(for-label racket/base
|
||||
;; FIXME: need to get this in
|
||||
;; scribble/text
|
||||
))
|
||||
|
@ -13,21 +13,21 @@
|
|||
(make-css-addition "shaded.css")))
|
||||
]{Text Preprocessing}
|
||||
|
||||
@defmodulelang[scribble/text]{The @schememodname[scribble/text]
|
||||
language provides everything from @scheme[scheme/base] with a few
|
||||
@defmodulelang[scribble/text]{The @racketmodname[scribble/text]
|
||||
language provides everything from @racket[racket/base] with a few
|
||||
changes that make it suitable as a preprocessor language:
|
||||
|
||||
@itemize[
|
||||
|
||||
@item{It uses @scheme[read-syntax-inside] to read the body of the
|
||||
@item{It uses @racket[read-syntax-inside] to read the body of the
|
||||
module, similar to @secref["docreader"]. This means that by
|
||||
default, all text is read in as Scheme strings; and
|
||||
@seclink["reader"]|{@-forms}| can be used to use Scheme
|
||||
default, all text is read in as Racket strings; and
|
||||
@seclink["reader"]|{@-forms}| can be used to use Racket
|
||||
functions and expression escapes.}
|
||||
|
||||
@item{Values of expressions are printed with a custom
|
||||
@scheme[output] function. This function displays most values
|
||||
in a similar way to @scheme[display], except that it is more
|
||||
@racket[output] function. This function displays most values
|
||||
in a similar way to @racket[display], except that it is more
|
||||
convenient for a preprocessor output.}]
|
||||
|
||||
}
|
||||
|
@ -42,9 +42,9 @@ changes that make it suitable as a preprocessor language:
|
|||
@section{Writing Preprocessor Files}
|
||||
|
||||
The combination of the two features makes text in files in the
|
||||
@scheme[scribble/text] language be read as strings, which get printed
|
||||
out when the module is @scheme[require]d, for example, when a file is
|
||||
given as an argument to @exec{mzscheme}. (In these example the left
|
||||
@racket[scribble/text] language be read as strings, which get printed
|
||||
out when the module is @racket[require]d, for example, when a file is
|
||||
given as an argument to @exec{racket}. (In these example the left
|
||||
part shows the source input, and the right part the printed result.)
|
||||
|
||||
@example|-{#lang scribble/text
|
||||
|
@ -58,14 +58,14 @@ part shows the source input, and the right part the printed result.)
|
|||
feature on top of feature, but
|
||||
blah blah blah.}-|
|
||||
|
||||
Using @seclink["reader"]|{@-forms}|, we can define and use Scheme
|
||||
Using @seclink["reader"]|{@-forms}|, we can define and use Racket
|
||||
functions.
|
||||
|
||||
@example|-{#lang scribble/text
|
||||
@(require scheme/list)
|
||||
@(require racket/list)
|
||||
@(define Foo "Preprocessing")
|
||||
@(define (3x . x)
|
||||
;; scheme syntax here
|
||||
;; racket syntax here
|
||||
(add-between (list x x x) " "))
|
||||
@Foo languages should
|
||||
be designed not by piling
|
||||
|
@ -77,10 +77,10 @@ functions.
|
|||
feature on top of feature, but
|
||||
blah blah blah.}-|
|
||||
|
||||
As demonstrated in this case, the @scheme[output] function simply
|
||||
As demonstrated in this case, the @racket[output] function simply
|
||||
scans nested list structures recursively, which makes them convenient
|
||||
for function results. In addition, @scheme[output] prints most values
|
||||
similarly to @scheme[display] --- notable exceptions are void and
|
||||
for function results. In addition, @racket[output] prints most values
|
||||
similarly to @racket[display] --- notable exceptions are void and
|
||||
false values which cause no output to appear. This can be used for
|
||||
convenient conditional output.
|
||||
|
||||
|
@ -184,7 +184,7 @@ what looks like erroneous indentation. More about this below.)
|
|||
A better approach is to generate newlines only when needed.
|
||||
|
||||
@example|-{#lang scribble/text
|
||||
@(require scheme/list)
|
||||
@(require racket/list)
|
||||
@(define (counts n str)
|
||||
(add-between
|
||||
(for/list ([i (in-range 1 (+ n 1))])
|
||||
|
@ -200,9 +200,9 @@ A better approach is to generate newlines only when needed.
|
|||
3 Mississippi,
|
||||
... and I'm done.}-|
|
||||
|
||||
In fact, this is common enough that the @scheme[scribble/text]
|
||||
language provides a convenient facility: @scheme[add-newlines] is a
|
||||
function that is similar to @scheme[add-between] using a newline
|
||||
In fact, this is common enough that the @racket[scribble/text]
|
||||
language provides a convenient facility: @racket[add-newlines] is a
|
||||
function that is similar to @racket[add-between] using a newline
|
||||
string as the default separator, except that false and void values are
|
||||
filtered out before doing so.
|
||||
|
||||
|
@ -262,9 +262,9 @@ that uses the Scribble @"@"-form syntax.)
|
|||
|
||||
Because the Scribble reader is uniform, you can use it in place of any
|
||||
expression where it is more convenient. (By convention, we use a
|
||||
plain S-expression syntax when we want a Scheme expression escape, and
|
||||
plain S-expression syntax when we want a Racket expression escape, and
|
||||
an @"@"-form for expressions that render as text, which, in the
|
||||
@scheme[scribble/text] language, is any value-producing expression.)
|
||||
@racket[scribble/text] language, is any value-producing expression.)
|
||||
For example, you can use an @"@"-form for a function that you define.
|
||||
|
||||
@example|-{#lang scribble/text
|
||||
|
@ -291,7 +291,7 @@ separate text arguments in the S-expression part of an @"@"-form.
|
|||
Either you're with us, or against us.
|
||||
}-|
|
||||
|
||||
You can even use @"@"-forms with a Scheme quote or quasiquote as the
|
||||
You can even use @"@"-forms with a Racket quote or quasiquote as the
|
||||
``head'' part to make it shorter, or use a macro to get grouping of
|
||||
sub-parts without dealing with quotes.
|
||||
|
||||
|
@ -317,11 +317,11 @@ sub-parts without dealing with quotes.
|
|||
}-|
|
||||
|
||||
Yet another solution is to look at the text values and split the input
|
||||
arguments based on a specific token. Using @scheme[match] can make it
|
||||
arguments based on a specific token. Using @racket[match] can make it
|
||||
convenient --- you can even specify the patterns with @"@"-forms.
|
||||
|
||||
@example|-{#lang scribble/text
|
||||
@(require scheme/match)
|
||||
@(require racket/match)
|
||||
@(define (features . text)
|
||||
(match text
|
||||
[@list{@|1st|@...
|
||||
|
@ -346,11 +346,11 @@ convenient --- you can even specify the patterns with @"@"-forms.
|
|||
}-|
|
||||
|
||||
In particular, it is often convenient to split the input by lines,
|
||||
identified by delimiting @scheme["\n"] strings. Since this can be
|
||||
useful, a @scheme[split-lines] function is provided.
|
||||
identified by delimiting @racket["\n"] strings. Since this can be
|
||||
useful, a @racket[split-lines] function is provided.
|
||||
|
||||
@example|-{#lang scribble/text
|
||||
@(require scheme/list)
|
||||
@(require racket/list)
|
||||
@(define (features . text)
|
||||
(add-between (split-lines text)
|
||||
", "))
|
||||
|
@ -437,9 +437,9 @@ printouts, as the results are rarely desirable.
|
|||
two1 3}-|
|
||||
|
||||
Note that you don't need side-effects if you want infinite output.
|
||||
The @scheme[output] function iterates thunks and (composable)
|
||||
The @racket[output] function iterates thunks and (composable)
|
||||
promises, so you can create a loop that is delayed in either form.
|
||||
@; Note: there is some sfs-related problem in mzscheme that makes it not
|
||||
@; Note: there is some sfs-related problem in racket that makes it not
|
||||
@; run in bounded space, so don't show it for nowx.
|
||||
|
||||
@example|-{#lang scribble/text
|
||||
|
@ -483,12 +483,12 @@ The Scribble reader ignores indentation spaces in its body. This is
|
|||
an intentional feature, since you usually do not want an expression to
|
||||
depend on its position in the source. But the question is how
|
||||
@emph{can} we render some output text with proper indentation. The
|
||||
@scheme[output] function achieves that by assigning a special meaning
|
||||
@racket[output] function achieves that by assigning a special meaning
|
||||
to lists: when a newline is part of a list's contents, it causes the
|
||||
following text to appear with indentation that corresponds to the
|
||||
column position at the beginning of the list. In most cases, this
|
||||
makes the output appear ``as intended'' when lists are used for nested
|
||||
pieces of text --- either from a literal @scheme[list] expression, or
|
||||
pieces of text --- either from a literal @racket[list] expression, or
|
||||
an expression that evaluates to a list, or when a list is passed on as
|
||||
a value; either as a toplevel expression, or as a nested value; either
|
||||
appearing after spaces, or after other output.
|
||||
|
@ -530,11 +530,11 @@ appearing after spaces, or after other output.
|
|||
(for/list ([i (in-naturals 1)]
|
||||
[item (in-list items)])
|
||||
@list{@|i|. @item})))
|
||||
Todo: @enumerate[@list{Install PLT Scheme}
|
||||
Todo: @enumerate[@list{Install Racket}
|
||||
@list{Hack, hack, hack}
|
||||
@list{Profit}].
|
||||
---***---
|
||||
Todo: 1. Install PLT Scheme;
|
||||
Todo: 1. Install Racket;
|
||||
2. Hack, hack, hack;
|
||||
3. Profit.}-|
|
||||
|
||||
|
@ -697,8 +697,8 @@ appearing after spaces, or after other output.
|
|||
}-|
|
||||
|
||||
There are, however, cases when you need more refined control over the
|
||||
output. The @scheme[scribble/text] provides a few functions for such
|
||||
cases. The @scheme[splice] function is used to group together a
|
||||
output. The @racket[scribble/text] provides a few functions for such
|
||||
cases. The @racket[splice] function is used to group together a
|
||||
number of values but avoid introducing a new indentation context.
|
||||
|
||||
@example|-{#lang scribble/text
|
||||
|
@ -723,9 +723,9 @@ number of values but avoid introducing a new indentation context.
|
|||
end
|
||||
}-|
|
||||
|
||||
The @scheme[disable-prefix] function disables all indentation
|
||||
The @racket[disable-prefix] function disables all indentation
|
||||
printouts in its contents, including the indentation before the body
|
||||
of the @scheme[disable-prefix] value itself. It is useful, for
|
||||
of the @racket[disable-prefix] value itself. It is useful, for
|
||||
example, to print out CPP directives.
|
||||
|
||||
@example|-{#lang scribble/text
|
||||
|
@ -758,7 +758,7 @@ example, to print out CPP directives.
|
|||
}
|
||||
}-|
|
||||
|
||||
If there are values after a @scheme[disable-prefix] value on the same
|
||||
If there are values after a @racket[disable-prefix] value on the same
|
||||
line, they will get indented to the goal column (unless the output is
|
||||
already beyond it).
|
||||
|
||||
|
@ -807,7 +807,7 @@ already beyond it).
|
|||
}-|
|
||||
|
||||
There are cases where each line should be prefixed with some string
|
||||
other than a plain indentation. The @scheme[add-prefix] function
|
||||
other than a plain indentation. The @racket[add-prefix] function
|
||||
causes its contents to be printed using some given string prefix for
|
||||
every line. The prefix gets accumulated to an existing indentation,
|
||||
and indentation in the contents gets added to the prefix.
|
||||
|
@ -840,11 +840,11 @@ and indentation in the contents gets added to the prefix.
|
|||
}
|
||||
}-|
|
||||
|
||||
When combining @scheme[add-prefix] and @scheme[disable-prefix] there
|
||||
is an additional value that can be useful: @scheme[flush]. This is a
|
||||
value that causes @scheme[output] to print the current indentation and
|
||||
When combining @racket[add-prefix] and @racket[disable-prefix] there
|
||||
is an additional value that can be useful: @racket[flush]. This is a
|
||||
value that causes @racket[output] to print the current indentation and
|
||||
prefix. This makes it possible to get the ``ignored as a prefix''
|
||||
property of @scheme[disable-prefix] but only for a nested prefix.
|
||||
property of @racket[disable-prefix] but only for a nested prefix.
|
||||
|
||||
@example|-{#lang scribble/text
|
||||
@(define (comment . text)
|
||||
|
@ -923,7 +923,7 @@ property of @scheme[disable-prefix] but only for a nested prefix.
|
|||
|
||||
Using additional files that contain code for your preprocessing is
|
||||
trivial: the preprocessor source is still source code in a module, so
|
||||
you can @scheme[require] additional files with utility functions.
|
||||
you can @racket[require] additional files with utility functions.
|
||||
|
||||
@example|-{#lang scribble/text
|
||||
@(require "itemize.ss")
|
||||
|
@ -933,7 +933,7 @@ you can @scheme[require] additional files with utility functions.
|
|||
@list{Hack some
|
||||
more}]
|
||||
---***--- itemize.ss
|
||||
#lang scheme
|
||||
#lang racket
|
||||
(provide itemize)
|
||||
(define (itemize . items)
|
||||
(add-between (map (lambda (item)
|
||||
|
@ -948,7 +948,7 @@ you can @scheme[require] additional files with utility functions.
|
|||
more
|
||||
}-|
|
||||
|
||||
Note that the @seclink["at-exp-lang"]{@scheme[at-exp] language} can
|
||||
Note that the @seclink["at-exp-lang"]{@racket[at-exp] language} can
|
||||
often be useful here, since such files need to deal with texts. Using
|
||||
it, it is easy to include a lot of textual content.
|
||||
|
||||
|
@ -961,8 +961,8 @@ it, it is easy to include a lot of textual content.
|
|||
more}]
|
||||
@summary
|
||||
---***--- stuff.ss
|
||||
#lang at-exp scheme/base
|
||||
(require scheme/list)
|
||||
#lang at-exp racket/base
|
||||
(require racket/list)
|
||||
(provide (all-defined-out))
|
||||
(define (itemize . items)
|
||||
(add-between (map (lambda (item)
|
||||
|
@ -983,17 +983,17 @@ it, it is easy to include a lot of textual content.
|
|||
}-|
|
||||
|
||||
Of course, the extreme side of this will be to put all of your content
|
||||
in a plain Scheme module, using @"@"-forms for convenience. However,
|
||||
in a plain Racket module, using @"@"-forms for convenience. However,
|
||||
there is no need to use the preprocessor language in this case;
|
||||
instead, you can @scheme[(require scribble/text)], which will get all
|
||||
of the bindings that are available in the @scheme[scribble/text]
|
||||
language. Using @scheme[output], switching from a preprocessed files
|
||||
to a Scheme file is very easy ---- choosing one or the other depends
|
||||
instead, you can @racket[(require scribble/text)], which will get all
|
||||
of the bindings that are available in the @racket[scribble/text]
|
||||
language. Using @racket[output], switching from a preprocessed files
|
||||
to a Racket file is very easy ---- choosing one or the other depends
|
||||
on whether it is more convenient to write a text file with occasional
|
||||
Scheme expressions or the other way.
|
||||
Racket expressions or the other way.
|
||||
|
||||
@example|-{#lang at-exp scheme/base
|
||||
(require scribble/text scheme/list)
|
||||
@example|-{#lang at-exp racket/base
|
||||
(require scribble/text racket/list)
|
||||
(define (itemize . items)
|
||||
(add-between (map (lambda (item)
|
||||
@list{* @item})
|
||||
|
@ -1026,12 +1026,12 @@ mostly-text file from a preprocessor file. It might be because you
|
|||
prefer to split the source text to several files, or because you need
|
||||
to preprocess a file without even a @litchar{#lang} header (for
|
||||
example, an HTML template file that is the result of an external
|
||||
editor). For these cases, the @scheme[scribble/text] language
|
||||
provides an @scheme[include] form that includes a file in the
|
||||
editor). For these cases, the @racket[scribble/text] language
|
||||
provides an @racket[include] form that includes a file in the
|
||||
preprocessor syntax (where the default parsing mode is text).
|
||||
|
||||
@example|-{#lang scribble/text
|
||||
@(require scheme/list)
|
||||
@(require racket/list)
|
||||
@(define (itemize . items)
|
||||
(list
|
||||
"<ul>"
|
||||
|
@ -1074,12 +1074,12 @@ preprocessor syntax (where the default parsing mode is text).
|
|||
</html>
|
||||
}-|
|
||||
|
||||
(Using @scheme[require] with a text file in the @scheme[scribble/text]
|
||||
(Using @racket[require] with a text file in the @racket[scribble/text]
|
||||
language will not work as intended: using the preprocessor language
|
||||
means that the text is displayed when the module is invoked, so the
|
||||
required file's contents will be printed before any of the requiring
|
||||
module's text does. If you find yourself in such a situation, it is
|
||||
better to switch to a Scheme-with-@"@"-expressions file as shown
|
||||
better to switch to a Racket-with-@"@"-expressions file as shown
|
||||
above.)
|
||||
|
||||
@;FIXME: add more text on `restore-prefix', `set-prefix', `with-writer'
|
||||
|
@ -1087,20 +1087,20 @@ above.)
|
|||
@;FIXME: add this to the reference section
|
||||
@;@defform[(include filename)]{
|
||||
@;
|
||||
@;Preprocess the @scheme[filename] using the same syntax as
|
||||
@;@scheme[scribble/text]. This is similar to using @scheme[load] in a
|
||||
@;Preprocess the @racket[filename] using the same syntax as
|
||||
@;@racket[scribble/text]. This is similar to using @racket[load] in a
|
||||
@;namespace that can access names bound in the current file so included
|
||||
@;code can refer to bindings from the including module. Note, however,
|
||||
@;that the including module cannot refer to names that are bound the
|
||||
@;included file because it is still a plain scheme module---for such
|
||||
@;uses you should still use @scheme[require] as usual.}
|
||||
@;included file because it is still a plain racket module---for such
|
||||
@;uses you should still use @racket[require] as usual.}
|
||||
|
||||
|
||||
@; Two random tests
|
||||
@example[#:hidden]|-{
|
||||
#lang scribble/text
|
||||
|
||||
@define[name]{PLT Scheme}
|
||||
@define[name]{Racket}
|
||||
|
||||
Suggested price list for "@name"
|
||||
|
||||
|
@ -1124,11 +1124,11 @@ above.)
|
|||
Total: @items-num items
|
||||
Average price: $@|average|.99
|
||||
---***---
|
||||
Suggested price list for "PLT Scheme"
|
||||
Suggested price list for "Racket"
|
||||
|
||||
0. PLT Scheme Home edition: $99.99
|
||||
1. PLT Scheme Professional edition: $149.99
|
||||
2. PLT Scheme Enterprize edition: $349.99
|
||||
0. Racket Home edition: $99.99
|
||||
1. Racket Professional edition: $149.99
|
||||
2. Racket Enterprize edition: $349.99
|
||||
|
||||
Total: 3 items
|
||||
Average price: $199.99
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#lang scheme/base
|
||||
#lang racket/base
|
||||
|
||||
(require scribble/core
|
||||
scribble/html-properties
|
||||
scribble/manual
|
||||
(prefix-in scheme: scribble/scheme)
|
||||
(prefix-in racket: scribble/racket)
|
||||
(prefix-in scribble: scribble/reader))
|
||||
|
||||
(define-syntax bounce-for-label
|
||||
|
@ -15,12 +15,12 @@
|
|||
(provide (for-label (all-from-out mod))))]
|
||||
[(_ mod ...) (begin (bounce-for-label mod) ...)]))
|
||||
|
||||
(bounce-for-label (all-except scheme (link) ())
|
||||
(bounce-for-label (all-except racket (link) ())
|
||||
scribble/core
|
||||
scribble/base-render
|
||||
scribble/decode
|
||||
scribble/manual
|
||||
scribble/scheme
|
||||
scribble/racket
|
||||
scribble/html-properties
|
||||
scribble/latex-properties
|
||||
scribble/eval
|
||||
|
@ -94,7 +94,7 @@
|
|||
(map (lambda (x)
|
||||
(let ([@expr (if x (litchar/lines (car x)) "")]
|
||||
[sexpr (if x
|
||||
(scheme:to-paragraph
|
||||
(racket:to-paragraph
|
||||
((norm-spacing 0) (cadr x)))
|
||||
"")]
|
||||
[reads-as (if x reads-as "")])
|
||||
|
@ -103,7 +103,7 @@
|
|||
|
||||
;; stuff for the preprocessor examples
|
||||
|
||||
(require scheme/list (for-syntax scheme/base scheme/list))
|
||||
(require racket/list (for-syntax racket/base racket/list))
|
||||
|
||||
(define max-textsample-width 45)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user