Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions scribble-lib/scribble/eval.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,11 @@
(set-mcdr! p (loop (mcdr v)))
p)]
[(vector? v)
(let ([v2 (make-vector (vector-length v))])
(hash-set! ht v v2)
(for ([i (in-range (vector-length v2))])
(vector-set! v2 i (loop (vector-ref v i))))
v2)]
(define v2 (make-vector (vector-length v)))
(hash-set! ht v v2)
(for ([i (in-range (vector-length v2))])
(vector-set! v2 i (loop (vector-ref v i))))
v2]
[(box? v)
(define v2 (box #f))
(hash-set! ht v v2)
Expand Down Expand Up @@ -543,9 +543,8 @@
(define (wait-loop cust)
(define thd (find-thread cust))
(when thd
(cond
[(eq? give-up-evt (sync thd give-up-evt)) (void)]
[else (wait-loop cust)])))
(unless (eq? give-up-evt (sync thd give-up-evt))
(wait-loop cust))))
(wait-loop sub-cust))

(define (make-eval/replay logfile)
Expand Down Expand Up @@ -583,9 +582,9 @@
(set! evaluations (cdr evaluations))
(display output init-out-p #| (current-output-port) |#)
(display error-output init-err-p #| (current-error-port) |#)
(cond
[(exn? result) (raise result)]
[(list? result) (apply values result)])))))))
(when (exn? result)
(raise result))
(apply values result)))))))
ev)

