-
Notifications
You must be signed in to change notification settings - Fork 1
/
update-docs.sh
executable file
·70 lines (52 loc) · 2.47 KB
/
update-docs.sh
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
#!/usr/bin/env bash
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# update to fluffos driver docs directory path
driverDocs=driver/docs
# update to mudlib docs directory path
libDocs=lib/doc
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
types=("apply" "efun") # exclude concepts, driver, stdlib, and zh-CN
for type in ${types[@]} ; do
mkdir -p ${libDocs}/${type} # ensure mudlib dir exists
for dir in ${driverDocs}/${type}/*/ ; do
dir=${dir%*/} # remove trailing /
for file in ${dir}/*.md ; do
filename=${file##*/} # grab everything after last /
[[ ${filename} =~ ^__ ]] && continue # ignore obsolete apply __INIT
[[ ${filename} =~ ^README ]] && continue # ignore README
[[ ${filename} =~ ^index ]] && continue # ignore index
# new doc file path
newDoc=${libDocs}/${type}/${filename%.md}
tmpDoc=${newDoc}.tmp
cp ${file} ${tmpDoc} # copy to temporary file
sed -i '1,4 d' ${tmpDoc} # trim beginning of file
# update doc if new file is different
cmp --silent ${tmpDoc} ${newDoc} || echo Updating ${newDoc} && cp ${tmpDoc} ${newDoc}
rm ${tmpDoc} # remove temporary file
done
done
done
types=("lpc/constructs" "lpc/preprocessor" "lpc/types")
for type in ${types[@]} ; do
mkdir -p ${libDocs}/${type} # ensure mudlib dir exists
echo type ${type}
for dir in ${driverDocs}/${type}/ ; do
dir=${dir%*/} # remove trailing /
echo dir ${dir}
for file in ${dir}/*.md ; do
filename=${file##*/} # grab everything after last /
echo filename ${filename}
[[ ${filename} =~ ^__ ]] && continue # ignore obsolete apply __INIT
[[ ${filename} =~ ^README ]] && continue # ignore README
[[ ${filename} =~ ^index ]] && continue # ignore index
# new doc file path
newDoc=${libDocs}/${type}/${filename%.md}
tmpDoc=${newDoc}.tmp
cp ${file} ${tmpDoc} # copy to temporary file
sed -i '1,4 d' ${tmpDoc} # trim beginning of file
# update doc if new file is different
cmp --silent ${tmpDoc} ${newDoc} || echo Updating ${newDoc} && cp ${tmpDoc} ${newDoc}
rm ${tmpDoc} # remove temporary file
done
done
done