-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.shen
34 lines (29 loc) · 1.06 KB
/
build.shen
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
(if (not (shen.fbound? require))
(error "prelude not loaded. run `shen -l prelude.shen -l build.shen`")
[])
(define flatten-type
[X --> [Y --> Z]] -> [(flatten-type X) --> | (flatten-type [Y --> Z])]
[X --> Y] -> [(flatten-type X) --> Y]
X -> X)
(define format-type-sub
--> -> "→"
shen.==> -> "⇨"
Type -> (make-string "(~A)" (join-strings " " (map #'format-type-sub Type))) where (cons? Type)
Type -> (str Type))
(define format-type
Type -> (join-strings " " (map #'format-type-sub Type)) where (cons? Type)
Type -> (str Type))
(define format-entry
Name Doc Type ->
(let Heading (@s "### `" (str Name) "`")
Heading (if (fail? Type) Heading (@s Heading " : `" (format-type (flatten-type Type)) "`"))
[Heading Doc]))
(do
(->>
&'*doc-index*
(sort-list (/. X Y (>= 0 (string-compare (str (fst X)) (str (fst Y))))))
(flat-map (/. D (format-entry (fst D) (snd D) (type-of (fst D)))))
(cons "# Shen Prelude API Docs")
(join-strings "c#13;c#10;c#13;c#10;")
(write-to-file "api.md"))
docs-written)