-
Notifications
You must be signed in to change notification settings - Fork 206
/
.generate
executable file
·46 lines (37 loc) · 1007 Bytes
/
.generate
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
#!/bin/bash
# /path/to/zotonic/modules/<mod>/templates/{device/}template_name.tpl
for f in `find $ZOTONIC_SRC/modules -name [^_]\*.tpl`
do
read -r mod templatepath <<EOF
`echo $f | sed -e 's/^.*\/\(mod_[^\/]*\)\/templates\/\(.*\)\.tpl$/\1 \2/'`
EOF
template=`basename $templatepath`
read -r device <<EOF
`dirname $templatepath | sed -e 's/^\.$//'`
EOF
dir=${0%/*}
base=$template${device:+-}$device
stub=$dir/meta-$base.rst
doc=$dir/template_$base.rst
title="$template${device:+ (}$device${device:+)}.tpl"
cat <<EOF > $stub
.. This file is generated.
To document this template, edit the template_$base.rst file, which should include this file.
.. index:: template; $base
single: $mod; template, $base
.. _template-$base:
$title
${title//?/=}
${device:+
* Device: $device
}
* Module: :ref:\`$mod\`
EOF
if [ ! -e $doc ]; then
echo "New doc: $doc"
cat <<EOF > $doc
.. include:: meta-$base.rst
.. todo:: Not yet documented.
EOF
fi
done