1#lang racket/base
2(require setup/collects
3         racket/contract/base
4         scribble/core
5         scribble/base
6         scribble/decode
7         scribble/html-properties
8         scribble/latex-properties
9         (for-syntax racket/base))
10
11(provide/contract
12 [abstract
13  (->* () () #:rest (listof pre-content?)
14       block?)]
15 [subtitle
16  (->* () () #:rest (listof pre-content?)
17       content?)]
18 [authorinfo
19  (-> pre-content? pre-content? pre-content?
20      block?)]
21 [conferenceinfo
22  (-> pre-content? pre-content?
23      block?)]
24 [copyrightyear
25  (->* () () #:rest (listof pre-content?)
26       block?)]
27 [copyrightdata
28  (->* () () #:rest (listof pre-content?)
29       block?)]
30 [exclusive-license
31  (->* () ()
32       block?)]
33 [doi
34  (->* () () #:rest (listof pre-content?)
35       block?)]
36 [to-appear
37  (->* () () #:rest pre-content?
38       block?)]
39 [category
40  (->* (pre-content? pre-content? pre-content?)
41       ((or/c #f pre-content?))
42       content?)]
43 [terms
44  (->* () () #:rest (listof pre-content?)
45       content?)]
46 [keywords
47  (->* () () #:rest (listof pre-content?)
48       content?)])
49
50(provide preprint 10pt nocopyright onecolumn noqcourier notimes
51         include-abstract)
52
53(define-syntax-rule (defopts name ...)
54  (begin (define-syntax (name stx)
55           (raise-syntax-error #f
56                               "option must appear on the same line as `#lang scribble/sigplan'"
57                               stx))
58         ...
59         (provide name ...)))
60(defopts preprint 10pt nocopyright onecolumn noqcourier notimes)
61
62(define sigplan-extras
63  (let ([abs (lambda (s)
64               (path->collects-relative
65                (collection-file-path s "scribble" "sigplan")))])
66    (list
67     (make-css-addition (abs "sigplan.css"))
68     (make-tex-addition (abs "sigplan.tex")))))
69
70;; ----------------------------------------
71;; Abstracts:
72
73(define abstract-style (make-style "abstract" sigplan-extras))
74
75(define (abstract . strs)
76  (make-nested-flow
77   abstract-style
78   (decode-flow strs)))
79
80(define (extract-abstract p)
81  (unless (part? p)
82    (error 'include-abstract "doc binding is not a part: ~e" p))
83  (unless (null? (part-parts p))
84    (error 'include-abstract "abstract part has sub-parts: ~e" (part-parts p)))
85  (when (part-title-content p)
86    (error 'include-abstract "abstract part has title content: ~e" (part-title-content p)))
87  (part-blocks p))
88
89(define-syntax-rule (include-abstract mp)
90  (begin
91    (require (only-in mp [doc abstract-doc]))
92    (make-nested-flow abstract-style (extract-abstract abstract-doc))))
93
94;; ----------------------------------------
95;; Authors and conference info:
96
97(define (authorinfo name affiliation e-mail)
98  ;; The \SAuthor macro in "style.tex" looks specifically
99  ;; for an \SAuthorinfo as its argument, and handles it
100  ;; specially in that case:
101  (author
102   (make-multiarg-element
103    (make-style "SAuthorinfo" sigplan-extras)
104    (list
105     (make-element #f (decode-content (list name)))
106     (make-element (make-style "SAuthorPlace" sigplan-extras)
107                   (decode-content (list affiliation)))
108     (make-element (make-style "SAuthorEmail" sigplan-extras)
109                   (decode-content (list e-mail)))))))
110
111(define (subtitle . str)
112  (make-element (make-style "SSubtitle" (append '(aux) sigplan-extras))
113                (decode-content str)))
114
115(define (conferenceinfo what where)
116  (make-paragraph
117   (make-style 'pretitle null)
118   (make-multiarg-element
119    (make-style "SConferenceInfo" sigplan-extras)
120    (list
121     (make-element #f (decode-content (list what)))
122     (make-element #f (decode-content (list where)))))))
123
124(define (copyrightyear . when)
125  (make-paragraph
126   (make-style 'pretitle null)
127   (make-element
128    (make-style "SCopyrightYear" sigplan-extras)
129    (decode-content when))))
130
131(define (copyrightdata . what)
132  (make-paragraph
133   (make-style 'pretitle null)
134   (make-element
135    (make-style "SCopyrightData" sigplan-extras)
136    (decode-content what))))
137
138(define (doi . what)
139  (make-paragraph
140   (make-style 'pretitle null)
141   (make-element
142    (make-style "Sdoi" sigplan-extras)
143    (decode-content what))))
144
145(define (exclusive-license . what)
146  (make-paragraph
147   (make-style 'pretitle null)
148   (make-element
149    (make-style "SPexclusivelicense" sigplan-extras)
150    (decode-content what))))
151
152(define (to-appear . what)
153  (make-paragraph
154   (make-style 'pretitle null)
155   (make-element
156    (make-style "toappear" sigplan-extras)
157    (decode-content what))))
158
159;; ----------------------------------------
160;; Categories, terms, and keywords:
161
162(define (category sec title sub [more #f])
163  (make-multiarg-element
164   (make-style (format "SCategory~a" (if more "Plus" "")) sigplan-extras)
165   (list*
166    (make-element #f (decode-content (list sec)))
167    (make-element #f (decode-content (list title)))
168    (make-element #f (decode-content (list sub)))
169    (if more
170        (list (make-element #f (decode-content (list more))))
171        null))))
172
173(define (terms . str)
174  (make-element (make-style "STerms" sigplan-extras) (decode-content str)))
175
176(define (keywords . str)
177  (make-element (make-style "SKeywords" sigplan-extras) (decode-content str)))
178