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
8 changes: 4 additions & 4 deletions scribble-lib/scribble/acmart.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
#:email (or/c pre-content? email? (listof email?)))
#:rest (listof pre-content?)
block?)]
[authorsaddresses (->* () () #:rest (listof pre-content?) block?)]
[shortauthors (->* () () #:rest (listof pre-content?) element?)]
[authorsaddresses (-> pre-content? ... block?)]
[shortauthors (-> pre-content? ... element?)]
[institution
(->* ()
(#:departments (listof (or/c pre-content? institution?)))
Expand All @@ -67,7 +67,7 @@
#:country (or/c pre-content? #f))
affiliation?)]
[affiliation? (-> any/c boolean?)]
[abstract (->* () () #:rest (listof pre-content?) block?)]
[abstract (-> pre-content? ... block?)]
[acmConference (-> string? string? string? block?)]
[grantsponsor (-> string? string? string? content?)]
[grantnum (->* (string? string?) (#:url string?) content?)]
Expand All @@ -76,7 +76,7 @@
[received (->* (string?) (#:stage string?) block?)]
[citestyle (-> content? block?)]
[ccsdesc (->* (string?) (#:number exact-integer?) block?)]
[CCSXML (->* () () #:rest (listof pre-content?) any/c)]))
[CCSXML (-> pre-content? ... any/c)]))
(provide
invisible-element-to-collect-for-acmart-extras
include-abstract)
Expand Down
51 changes: 13 additions & 38 deletions scribble-lib/scribble/sigplan.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,19 @@
scribble/latex-properties
(for-syntax racket/base))

(provide/contract
[abstract
(->* () () #:rest (listof pre-content?)
block?)]
[subtitle
(->* () () #:rest (listof pre-content?)
content?)]
[authorinfo
(-> pre-content? pre-content? pre-content?
block?)]
[conferenceinfo
(-> pre-content? pre-content?
block?)]
[copyrightyear
(->* () () #:rest (listof pre-content?)
block?)]
[copyrightdata
(->* () () #:rest (listof pre-content?)
block?)]
[exclusive-license
(->* () ()
block?)]
[doi
(->* () () #:rest (listof pre-content?)
block?)]
[to-appear
(->* () () #:rest pre-content?
block?)]
[category
(->* (pre-content? pre-content? pre-content?)
((or/c #f pre-content?))
content?)]
[terms
(->* () () #:rest (listof pre-content?)
content?)]
[keywords
(->* () () #:rest (listof pre-content?)
content?)])
(provide (contract-out
[abstract (->* () () #:rest (listof pre-content?) block?)]
[subtitle (->* () () #:rest (listof pre-content?) content?)]
[authorinfo (-> pre-content? pre-content? pre-content? block?)]
[conferenceinfo (-> pre-content? pre-content? block?)]
[copyrightyear (->* () () #:rest (listof pre-content?) block?)]
[copyrightdata (->* () () #:rest (listof pre-content?) block?)]
[exclusive-license (->* () () block?)]
[doi (->* () () #:rest (listof pre-content?) block?)]
[to-appear (->* () () #:rest pre-content? block?)]
[category (->* (pre-content? pre-content? pre-content?) ((or/c #f pre-content?)) content?)]
[terms (->* () () #:rest (listof pre-content?) content?)]
[keywords (->* () () #:rest (listof pre-content?) content?)]))

(provide preprint 10pt nocopyright onecolumn noqcourier notimes
include-abstract)
Expand Down
122 changes: 66 additions & 56 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)))))]))))])
(define names-length (length names))
(define 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)))))])))])

#`([(id #,@(build-mandatories/optionals (syntax->list #'(mandatory-names ...))
(syntax->list #'(mandatory ...))
Expand All @@ -404,11 +412,13 @@
[((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)
Expand Down
57 changes: 30 additions & 27 deletions scribble-lib/scribble/tag.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -51,38 +51,41 @@
(cond
[(or (string? v) (bytes? v) (list? v))
(define b (hash-ref interned v #f))
(if b
(or (weak-box-value b)
;; just in case the value is GCed before we extract it:
(intern-taglet v))
(begin
(hash-set! interned v (make-weak-box v))
v))]
(cond
[b
(or (weak-box-value b)
;; just in case the value is GCed before we extract it:
(intern-taglet v))]
[else
(hash-set! interned v (make-weak-box v))
v])]
[else v])))

(define (do-module-path-index->taglet mod)
;; Derive the name from the module path:
(define p (collapse-module-path-index mod (lambda () (build-path (current-directory) "dummy"))))
(if (path? p)
;; If we got a path back anyway, then it's best to use the resolved
;; name; if the current directory has changed since we
;; the path-index was resolved, then p might not be right. Also,
;; the resolved path might be a symbol instead of a path.
(let ([rp (resolved-module-path-name (module-path-index-resolve mod))])
(if (path? rp)
(intern-taglet (path->collects-relative rp))
rp))
(let ([p (if (and (pair? p) (eq? (car p) 'planet))
;; Normalize planet verion number based on current
;; linking:
(let-values ([(path pkg) (get-planet-module-path/pkg p #f #f)])
(list* 'planet
(cadr p)
(list (car (caddr p)) (cadr (caddr p)) (pkg-maj pkg) (pkg-min pkg))
(cdddr p)))
;; Otherwise the path is fully normalized:
p)])
(intern-taglet p))))
(cond
[(path? p)
;; If we got a path back anyway, then it's best to use the resolved
;; name; if the current directory has changed since we
;; the path-index was resolved, then p might not be right. Also,
;; the resolved path might be a symbol instead of a path.
(define rp (resolved-module-path-name (module-path-index-resolve mod)))
(if (path? rp)
(intern-taglet (path->collects-relative rp))
rp)]
[else
(let ([p (if (and (pair? p) (eq? (car p) 'planet))
;; Normalize planet verion number based on current
;; linking:
(let-values ([(path pkg) (get-planet-module-path/pkg p #f #f)])
(list* 'planet
(cadr p)
(list (car (caddr p)) (cadr (caddr p)) (pkg-maj pkg) (pkg-min pkg))
(cdddr p)))
;; Otherwise the path is fully normalized:
p)])
(intern-taglet p))]))

(define collapsed (make-weak-hasheq))
(define (module-path-index->taglet mod)
Expand Down
Loading