diff --git a/scribble-lib/scribble/private/doc-begin.rkt b/scribble-lib/scribble/private/doc-begin.rkt index c41e555a0c..e7e51f2e77 100644 --- a/scribble-lib/scribble/private/doc-begin.rkt +++ b/scribble-lib/scribble/private/doc-begin.rkt @@ -66,22 +66,15 @@ #'(check-pre-part s (quote-syntax loc))))])) (define (check-pre-part v loc-stx) - (if (pre-part? v) - v - (error - (format - "~a: not valid in document body (need a pre-part for decode) in: ~e" - (cond - [(and (syntax-source loc-stx) - (syntax-line loc-stx)) - (format "~a:~a:~a" - (syntax-source loc-stx) - (syntax-line loc-stx) - (syntax-column loc-stx))] - [(and (syntax-source loc-stx) - (syntax-position loc-stx)) - (format "~a:::~a" - (syntax-source loc-stx) - (syntax-position loc-stx))] - [else 'document]) - v)))) + (unless (pre-part? v) + (error + (format + "~a: not valid in document body (need a pre-part for decode) in: ~e" + (cond + [(and (syntax-source loc-stx) (syntax-line loc-stx)) + (format "~a:~a:~a" (syntax-source loc-stx) (syntax-line loc-stx) (syntax-column loc-stx))] + [(and (syntax-source loc-stx) (syntax-position loc-stx)) + (format "~a:::~a" (syntax-source loc-stx) (syntax-position loc-stx))] + [else 'document]) + v))) + v) diff --git a/scribble-lib/scribble/private/indirect-renderer.rkt b/scribble-lib/scribble/private/indirect-renderer.rkt index 68371ecfd4..509067c097 100644 --- a/scribble-lib/scribble/private/indirect-renderer.rkt +++ b/scribble-lib/scribble/private/indirect-renderer.rkt @@ -19,19 +19,14 @@ (define/override (get-suffix) target-suffix) (define/override (render srcs dests ri) (define tmp-dir - (make-temporary-file - (format "scribble-~a-to-~a-~~a" - (dotless base-suffix) (dotless target-suffix)) - 'directory)) + (make-temporary-directory + (format "scribble-~a-to-~a-~~a" (dotless base-suffix) (dotless target-suffix)))) (define (cleanup) (when (directory-exists? tmp-dir) (delete-directory/files tmp-dir))) (with-handlers ([void (lambda (e) (cleanup) (raise e))]) (define tmp-dests - (map (lambda (dest) - (build-path tmp-dir - (path-replace-suffix (file-name-from-path dest) - base-suffix))) - dests)) + (for/list ([dest (in-list dests)]) + (build-path tmp-dir (path-replace-suffix (file-name-from-path dest) base-suffix)))) (set! tmp-dest-dir tmp-dir) ;; it would be better if it's ok to change current-directory for this (super render srcs tmp-dests ri) diff --git a/scribble-lib/scribble/private/manual-bib.rkt b/scribble-lib/scribble/private/manual-bib.rkt index d7694520cf..39ef0fca8e 100644 --- a/scribble-lib/scribble/private/manual-bib.rkt +++ b/scribble-lib/scribble/private/manual-bib.rkt @@ -11,18 +11,21 @@ (define-struct a-bib-entry (key val)) -(provide/contract - [cite ((string?) () #:rest (listof string?) . ->* . element?)] - [bib-entry ((#:key string? #:title (or/c #f pre-content?)) - (#:is-book? boolean? #:author (or/c #f pre-content?) - #:location (or/c #f pre-content?) - #:date (or/c #f pre-content?) - #:url (or/c #f pre-content?) - #:note (or/c #f pre-content?)) - . ->* . - a-bib-entry?)] - [rename a-bib-entry? bib-entry? predicate/c] - [bibliography (() (#:tag string?) #:rest (listof a-bib-entry?) . ->* . part?)]) +(provide (contract-out + [cite ((string?) () #:rest (listof string?) . ->* . element?)] + [bib-entry + ((#:key string? #:title (or/c #f pre-content?)) (#:is-book? boolean? + #:author (or/c #f pre-content?) + #:location (or/c #f pre-content?) + #:date (or/c #f pre-content?) + #:url (or/c #f pre-content?) + #:note (or/c #f pre-content?)) + . ->* . + a-bib-entry?)] + (rename a-bib-entry? + bib-entry? + predicate/c) + [bibliography (() (#:tag string?) #:rest (listof a-bib-entry?) . ->* . part?)])) (define (cite key . keys) (make-element @@ -65,7 +68,9 @@ `(" " ,@(decode-content (list location)) ,(if date "," ".")) null) (if date `(" " ,@(decode-content (list date)) ".") null) - (if url `(" " ,(link url (tt url))) null) + (if url (list " " + (link url + (tt url))) null) (if note (decode-content (list note)) null))))) (define-on-demand bib-style (make-style "RBibliography" scheme-properties)) @@ -81,12 +86,10 @@ (list (make-table bib-style - (map (lambda (c) - (define key (a-bib-entry-key c)) - (define val (a-bib-entry-val c)) - (list - (to-flow (make-target-element #f `("[" ,key "]") `(cite ,key))) + (for/list ([c (in-list citations)]) + (define key (a-bib-entry-key c)) + (define val (a-bib-entry-val c)) + (list (to-flow (make-target-element #f `("[" ,key "]") `(cite ,key))) flow-spacer - (to-flow val))) - citations)))) + (to-flow val)))))) null)) diff --git a/scribble-lib/scribble/private/manual-mod.rkt b/scribble-lib/scribble/private/manual-mod.rkt index 9f680e93b6..d808e32911 100644 --- a/scribble-lib/scribble/private/manual-mod.rkt +++ b/scribble-lib/scribble/private/manual-mod.rkt @@ -299,12 +299,9 @@ pkg-spec)))) libs-specs)) (append (if link-target? - (map (lambda (modpath) - (make-part-tag-decl - (intern-taglet - `(mod-path ,(datum-intern-literal - (element->string modpath)))))) - modpaths) + (for/list ([modpath (in-list modpaths)]) + (make-part-tag-decl (intern-taglet `(mod-path ,(datum-intern-literal + (element->string modpath)))))) null) (flow-paragraphs (decode-flow content))))))) @@ -334,12 +331,12 @@ #'(list pkg ...) #'#f)]) (let ([libs (syntax->list #'(lib ... plib ...))]) - (for ([l libs]) - (unless (or (syntax-case l (unquote) - [(unquote _) #t] - [_ #f]) - (module-path? (syntax->datum l))) - (raise-syntax-error #f "not a module path" stx l))) + (for ([l libs] + #:unless (or (syntax-case l (unquote) + [(unquote _) #t] + [_ #f]) + (module-path? (syntax->datum l)))) + (raise-syntax-error #f "not a module path" stx l)) (when (null? libs) (raise-syntax-error #f "need at least one module path" stx)) #'(*declare-exporting `(lib ...) `(plib ...) packages)))])) diff --git a/scribble-lib/scribble/private/manual-proc.rkt b/scribble-lib/scribble/private/manual-proc.rkt index 89c3d59e3f..76f51b2598 100644 --- a/scribble-lib/scribble/private/manual-proc.rkt +++ b/scribble-lib/scribble/private/manual-proc.rkt @@ -857,42 +857,38 @@ (make-just-context (car name) (car (syntax-e stx-id))) stx-id)]) - (if link? - (let () - (define (gen defn?) - ((if defn? annote-exporting-library values) - (to-element #:defn? defn? name-id))) - (define content (gen #t)) - (define ref-content (gen #f)) - (make-target-element* - (lambda (s c t) - (make-toc-target2-element s c t ref-content)) - (if (pair? name) - (car (syntax-e stx-id)) - stx-id) - content - (let ([name (if (pair? name) (car name) name)]) - (list* (list 'info name) - (list 'type 'struct: name) - (list 'predicate name '?) - (append - (if cname-id - (list (list 'constructor (syntax-e cname-id))) - null) - (map (lambda (f) - (list 'accessor name '- - (field-name f))) - fields) - (filter-map - (lambda (f) - (and (or (not immutable?) - (and (pair? (car f)) - (memq '#:mutable - (car f)))) - (list 'mutator 'set- name '- - (field-name f) '!))) - fields)))))) - (to-element #:defn? #t name-id)))]) + (cond + [link? + (define (gen defn?) + ((if defn? annote-exporting-library values) (to-element #:defn? defn? + name-id))) + (define content (gen #t)) + (define ref-content (gen #f)) + (make-target-element* + (lambda (s c t) (make-toc-target2-element s c t ref-content)) + (if (pair? name) + (car (syntax-e stx-id)) + stx-id) + content + (let ([name (if (pair? name) + (car name) + name)]) + (list* (list 'info name) + (list 'type 'struct: name) + (list 'predicate name '?) + (append + (if cname-id + (list (list 'constructor (syntax-e cname-id))) + null) + (map (lambda (f) (list 'accessor name '- (field-name f))) + fields) + (filter-map + (lambda (f) + (and (or (not immutable?) + (and (pair? (car f)) (memq '#:mutable (car f)))) + (list 'mutator 'set- name '- (field-name f) '!))) + fields)))))] + [else (to-element #:defn? #t name-id)]))]) (if (pair? name) (make-element #f @@ -913,17 +909,17 @@ (map sym-length (append (if (pair? name) name (list name)) (map field-name fields))) - (map (lambda (f) - (match (car f) - [(? symbol?) 0] - [(list name) 2] ;; the extra [ ] - [(list* name field-opts) - ;; '[' ']' - (apply + 2 - (for/list ([field-opt (in-list field-opts)]) - ;; and " #:" - (+ 3 (string-length (keyword->string field-opt)))))])) - fields)))]) + (for/list ([f (in-list fields)]) + (match (car f) + [(? symbol?) 0] + [(list name) 2] ;; the extra [ ] + [(list* name field-opts) + ;; '[' ']' + (apply + + 2 + (for/list ([field-opt (in-list field-opts)]) + ;; and " #:" + (+ 3 (string-length (keyword->string field-opt)))))]))))]) (cond [(and (short-width . < . max-proto-width) (not keyword-modifiers?)) @@ -931,9 +927,7 @@ (make-omitable-paragraph (list (to-element - `(,(racket struct) - ,the-name - ,(map field-view fields)))))] + (list (racket struct) the-name (map field-view fields)))))] [else ;; Multi-line view (leaving out last paren if keywords follow): (define one-right-column? diff --git a/scribble-lib/scribble/private/manual-style.rkt b/scribble-lib/scribble/private/manual-style.rkt index a4b855628e..62824b791d 100644 --- a/scribble-lib/scribble/private/manual-style.rkt +++ b/scribble-lib/scribble/private/manual-style.rkt @@ -22,10 +22,11 @@ itemize aux-elem code-inset) -(provide/contract [filebox (((or/c core:element? string?)) () #:rest (listof pre-flow?) . ->* . block?)]) +(provide (contract-out + [filebox (((or/c core:element? string?)) () #:rest (listof pre-flow?) . ->* . block?)])) (define styling-f/c - (() () #:rest (listof pre-content?) . ->* . element?)) + (-> pre-content? ... element?)) (define-syntax-rule (provide-styling id ...) (provide/contract [id styling-f/c] ...)) (provide-styling racketmodfont racketoutput @@ -53,35 +54,32 @@ (provide void-const undefined-const) -(provide/contract - [PLaneT element?] - [hash-lang (-> element?)] - [etc element?] - [inset-flow (() () #:rest (listof pre-content?) . ->* . nested-flow?)] - [litchar (() () #:rest (listof string?) . ->* . element?)] - [t (() () #:rest (listof pre-content?) . ->* . paragraph?)] - [exec (() () #:rest (listof content?) . ->* . element?)] - [commandline (() () #:rest (listof content?) . ->* . paragraph?)] - [menuitem (string? string? . -> . element?)]) +(provide (contract-out [PLaneT element?] + [hash-lang (-> element?)] + [etc element?] + [inset-flow (() () #:rest (listof pre-content?) . ->* . nested-flow?)] + [litchar (() () #:rest (listof string?) . ->* . element?)] + [t (() () #:rest (listof pre-content?) . ->* . paragraph?)] + [exec (() () #:rest (listof content?) . ->* . element?)] + [commandline (() () #:rest (listof content?) . ->* . paragraph?)] + [menuitem (string? string? . -> . element?)])) (define PLaneT (make-element "planetName" '("PLaneT"))) (define etc (make-element #f (list "etc" ._))) (define (litchar . strs) - (let ([s (string-append* (map (lambda (s) (regexp-replace* "\n" s " ")) - strs))]) - (cond - [(regexp-match? #rx"^ *$" s) (make-element input-background-color (list (hspace (string-length s))))] - [else - (define ^spaces (car (regexp-match-positions #rx"^ *" s))) - (define $spaces (car (regexp-match-positions #rx" *$" s))) - (make-element - input-background-color - (list (hspace (cdr ^spaces)) - (make-element input-color - (list (substring s (cdr ^spaces) (car $spaces)))) - (hspace (- (cdr $spaces) (car $spaces)))))]))) + (define s (string-append* (map (lambda (s) (regexp-replace* "\n" s " ")) strs))) + (cond + [(regexp-match? #rx"^ *$" s) + (make-element input-background-color (list (hspace (string-length s))))] + [else + (define ^spaces (car (regexp-match-positions #rx"^ *" s))) + (define $spaces (car (regexp-match-positions #rx" *$" s))) + (make-element input-background-color + (list (hspace (cdr ^spaces)) + (make-element input-color (list (substring s (cdr ^spaces) (car $spaces)))) + (hspace (- (cdr $spaces) (car $spaces)))))])) (define (onscreen . str) (make-element 'sf (decode-content str))) @@ -173,11 +171,10 @@ (make-blockquote code-inset-style (list b))) (define (commandline . s) - (make-paragraph (cons (hspace 2) (map (lambda (s) - (if (string? s) - (make-element 'tt (list s)) - s)) - s)))) + (make-paragraph (cons (hspace 2) (for/list ([s (in-list s)]) + (if (string? s) + (make-element 'tt (list s)) + s))))) (define (pidefterm . s) (define c (apply defterm s)) diff --git a/scribble-lib/scribble/private/manual-vars.rkt b/scribble-lib/scribble/private/manual-vars.rkt index 3321674190..a707d8270e 100644 --- a/scribble-lib/scribble/private/manual-vars.rkt +++ b/scribble-lib/scribble/private/manual-vars.rkt @@ -17,8 +17,7 @@ (define-struct (box-splice splice) ()) -(provide/contract - [struct (box-splice splice) ([run list?])]) ; XXX ugly copying +(provide (contract-out (struct (box-splice splice) ([run list?])))) ; XXX ugly copying (provide deftogether *deftogether with-racket-variables with-togetherable-racket-variables @@ -172,47 +171,42 @@ (list (make-table boxed-style - (map - (lambda (box) - (unless (and (box-splice? box) - (= 1 (length (splice-run box))) - (nested-flow? (car (splice-run box))) - (eq? vertical-inset-style (nested-flow-style (car (splice-run box)))) - (let ([l (nested-flow-blocks (car (splice-run box)))]) - (= 1 (length l)) - (table? (car l)) - (eq? boxed-style (table-style (car l))))) - (error 'deftogether - "element is not a boxing splice containing a single nested-flow with a single table: ~e" - box)) - (list (make-flow (list (make-table - "together" - (table-flowss (car (nested-flow-blocks (car (splice-run box)))))))))) - boxes)))) + (for/list ([box (in-list boxes)]) + (unless (and (box-splice? box) + (= 1 (length (splice-run box))) + (nested-flow? (car (splice-run box))) + (eq? vertical-inset-style (nested-flow-style (car (splice-run box)))) + (let ([l (nested-flow-blocks (car (splice-run box)))]) + (= 1 (length l)) + (table? (car l)) + (eq? boxed-style (table-style (car l))))) + (error + 'deftogether + "element is not a boxing splice containing a single nested-flow with a single table: ~e" + box)) + (list (make-flow (list (make-table "together" + (table-flowss (car (nested-flow-blocks + (car (splice-run box))))))))))))) (body-thunk)))) (define-syntax (deftogether stx) (syntax-parse stx [(_ (def ...+) . body) (with-syntax ([((_ (lit ...) (var ...) decl) ...) - (map (lambda (def) - (define exp-def - (local-expand - def - (list (make-deftogether-tag)) - (cons - #'with-togetherable-racket-variables* - (kernel-form-identifier-list)))) - (syntax-case exp-def (with-togetherable-racket-variables*) - [(with-togetherable-racket-variables* lits vars decl) - exp-def] - [_ - (raise-syntax-error - #f - "sub-form is not a documentation form that can be combined" - stx - def)])) - (syntax->list #'(def ...)))]) + (for/list ([def (in-list (syntax->list #'(def ...)))]) + (define exp-def + (local-expand def + (list (make-deftogether-tag)) + (cons #'with-togetherable-racket-variables* + (kernel-form-identifier-list)))) + (syntax-case exp-def (with-togetherable-racket-variables*) + [(with-togetherable-racket-variables* lits vars decl) exp-def] + [_ + (raise-syntax-error + #f + "sub-form is not a documentation form that can be combined" + stx + def)]))]) #'(with-togetherable-racket-variables (lit ... ...) (var ... ...) diff --git a/scribble-lib/scribble/private/render-utils.rkt b/scribble-lib/scribble/private/render-utils.rkt index c652d4ea5a..d5cbacb7e8 100644 --- a/scribble-lib/scribble/private/render-utils.rkt +++ b/scribble-lib/scribble/private/render-utils.rkt @@ -42,13 +42,14 @@ (let ([cols (ormap (lambda (v) (and (table-columns? v) v)) vars)]) (and cols (let ([cols (table-columns-styles cols)]) - (map (lambda (row) - (unless (= (length cols) (length row)) - (error 'table - "table-columns property list's length does not match a row length: ~e vs. ~e" - cols (length row))) - cols) - (table-blockss t))))) + (for/list ([row (in-list (table-blockss t))]) + (unless (= (length cols) (length row)) + (error + 'table + "table-columns property list's length does not match a row length: ~e vs. ~e" + cols + (length row))) + cols)))) (map (lambda (row) (map (lambda (c) plain) row)) (table-blockss t)))) (define (empty-content? c) (null? c))