-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathos.rkt
executable file
·66 lines (59 loc) · 2.28 KB
/
os.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#! /usr/bin/env racket
#lang racket
;; raco pkg install css-expr txexpr
(require css-expr)
(require txexpr)
(define (xexpr->file html-filename xexpr)
(call-with-atomic-output-file
html-filename
(λ (out . _) (displayln (xexpr->html xexpr) out))))
(define data (with-input-from-file "os.scm" read))
(define (feature-tds all-available-features-in-order features)
(for-each (λ (feature)
(unless (memq feature all-available-features-in-order)
(error "missing from list of all features:" feature)))
features)
(map (λ (feature)
(let ((has? (memq feature features)))
`(td ((class ,(if has? "feature yes" "feature no"))))))
all-available-features-in-order))
(define (feature-sections feature)
(match feature
[(cons feature-class feature-instances)
(match feature-instances
[(cons (cons 'features all-available-features-in-order) instances)
`(section
(h2 ,(symbol->string feature-class))
(table
(tr (th "Scheme")
(th "Procedure")
,@(map (λ (feature) `(th ,(symbol->string feature)))
all-available-features-in-order))
,@(map (λ (instance)
(match instance
[(list 'implementation
scheme-impl impl-name impl-features)
`(tr
(td ,(symbol->string scheme-impl))
(td ,(symbol->string impl-name))
,@(feature-tds all-available-features-in-order
impl-features))]))
instances)))])]))
(xexpr->file
"os.html"
`(html
(head
(title "Scheme")
(style ,(css-expr->css
(css-expr
[html #:background-color white #:font-family sans-serif]
[table #:border-collapse collapse]
[table td th #:border [1px solid black]]
[td.feature #:text-align center]
[td.feature.yes #:background-color lightgreen]
[td.feature.yes::after #:content "\u2714"]
[td.feature.no #:background-color lightyellow]
[td.feature.no::after #:content "\u2715"]))))
(body
(h1 "Scheme")
,@(map feature-sections data))))