-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.aya
executable file
·40 lines (34 loc) · 1022 Bytes
/
build.aya
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
#!/usr/bin/env aya
import ::sys
import ::io
path.aya "manual" + :source;
"./docs/source" path! :dest;
.# Convert markdown files to rst files
source sys.readdir.[{".md"N0>}] :# {file : filename out in,
file :P
file '. S.[0] :filename;
dest "$filename.rst" + :out;
source file +: in;
"Converting $in -> $out" :P
["pandoc" "--from=markdown" "--to=rst" "--output=$out" "$in"] :{sys.exec}
};
.# Operator page
from "./gen_op_tables" import ::op_page_str
.# Write to temp file
op_page_str "oprst.rst" 0 .G
dest "operators.rst" + :op_out;
["mv" "oprst.rst" "$op_out"] :{sys.exec}
.# Convert .md links to .html links
dest sys.readdir.[{".rst"N0>}] :# {fname : content,
dest fname + P:fpath;
.# Read the file
fpath G :content;
.# replace .md links with .html ones
content ("\.md>" ".html>" .&) ("\.md#" ".html#" .&) :content;
.# Write it back to the file
fpath 'w file!:f;
content f.print;
f.close;
};
.# Copy images over
["cp" "-r" "$source/img" dest] :{sys.exec}