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
38 changes: 18 additions & 20 deletions scribble-lib/scribble/markdown-render.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -104,26 +104,24 @@
(displayln "```")]

[else
(define strs (map (lambda (flows)
(map (lambda (d)
(cond
[(eq? d 'cont) d]
[else
(define o (open-output-string))
(parameterize ([current-indent 0]
[current-output-port o])
(render-block d part ht #f))
(regexp-split
#rx"\n"
(regexp-replace #rx"\n$" (get-output-string o) ""))]))
flows))
flowss))
(define widths (map (lambda (col)
(for/fold ([d 0]) ([i (in-list col)])
(if (eq? i 'cont)
0
(apply max d (map string-length i)))))
(apply map list strs)))
(define strs (for/list ([flows (in-list flowss)])
(map
(lambda (d)
(cond
[(eq? d 'cont) d]
[else
(define o (open-output-string))
(parameterize ([current-indent 0]
[current-output-port o])
(render-block d part ht #f))
(regexp-split #rx"\n"
(regexp-replace #rx"\n$" (get-output-string o) ""))]))
flows)))
(define widths (for/list ([col (in-list (apply map list strs))])
(for/fold ([d 0]) ([i (in-list col)])
(if (eq? i 'cont)
0
(apply max d (map string-length i))))))
(define (x-length col)
(if (eq? col 'cont) 0 (length col)))
(for/fold ([indent? #f]) ([row (in-list strs)])
Expand Down
20 changes: 10 additions & 10 deletions scribble-lib/scribble/render.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,24 @@
(unless quiet?
(send renderer report-output!))
(define fns
(map (lambda (fn)
(let-values ([(base name dir?) (split-path fn)])
(let ([fn (path-replace-suffix name (send renderer get-suffix))])
(if dest-dir
(build-path dest-dir fn)
fn))))
names))
(for/list ([fn (in-list names)])
(define-values (base name dir?) (split-path fn))
(let ([fn (path-replace-suffix name (send renderer get-suffix))])
(if dest-dir
(build-path dest-dir fn)
fn))))
(define fp (send renderer traverse docs fns))
(define info (send renderer collect docs fns fp))
(for ([file (in-list info-input-files)])
(let ([s (with-input-from-file file read)]) (send renderer deserialize-info s info)))
(define s (with-input-from-file file read))
(send renderer deserialize-info s info))
(for ([xr (in-list xrefs)])
(xref-transfer-info renderer info xr))
(let ([r-info (send renderer resolve docs fns info)])
(send renderer render docs fns r-info)
(when info-output-file
(let ([s (send renderer serialize-info r-info)])
(with-output-to-file info-output-file #:exists 'truncate/replace (lambda () (write s)))))
(define s (send renderer serialize-info r-info))
(with-output-to-file info-output-file #:exists 'truncate/replace (lambda () (write s))))
(when warn-undefined?
(let ([undef (send renderer get-undefined r-info)])
(unless (null? undef)
Expand Down
25 changes: 12 additions & 13 deletions scribble-lib/scribble/search.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,18 @@
(cond
[a
(loop queue
(append (map (lambda (m)
(if (pair? m)
(list (module-path-index-rejoin (car m) mod)
(list-ref m 2)
defn-phase
(list-ref m 1)
(list-ref m 3))
(list (module-path-index-rejoin m mod)
id
defn-phase
import-phase
export-phase)))
(reverse (cadr a)))
(append (for/list ([m (in-list (reverse (cadr a)))])
(if (pair? m)
(list (module-path-index-rejoin (car m) mod)
(list-ref m 2)
defn-phase
(list-ref m 1)
(list-ref m 3))
(list (module-path-index-rejoin m mod)
id
defn-phase
import-phase
export-phase)))
rqueue)
need-result?)]
;; A dead end may not be our fault: the files could
Expand Down
146 changes: 77 additions & 69 deletions scribble-lib/scribble/srcdoc.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,13 @@
(syntax-shift-phase-level s #f)))
(with-syntax ([((req ...) ...)
(for/list ([rs (in-list (reverse requires))])
(map (lambda (r)
(syntax-case r ()
[(op arg ...)
(with-syntax ([(arg ...) (map shift-and-introduce
(syntax->list #'(arg ...)))])
#'(op arg ...))]
[else (shift-and-introduce r)]))
(syntax->list rs)))]
(for/list ([r (in-list (syntax->list rs))])
(syntax-case r ()
[(op arg ...)
(with-syntax ([(arg ...) (map shift-and-introduce
(syntax->list #'(arg ...)))])
#'(op arg ...))]
[else (shift-and-introduce r)])))]
[(expr ...)
(map shift-and-introduce (reverse doc-exprs))]
[doc-body
Expand Down Expand Up @@ -128,11 +127,12 @@
(let ([t (syntax-local-value #'id (lambda () #f))])
(unless (provide/doc-transformer? t)
(raise-syntax-error #f "not bound as a provide/doc transformer" stx #'id))
(let* ([i (make-syntax-introducer)]
[i2 (lambda (x) (syntax-local-introduce (i x)))])
(let-values ([(p/c d req/d id) ((provide/doc-transformer-proc t)
(i (syntax-local-introduce form)))])
(list (i2 p/c) (i req/d) (i d) (i id)))))]
(define i (make-syntax-introducer))
(define (i2 x)
(syntax-local-introduce (i x)))
(let-values ([(p/c d req/d id) ((provide/doc-transformer-proc t)
(i (syntax-local-introduce form)))])
(list (i2 p/c) (i req/d) (i d) (i id))))]
[_ (raise-syntax-error #f "not a provide/doc sub-form" stx form)]))])
(with-syntax ([(p/c ...)
(map (lambda (form f)
Expand Down Expand Up @@ -345,44 +345,52 @@

(let ([build-mandatories/optionals
(λ (names contracts extras)
(let ([names-length (length names)]
[contracts-length (length contracts)])
(let loop ([contracts contracts]
[names names]
[extras extras])
(cond
[(and (null? names) (null? contracts)) '()]
[(or (null? names) (null? contracts))
(raise-syntax-error #f
(format "mismatched ~a argument list count and domain contract count (~a)"
(if extras "optional" "mandatory")
(if (null? names)
"ran out of names"
"ran out of contracts"))
stx)]
[else
(let ([fst-name (car names)]
[fst-ctc (car contracts)])
(if (keyword? (syntax-e fst-ctc))
(begin
(unless (pair? (cdr contracts))
(raise-syntax-error #f
"keyword not followed by a contract"
stx))
(cons (if extras
(list fst-ctc fst-name (cadr contracts) (car extras))
(list fst-ctc fst-name (cadr contracts)))
(loop (cddr contracts)
(cdr names)
(if extras
(cdr extras)
extras))))
(cons (if extras
(list fst-name fst-ctc (car extras))
(list fst-name fst-ctc))
(loop (cdr contracts) (cdr names) (if extras
(cdr extras)
extras)))))]))))])
(length names)
(length contracts)
(let loop ([contracts contracts]
[names names]
[extras extras])
(cond
[(and (null? names) (null? contracts)) '()]
[(or (null? names) (null? contracts))
(raise-syntax-error
#f
(format
"mismatched ~a argument list count and domain contract count (~a)"
(if extras "optional" "mandatory")
(if (null? names)
"ran out of names"
"ran out of contracts"))
stx)]
[else
(let ([fst-name (car names)]
[fst-ctc (car contracts)])
(if (keyword? (syntax-e fst-ctc))
(begin
(unless (pair? (cdr contracts))
(raise-syntax-error
#f
"keyword not followed by a contract"
stx))
(cons (if extras
(list fst-ctc
fst-name
(cadr contracts)
(car extras))
(list fst-ctc fst-name (cadr contracts)))
(loop (cddr contracts)
(cdr names)
(if extras
(cdr extras)
extras))))
(cons (if extras
(list fst-name fst-ctc (car extras))
(list fst-name fst-ctc))
(loop (cdr contracts)
(cdr names)
(if extras
(cdr extras)
extras)))))])))])

#`([(id #,@(build-mandatories/optionals (syntax->list #'(mandatory-names ...))
(syntax->list #'(mandatory ...))
Expand All @@ -404,19 +412,22 @@
[((x y) ...)
(andmap identifier? (syntax->list #'(x ... y ...)))]
[((x y) ...)
(for-each
(λ (var)
(unless (identifier? var)
(raise-syntax-error #f "expected an identifier in the optional names" stx var)))
(syntax->list #'(x ... y ...)))]
(for ([var (in-list (syntax->list #'(x ... y ...)))])
(unless (identifier? var)
(raise-syntax-error
#f
"expected an identifier in the optional names"
stx
var)))]
[(a ...)
(for-each
(λ (a)
(syntax-case stx ()
[(x y) (void)]
[other
(raise-syntax-error #f "expected an sequence of two idenfiers" stx #'other)]))
(syntax->list #'(a ...)))]))]
(for ([a (in-list (syntax->list #'(a ...)))])
(syntax-case stx ()
[(x y) (void)]
[other
(raise-syntax-error #f
"expected an sequence of two idenfiers"
stx
#'other)]))]))]
[x
(raise-syntax-error
#f
Expand Down Expand Up @@ -492,12 +503,9 @@
"expected an identifier or sequence of two identifiers"
stx
#'struct-name)])
(for ([f (in-list (syntax->list #'(field-name ...)))])
(unless (identifier? f)
(raise-syntax-error #f
"expected an identifier"
stx
f)))
(for ([f (in-list (syntax->list #'(field-name ...)))]
#:unless (identifier? f))
(raise-syntax-error #f "expected an identifier" stx f))
(define omit-constructor? #f)
(define-values (ds-args desc)
(let loop ([ds-args '()]
Expand Down
Loading