fix other mandelbrot variants
[mu.git] / tools / update_html
blob8110b0100e748164e7e0815812ea28d88139e773
1 #!/bin/bash
2 # Regenerate html files.
3 # If given a single argument, try to regenerate just that file. Not supported everywhere.
5 set -e
7 ( cd tools; c++ -g linkify.cc -o linkify; )
9 # generate html/$1.html using /tmp/tags
10 process() {
11 mkdir -p html/$(dirname $1)
12 rm -f html/$1.html
13 convert_html $1
14 tools/linkify /tmp/tags $1.html
15 mv $1.html.out html/$1.html
16 rm $1.html
19 URL_BASE='https://github.com/akkartik/mu/blob/main'
21 convert_html() {
22 vim -c "set number" -c TOhtml -c write -c qall $1
24 sed -i 's,<title>.*/mu/,<title>Mu - ,' $1.html
25 sed -i 's,\.html</title>,</title>,' $1.html
27 sed -i "/^<body/a <a href='$URL_BASE/$1'>$URL_BASE/$1</a>" $1.html
29 sed -i 's/^\* { \(.*\) }/* { font-size:12pt; \1 }/g' $1.html
30 sed -i 's/^body { \(.*\) }/body { font-size:12pt; \1 }/g' $1.html
32 sed -i '/^body {/a a { color:inherit; }' $1.html
35 ctags -x boot.subx [0-9]*.subx [0-9]*.mu > /tmp/tags
36 for f in boot.subx [0-9]*.subx [0-9]*.mu
38 test $# -gt 0 && test $1 != $f && continue
39 process $f
40 done
42 for f in [^0-9]*.subx [^0-9]*.mu
44 test $# -gt 0 && test $1 != $f && continue
45 test $f = "boot.subx" && continue
46 ctags -x boot.subx [0-9]*.subx [0-9]*.mu $f > /tmp/tags
47 process $f
48 done
50 for f in apps/*.mu
52 test $# -gt 0 && test $1 != $f && continue
53 ( cd $(dirname $f)
54 ctags -x ../[0-9]*.subx ../[0-9]*.mu $(basename $f) > /tmp/tags
56 process $f
57 done
59 ( cd shell
60 ctags -x ../boot.subx ../[0-9]*.subx ../[0-9]*.mu *.mu > /tmp/tags
62 for f in shell/*.mu
64 test $# -gt 0 && test $1 != $f && continue
65 process $f
66 done
68 ( cd browse-slack
69 ctags -x ../boot.subx ../[0-9]*.subx ../[0-9]*.mu *.mu > /tmp/tags
71 for f in browse-slack/*.mu
73 test $# -gt 0 && test $1 != $f && continue
74 process $f
75 done
77 ( cd linux
78 ctags -x [0-9]*.subx [0-9]*.mu > /tmp/tags
80 for f in linux/[0-9]*.subx linux/[0-9]*.mu
82 process $f
83 done
85 for f in linux/[^0-9]*.subx linux/[^0-9]*.mu
87 ( cd $(dirname $f)
88 ctags -x [0-9]*.subx [0-9]*.mu $(basename $f) > /tmp/tags
90 process $f
91 done
93 for f in linux/apps/*.subx linux/apps/*.mu
95 ( cd $(dirname $f)
96 ctags -x ../[0-9]*.subx ../[0-9]*.mu $(basename $f) > /tmp/tags
98 process $f
99 done
101 for f in linux/apps/advent2020/*.mu linux/apps/advent2017/*.mu
103 ( cd $(dirname $f)
104 ctags -x ../../[0-9]*.subx ../../[0-9]*.mu $(basename $f) > /tmp/tags
106 process $f
107 done
109 ( cd linux/tile
110 ctags -x ../[0-9]*.subx ../[0-9]*.mu *.mu > /tmp/tags
112 for f in linux/tile/*.mu
114 process $f
115 done
117 ( cd linux/apps/raytracing
118 ctags -x ../../[0-9]*.subx ../../[0-9]*.mu *.mu > /tmp/tags
120 for f in linux/apps/raytracing/*.mu
122 process $f
123 done
125 ( cd linux/bootstrap
126 ctags -x *.cc |grep -v '^. ' > /tmp/tags # don't hyperlink every 'i' to the integer register variant
128 for f in linux/bootstrap/*.cc
130 process $f
131 done
133 rm /tmp/tags