more doc fixes

svn: r7881
This commit is contained in:
Matthew Flatt 2007-12-01 02:47:17 +00:00
parent 58684c1b0b
commit c9545a836b
6 changed files with 64 additions and 40 deletions

View File

@ -45,14 +45,18 @@
(define-struct (sized-element element) (length))
(define-struct spaces (pre cnt post))
(define-struct (spaces element) (cnt))
(define (literalize-spaces i)
(let ([m (regexp-match-positions #rx" +" i)])
(if m
(make-spaces (literalize-spaces (substring i 0 (caar m)))
(- (cdar m) (caar m))
(literalize-spaces (substring i (cdar m))))
(let ([cnt (- (cdar m) (caar m))])
(make-spaces #f
(list
(literalize-spaces (substring i 0 (caar m)))
(make-element 'hspace (list (make-string cnt #\space)))
(literalize-spaces (substring i (cdar m))))
cnt))
i)))
(define (typeset-atom c out color? quote-depth)
@ -150,17 +154,17 @@
[(delayed-element? v)
(element-width v)]
[(spaces? v)
(+ (sz-loop (spaces-pre v))
(+ (sz-loop (car (element-content v)))
(spaces-cnt v)
(sz-loop (spaces-post v)))]
(sz-loop (caddr (element-content v))))]
[else 1])))]
[(v cls len)
(unless (equal? v "")
(cond
[(spaces? v)
(out (spaces-pre v) cls 0)
(out (make-element 'hspace (list (make-string (spaces-cnt v) #\space))) #f 0)
(out (spaces-post v) cls len)]
(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

View File

@ -66,7 +66,7 @@
(syntax-case stx ()
[(_ (id ([field ct] ...)) ...)
#`(begin
(define-serializable-struct id (field ...) #:mutable) ...
(define-serializable-struct id (field ...)) ...
(provide/contract
#,@(let ([ids (syntax->list #'(id ...))]
[fields+cts (syntax->list #'(([field ct] ...) ...))])

View File

@ -131,12 +131,11 @@ structure type are kept private to a module, then no other module can
rely on the representation of the type's instances.
To make a structure type @defterm{transparent}, use the
@scheme[#:inspector] keyword with the value @scheme[#f] after the
field-name sequence:
@scheme[#:transparent] keyword after the field-name sequence:
@def+int[
(define-struct posn (x y)
#:inspector #f)
#:transparent)
(make-posn 1 2)
]
@ -144,8 +143,7 @@ An instance of a transparent structure type prints like a vector, and
it shows the content of the structure's fields. A transparent
structure type also allows reflective operations, such as
@scheme[struct?] and @scheme[struct-info], to be used on its instances
(see @secref["reflection"]). Different values for @scheme[#:inspector]
support more controlled access to reflective operations.
(see @secref["reflection"]).
Structure types are opaque by default, because opaque structure
instances provide more encapsulation guarantees. That is, a library
@ -192,10 +190,13 @@ A @scheme[_struct-option] always starts with a keyword:
(set-person-age! friend 6)
(set-person-name! friend "Mary")]}
@specspecsubform[(code:line #:inspector inspector-expr)]{
@specspecsubform[(code:line #:transparent)]{
Controls reflective access to structure instances, as discussed
in the previous section (@secref["trans-struct"]).
}
in the previous section (@secref["trans-struct"]).}
@specspecsubform[(code:line #:inspector inspector-expr)]{
Generalizes @scheme[#:transparent] to support more controlled access
to reflective operations.}
@specspecsubform[(code:line #:auto-value auto-expr)]{
@ -206,7 +207,7 @@ A @scheme[_struct-option] always starts with a keyword:
@defexamples[
(define-struct posn (x y [z #:auto])
#:inspector #f
#:transparent
#:auto-value 0)
(make-posn 1 2)
]}
@ -224,7 +225,7 @@ A @scheme[_struct-option] always starts with a keyword:
@defexamples[
(define-struct thing (name)
#:inspector #f
#:transparent
#:guard (lambda (name type-name)
(cond
[(string? name) name]
@ -242,7 +243,7 @@ A @scheme[_struct-option] always starts with a keyword:
@defexamples[
(define-struct (person thing) (age)
#:inspector #f
#:transparent
#:guard (lambda (name age type-name)
(if (negative? age)
(error "bad age" age)
@ -282,7 +283,7 @@ A @scheme[_struct-option] always starts with a keyword:
(define (make-raven-constructor super-type)
(define-struct raven ()
#:super super-type
#:inspector #f
#:transparent
#:property prop:procedure (lambda (self)
'nevermore))
make-raven)
@ -307,7 +308,7 @@ times.
@defexamples[
(define (add-bigger-fish lst)
(define-struct fish (size) #:inspector #f) (code:comment #,(t "new every time"))
(define-struct fish (size) #:transparent) (code:comment #,(t "new every time"))
(cond
[(null? lst) (list (make-fish 1))]
[else (cons (make-fish (* 2 (fish-size (car lst))))
@ -317,7 +318,7 @@ times.
(add-bigger-fish (add-bigger-fish null))
]
@defs+int[
[(define-struct fish (size) #:inspector #f)
[(define-struct fish (size) #:transparent)
(define (add-bigger-fish lst)
(cond
[(null? lst) (list (make-fish 1))]

View File

@ -16,6 +16,8 @@ A @tech{module path} that is a quoted identifier refers to a non-file
@scheme[module] declaration using the identifier. This form of module
reference makes the most sense in a @tech{REPL}.
@interaction-eval[(compile-enforce-module-constants #f)]
@examples[
(module m scheme
(provide color)
@ -26,6 +28,8 @@ reference makes the most sense in a @tech{REPL}.
(require 'n)
]}
@interaction-eval[(compile-enforce-module-constants #t)]
@; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@specsubform[id]{

View File

@ -114,6 +114,13 @@ banner text for an embedding program, such as MrEd). The banner string
ends with a newline.}
@defparam[current-command-line-arguments argv (vectorof (and/c string? immutable?))]{
A parameter that is initialized with command-line arguments when
Scheme starts (not including any command-line arguments that were
treated as flags for the system).}
@defproc[(vector-set-performance-stats! [results (and/c vector?
(not/c immutable?))]
[thd (or/c thread? false/c) #f])

View File

@ -204,20 +204,28 @@
(loop base)))))))
only-dirs)))
(define (ensure-doc-prefix! src-file v)
(define (ensure-doc-prefix v src-file)
(let ([p (format "~a"
(path->main-collects-relative src-file))])
(if (part-tag-prefix v)
(unless (equal? p
(part-tag-prefix v))
(error 'setup
"bad tag prefix: ~e for: ~a expected: ~e"
(part-tag-prefix v)
src-file
p))
(set-part-tag-prefix! v p))
(unless (member '(part "top") (part-tags v))
(set-part-tags! v (cons '(part "top") (part-tags v))))))
(when (part-tag-prefix v)
(unless (equal? p
(part-tag-prefix v))
(error 'setup
"bad tag prefix: ~e for: ~a expected: ~e"
(part-tag-prefix v)
src-file
p)))
(let ([tag-prefix p]
[tags (if (member '(part "top") (part-tags v))
(part-tags v)
(cons '(part "top") (part-tags v)))])
(make-part tag-prefix
tags
(part-title-content v)
(part-style v)
(part-to-collect v)
(part-flow v)
(part-parts v)))))
(define ((get-doc-info only-dirs latex-dest) doc)
(let ([info-out-file (build-path (or latex-dest (doc-dest-dir doc)) "out.sxref")]
@ -267,9 +275,9 @@
#f)))
;; Run the doc once:
(parameterize ([current-directory (doc-src-dir doc)])
(let ([v (dynamic-require-doc (doc-src-file doc))]
(let ([v (ensure-doc-prefix (dynamic-require-doc (doc-src-file doc))
(doc-src-file doc))]
[dest-dir (pick-dest latex-dest doc)])
(ensure-doc-prefix! (doc-src-file doc) v)
(let* ([ci (send renderer collect (list v) (list dest-dir))])
(let ([ri (send renderer resolve (list v) (list dest-dir) ci)]
[out-v (and info-out-time
@ -314,9 +322,9 @@
(doc-src-file doc))
(set-info-rendered?! info #t)
(parameterize ([current-directory (doc-src-dir doc)])
(let ([v (dynamic-require-doc (doc-src-file doc))]
(let ([v (ensure-doc-prefix (dynamic-require-doc (doc-src-file doc))
(doc-src-file doc))]
[dest-dir (pick-dest latex-dest doc)])
(ensure-doc-prefix! (doc-src-file doc) v)
(let* ([ci (send renderer collect (list v) (list dest-dir))])
(for-each (lambda (i)
(send renderer deserialize-info (info-sci i) ci))