about summary refs log tree commit diff stats
path: root/tools/update_html
blob: 78a790aa939cc3ddf72f690b65ceeb50abb3959b (plain) (blame)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
# Regenerate html files.
# If given a single argument, try to regenerate just that file. Not supported everywhere.

set -e

( cd tools; c++ -g linkify.cc -o linkify; )

# generate html/$1.html using /tmp/tags
process() {
  mkdir -p html/$(dirname $1)
  rm -f html/$1.html
  convert_html $1
  tools/linkify /tmp/tags $1.html
  mv $1.html.out html/$1.html
  rm $1.html
}

URL_BASE='https://github.com/akkartik/mu/blob/main'

convert_html() {
  vim -c "set number" -c TOhtml -c write -c qall $1

  sed -i 's,<title>.*/mu/,<title>Mu - ,' $1.html
  sed -i 's,\.html</title>,</title>,' $1.html

  sed -i "/^<body/a <a href='$URL_BASE/$1'>$URL_BASE/$1</a>" $1.html

  sed -i 's/^\* { \(.*\) }/* { font-size:12pt; \1 }/g' $1.html
  sed -i 's/^body { \(.*\) }/body { font-size:12pt; \1 }/g' $1.html

  sed -i '/^body {/a a { color:inherit; }' $1.html
}

ctags -x boot.subx [0-9]*.subx [0-9]*.mu  > /tmp/tags
for f in boot.subx [0-9]*.subx [0-9]*.mu
do
  test $# -gt 0  &&  test $1 != $f  &&  continue
  process $f
done

for f in [^0-9]*.subx [^0-9]*.mu
do
  test $# -gt 0  &&  test $1 != $f  &&  continue
  test $f = "boot.subx" && continue
  ctags -x boot.subx [0-9]*.subx [0-9]*.mu $f > /tmp/tags
  process $f
done

for f in apps/*.mu
do
  ( cd $(dirname $f)
    ctags -x ../[0-9]*.subx ../[0-9]*.mu $(basename $f) > /tmp/tags
  )
  process $f
done

( cd shell
  ctags -x ../boot.subx ../[0-9]*.subx ../[0-9]*.mu *.mu > /tmp/tags
)
for f in shell/*.mu
do
  test $# -gt 0  &&  test $1 != $f  &&  continue
  process $f
done

( cd browse-slack
  ctags -x ../boot.subx ../[0-9]*.subx ../[0-9]*.mu *.mu > /tmp/tags
)
for f in browse-slack/*.mu
do
  test $# -gt 0  &&  test $1 != $f  &&  continue
  process $f
done

( cd linux
  ctags -x [0-9]*.subx [0-9]*.mu  > /tmp/tags
)
for f in linux/[0-9]*.subx linux/[0-9]*.mu
do
  process $f
done

for f in linux/[^0-9]*.subx linux/[^0-9]*.mu
do
  ( cd $(dirname $f)
    ctags -x [0-9]*.subx [0-9]*.mu $(basename $f)  > /tmp/tags
  )
  process $f
done

for f in linux/apps/*.subx linux/apps/*.mu
do
  ( cd $(dirname $f)
    ctags -x ../[0-9]*.subx ../[0-9]*.mu $(basename $f) > /tmp/tags
  )
  process $f
done

for f in linux/apps/advent2020/*.mu linux/apps/advent2017/*.mu
do
  ( cd $(dirname $f)
    ctags -x ../../[0-9]*.subx ../../[0-9]*.mu $(basename $f) > /tmp/tags
  )
  process $f
done

( cd linux/tile
  ctags -x ../[0-9]*.subx ../[0-9]*.mu *.mu > /tmp/tags
)
for f in linux/tile/*.mu
do
  process $f
done

( cd linux/apps/raytracing
  ctags -x ../../[0-9]*.subx ../../[0-9]*.mu *.mu > /tmp/tags
)
for f in linux/apps/raytracing/*.mu
do
  process $f
done

( cd linux/bootstrap
  ctags -x *.cc  |grep -v '^. '  > /tmp/tags  # don't hyperlink every 'i' to the integer register variant
)
for f in linux/bootstrap/*.cc
do
  process $f
done

rm /tmp/tags