(define (close-eval e)
Expand Down
125 changes: 60 additions & 65 deletions scribble-lib/scribble/racket.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -798,9 +798,8 @@
(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 first-expr? #f) l (if (and expr? (zero? quote-depth))
srcless-step
#f))]))
((loop init-line! quote-depth first-expr? #f) l (and (and expr? (zero? quote-depth))
srcless-step))]))
(out (case sh
[(#\[) "]"]
[(#\{) "}"]
Expand Down Expand Up @@ -890,11 +889,9 @@
;; constructed:
[(and expr? (zero? quote-depth))
(define l (apply append
(map (lambda (p)
(let ([p (syntax-e p)])
(list (forced-pair-car p)
(forced-pair-cdr p))))
(reverse l2))))
(for/list ([p (in-list (reverse l2))])
(let ([p (syntax-e p)])
(list (forced-pair-car p) (forced-pair-cdr p))))))
(datum->syntax
#f
(cons (datum->syntax #f
Expand Down Expand Up @@ -947,10 +944,9 @@
(hash-set! next-col-map init-col dest-col)
((loop (lambda () (set! src-col init-col) (set! dest-col 0)) 0 expr? #f) c #f)
(if (list? suffix)
(map (lambda (sfx)
(finish-line!)
(out sfx #f))
suffix)
(for/list ([sfx (in-list suffix)])
(finish-line!)
(out sfx #f))
(out suffix #f))
(unless (null? content)
(finish-line!))
Expand Down Expand Up @@ -1161,10 +1157,12 @@
(do-syntax-ize v col line (box #hasheq()) #f (and expr? 0) #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)))
(cond
[graph?
(define n (hash-ref (unbox ht) '#%graph-count 0))
(set-box! ht (hash-set (unbox ht) '#%graph-count (add1 n)))
n]
[else #f]))

(define-struct forced-pair (car cdr))

Expand All @@ -1187,15 +1185,13 @@
[(and (struct? v)
(prefab-struct-key v))
(andmap quotable? (vector->list (struct->vector v)))]
[(struct? v) (if (custom-write? v)
(case (or (and (custom-print-quotable? v)
(custom-print-quotable-accessor v))
'self)
[(self always) #t]
[(never) #f]
[(maybe)
(andmap quotable? (vector->list (struct->vector v)))])
#f)]
[(struct? v) (and (custom-write? v)
(case (or (and (custom-print-quotable? v)
(custom-print-quotable-accessor v))
'self)
[(self always) #t]
[(never) #f]
[(maybe) (andmap quotable? (vector->list (struct->vector v)))]))]
[(struct-proxy? v) #f]
[(mpair? v) #f]
[else #t])])))
Expand Down Expand Up @@ -1303,41 +1299,43 @@
[no-cons? 1] ; '('
[else 6]) ; `(list '
1))
(define r (let ([l (let loop ([col (+ col delta vec-sz graph-sz)]
[v (cond
[(vector? v)
(vector->short-list v values)]
[(struct? v)
(cons (let ([pf (prefab-struct-key v)])
(if pf
(prefab-struct-key v)
(object-name v)))
(cdr (vector->list (struct->vector v qq-ellipses))))]
[else v])])
(cond
[(null? v) null]
[else
(define i (do-syntax-ize (car v) col line ht #f qq #f))
(cons i (loop (+ col 1 (syntax-span i)) (cdr v)))]))])
(datum->syntax #f
(cond
[(vector? v) (short-list->vector v l)]
[(struct? v)
(define pf (prefab-struct-key v))
(if pf
(apply make-prefab-struct (prefab-struct-key v) (cdr l))
(make-struct-proxy (car l) (cdr l)))]
[else l])
(vector #f line
(+ graph-sz col)
(+ 1 graph-sz col)
(+ 1
vec-sz
delta
(if (zero? (length l))
0
(sub1 (length l)))
(apply + (map syntax-span l)))))))
(define l
(let loop ([col (+ col delta vec-sz graph-sz)]
[v (cond
[(vector? v) (vector->short-list v values)]
[(struct? v)
(cons (let ([pf (prefab-struct-key v)])
(if pf
(prefab-struct-key v)
(object-name v)))
(cdr (vector->list (struct->vector v qq-ellipses))))]
[else v])])
(cond
[(null? v) null]
[else
(define i (do-syntax-ize (car v) col line ht #f qq #f))
(cons i (loop (+ col 1 (syntax-span i)) (cdr v)))])))
(define r
(datum->syntax #f
(cond
[(vector? v) (short-list->vector v l)]
[(struct? v)
(define pf (prefab-struct-key v))
(if pf
(apply make-prefab-struct (prefab-struct-key v) (cdr l))
(make-struct-proxy (car l) (cdr l)))]
[else l])
(vector #f
line
(+ graph-sz col)
(+ 1 graph-sz col)
(+ 1
vec-sz
delta
(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
Expand Down Expand Up @@ -1446,11 +1444,8 @@
[(hash-eq? v) make-immutable-hasheq]
[(hash-eqv? v) make-immutable-hasheqv]
[else make-immutable-hash])
(map (lambda (p)
(let ([p (syntax-e p)])
(cons (syntax->datum (car p))
(cdr p))))
(syntax->list pairs)))
(for/list ([p (in-list (syntax->list pairs))])
(let ([p (syntax-e p)]) (cons (syntax->datum (car p)) (cdr p)))))
(vector (syntax-source pairs)
(syntax-line pairs)
(max 0 (- (syntax-column pairs) undelta))
Expand Down
62 changes: 30 additions & 32 deletions scribble-lib/scribble/run.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

(module test racket/base)

(define multi-html:render-mixin
(lambda (%) (html:render-multi-mixin (html:render-mixin %))))
(define (multi-html:render-mixin %)
(html:render-multi-mixin (html:render-mixin %)))

(define current-render-mixin (make-parameter html:render-mixin))
(define current-html (make-parameter #t))
Expand All @@ -38,10 +38,9 @@
(define current-image-prefs (make-parameter null)) ; reverse order

(define (read-one str)
(let ([i (open-input-string str)])
(with-handlers ([exn:fail:read? (lambda (x) #f)])
(let ([v (read i)])
(and (eof-object? (read i)) v)))))
(define i (open-input-string str))
(with-handlers ([exn:fail:read? (lambda (x) #f)])
(let ([v (read i)]) (and (eof-object? (read i)) v))))

(define (run)
(define doc-binding 'doc)
Expand Down Expand Up @@ -178,32 +177,29 @@
(make-compilation-manager-load/use-compiled-handler))])
(parameterize ([current-command-line-arguments
(list->vector (reverse (doc-command-line-arguments)))])
(build-docs (map (lambda (file)
(define (go)
(let ([mp (if (current-lib-mode)
`(lib ,file)
`(file ,file))])
;; Try `doc' submodule, first:
(if (module-declared? `(submod ,mp ,doc-binding) #t)
(dynamic-require `(submod ,mp ,doc-binding)
doc-binding)
(dynamic-require mp doc-binding))))
(if maker
(parameterize ([current-load/use-compiled maker])
(go))
(go)))
files)
(build-docs (for/list ([file (in-list files)])
(define (go)
(let ([mp (if (current-lib-mode)
`(lib ,file)
`(file ,file))])
;; Try `doc' submodule, first:
(if (module-declared? `(submod ,mp ,doc-binding) #t)
(dynamic-require `(submod ,mp ,doc-binding) doc-binding)
(dynamic-require mp doc-binding))))
(if maker
(parameterize ([current-load/use-compiled maker])
(go))
(go)))
files)))))

(define (build-docs docs files)
(when (and (current-dest-name)
((length files) . > . 1))
(raise-user-error 'scribble "cannot supply a destination name with multiple inputs"))
(render docs
(map (lambda (fn)
(let-values ([(base name dir?) (split-path fn)])
(or (current-dest-name) name)))
files)
(for/list ([fn (in-list files)])
(define-values (base name dir?) (split-path fn))
(or (current-dest-name) name))
#:dest-dir (current-dest-directory)
#:render-mixin (current-render-mixin)
#:image-preferences (reverse (current-image-prefs))
Expand All @@ -219,13 +215,15 @@
#:quiet? (current-quiet)
#:info-in-files (reverse (current-info-input-files))
#:xrefs (for/list ([mod+id (in-list (reverse (current-xref-input-modules)))])
(let* ([get-xref (dynamic-require (car mod+id) (cdr mod+id))]
[xr (get-xref)])
(unless (xref? xr)
(raise-user-error
'scribble "result from `~s' of `~s' is not an xref: ~e"
(cdr mod+id) (car mod+id) xr))
xr))
(define get-xref (dynamic-require (car mod+id) (cdr mod+id)))
(define xr (get-xref))
(unless (xref? xr)
(raise-user-error 'scribble
"result from `~s' of `~s' is not an xref: ~e"
(cdr mod+id)
(car mod+id)
xr))
xr)
#:info-out-file (current-info-output-file)))

(run)
Loading
Loading