forked from w3f/research
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaintain-indexes.sh
executable file
·40 lines (35 loc) · 996 Bytes
/
maintain-indexes.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
#!/usr/bin/env bash
# Autogenerate dummy missing index pages
for dir in $(find docs -mindepth 1 -type d); do
case $dir in
*/_static|*/_static/*|*/_templates|*/_templates/*|*/images|*/images/*|docs/papers|docs/papers/*) continue;;
*)
if [ -f "$dir/main.tex" ]; then
continue
elif [ ! -f "$dir.rst" ]; then
name="$(basename "$dir")"
read -p "create empty index \"$name\" for $dir [y/n]? " x
if [ "$x" = "y" -o "$x" = "Y" ]; then
if [ -f "$dir/index.md" ]; then
nameindex="$(printf "%s/index\n " "$name")"
namerefresh='.. raw:: html
<meta http-equiv="refresh" content="0; url=./'"${name}"'/index.html">
'
else
namerefresh=""
nameindex=""
fi
titlebar="$(echo "$name" | sed s/./=/g)"
cat > "$dir.rst" <<-eof
$titlebar
$name
$titlebar
${namerefresh}.. toctree::
:glob:
${nameindex}$name/*
eof
fi
fi
;;
esac
done