diff --git a/scribble-lib/scribble/private/manual-class.rkt b/scribble-lib/scribble/private/manual-class.rkt index 7cff96cfe0..af8c1a5e15 100644 --- a/scribble-lib/scribble/private/manual-class.rkt +++ b/scribble-lib/scribble/private/manual-class.rkt @@ -48,14 +48,9 @@ (define (id-info id) (define b (identifier-label-binding id)) - (if b - (list (caddr b) - (list-ref b 3) - (list-ref b 4) - (list-ref b 5) - (list-ref b 6)) - (error 'scribble "no class/interface/mixin information for identifier: ~e" - id))) + (unless b + (error 'scribble "no class/interface/mixin information for identifier: ~e" id)) + (list (caddr b) (list-ref b 3) (list-ref b 4) (list-ref b 5) (list-ref b 6))) (define (make-inherited-table r d ri decl) (define start @@ -155,11 +150,11 @@ null)) (define (build-body decl body) - `(,@(map (lambda (i) - (cond [(constructor? i) ((constructor-def i))] - [(meth? i) ((meth-def i))] - [else i])) - body) + `(,@(for/list ([i (in-list body)]) + (cond + [(constructor? i) ((constructor-def i))] + [(meth? i) ((meth-def i))] + [else i])) ,(make-delayed-block (lambda (r d ri) (make-inherited-table r d ri decl))))) (define (*include-class/title decl link?) @@ -408,17 +403,13 @@ (datum->syntax n (syntax-e n) (list 'src 1 3 4 1))) (list 'src 1 0 1 5))] [(((kw ...) ...) ...) - (map (lambda (ids) - (map (lambda (arg) - (if (and (pair? (syntax-e arg)) - (eq? (syntax-e #'mode) 'new)) - (list (string->keyword - (symbol->string - (syntax-e - (car (syntax-e arg)))))) - null)) - (syntax->list ids))) - (syntax->list #'((arg ...) ...)))]) + (for/list ([ids (in-list (syntax->list #'((arg ...) ...)))]) + (map (lambda (arg) + (if (and (pair? (syntax-e arg)) (eq? (syntax-e #'mode) 'new)) + (list (string->keyword + (symbol->string (syntax-e (car (syntax-e arg)))))) + null)) + (syntax->list ids)))]) #'(make-constructor (lambda () (defproc* #:mode mode #:within name [[(make [kw ... . arg] ...) result] ...] diff --git a/scribble-lib/scribble/private/manual-code.rkt b/scribble-lib/scribble/private/manual-code.rkt index 740d828bd0..3b3b228143 100644 --- a/scribble-lib/scribble/private/manual-code.rkt +++ b/scribble-lib/scribble/private/manual-code.rkt @@ -340,16 +340,19 @@ (list 'function start end 1)] ; this looses information [_ tok]))) - (define (make-test-result lst) - (define-values (res _) - (for/fold ([result null] [count 12]) + (define (make-test-result lst) + (define res + (for/fold ([result null] + [count 12] + #:result result) ([p lst]) (define next (+ count (second p))) (define r (if (eq? (first p) 'function) 1 0)) - (values - (cons (list (first p) count next r) result) - next))) - (list* `(function 0 5 1) `(white-space 5 6 0) `(function 6 12 1) `(function 6 12 1) + (values (cons (list (first p) count next r) result) next))) + (list* `(function 0 5 1) + `(white-space 5 6 0) + `(function 6 12 1) + `(function 6 12 1) (reverse res))) (check-equal? diff --git a/scribble-lib/scribble/private/manual-form.rkt b/scribble-lib/scribble/private/manual-form.rkt index e3a4abd106..17c6879418 100644 --- a/scribble-lib/scribble/private/manual-form.rkt +++ b/scribble-lib/scribble/private/manual-form.rkt @@ -413,11 +413,12 @@ flow-empty-line flow-empty-line) (list (to-flow nonterm) flow-empty-line (to-flow "=") flow-empty-line (make-flow (list (car clauses)))) - (map (lambda (clause) - (list flow-empty-line flow-empty-line - (to-flow "|") flow-empty-line - (make-flow (list clause)))) - (cdr clauses)))) + (for/list ([clause (in-list (cdr clauses))]) + (list flow-empty-line + flow-empty-line + (to-flow "|") + flow-empty-line + (make-flow (list clause)))))) nonterms clauseses)))) (define (*racketrawgrammar style nonterm clause1 . clauses) @@ -426,11 +427,8 @@ (define (*racketgrammar lits s-expr clauseses-thunk) (define l (clauseses-thunk)) (*racketrawgrammars #f - (map (lambda (x) - (make-element #f - (list (hspace 2) - (car x)))) - l) + (for/list ([x (in-list l)]) + (make-element #f (list (hspace 2) (car x)))) (map cdr l))) (define (*var id) @@ -445,14 +443,11 @@ (append (list (list flow-empty-line)) (list (list (make-flow - (map (lambda (c) - (make-table - "argcontract" - (list - (list (to-flow (hspace 2)) - (to-flow ((car c))) - flow-spacer - (to-flow ":") - flow-spacer - (make-flow (list ((cadr c)))))))) - contract-procs))))))) + (for/list ([c (in-list contract-procs)]) + (make-table "argcontract" + (list (list (to-flow (hspace 2)) + (to-flow ((car c))) + flow-spacer + (to-flow ":") + flow-spacer + (make-flow (list ((cadr c)))))))))))))) 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-tech.rkt b/scribble-lib/scribble/private/manual-tech.rkt index f36103662e..a1870662b8 100644 --- a/scribble-lib/scribble/private/manual-tech.rkt +++ b/scribble-lib/scribble/private/manual-tech.rkt @@ -9,28 +9,31 @@ "manual-utils.rkt" "manual-style.rkt") -(provide/contract - [deftech (() (#:normalize? any/c - #:style? any/c - #:key (or/c string? #f) - #:index-extras desc-extras/c) - #:rest (listof pre-content?) . ->* . element?)] - [tech (() - (#:doc (or/c module-path? #f) - #:tag-prefixes (or/c (listof string?) #f) - #:key (or/c string? #f) - #:normalize? any/c - #:indirect? any/c) - #:rest (listof pre-content?) - . ->* . element?)] - [techlink (() - (#:doc (or/c module-path? #f) - #:tag-prefixes (or/c (listof string?) #f) - #:key (or/c string? #f) - #:normalize? any/c - #:indirect? any/c) - #:rest (listof pre-content?) - . ->* . element?)]) +(provide (contract-out + [deftech + (() + (#:normalize? any/c #:style? any/c #:key (or/c string? #f) #:index-extras desc-extras/c) + #:rest (listof pre-content?) + . ->* . + element?)] + [tech + (() (#:doc (or/c module-path? #f) + #:tag-prefixes (or/c (listof string?) #f) + #:key (or/c string? #f) + #:normalize? any/c + #:indirect? any/c) + #:rest (listof pre-content?) + . ->* . + element?)] + [techlink + (() (#:doc (or/c module-path? #f) + #:tag-prefixes (or/c (listof string?) #f) + #:key (or/c string? #f) + #:normalize? any/c + #:indirect? any/c) + #:rest (listof pre-content?) + . ->* . + element?)])) (define (*tech make-elem style doc prefix s key normalize?) (let* ([c (decode-content 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))