forked from elego/rental-vertical
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen-doc.sh
executable file
·137 lines (135 loc) · 3.77 KB
/
gen-doc.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
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
133
134
135
136
137
#!/bin/bash
TOOLS=${TOOLS:-~/work/odoo-dev/tools}
ds=$(date "+%Y-%m-%d-%H-%M-%S")
GET_MANIFEST_INFO=${GET_MANIFEST_INFO:-${TOOLS}/get_openerp_info.py}
cp /dev/null index.txt
#set -x
for p in ${@:-rental_* shipment*}; do
echo "processing ${p}..."
m=${p}/__manifest__.py
docdir=${p}/README
shtmldir=${p}/static/description
shtmlfn=${shtmldir}/index.html
descfn=${docdir}/DESCRIPTION.rst
historyfn=${docdir}/HISTORY.rst
configfn=${docdir}/CONFIGURATION.rst
usagefn=${docdir}/USAGE.rst
contribfn=${docdir}/CONTRIBUTORS.rst
mkdir -p ${docdir} || {
echo "error: cannot create ${docdir}, continuing with next package..."
continue
}
mkdir -p ${shtmldir} || {
echo "error: cannot create ${shtmldir}, continuing with next package..."
continue
}
if egrep -q '"name"|'"'name'" ${m}; then
name=$(${GET_MANIFEST_INFO} -f ${m} -a name -p '' | sed -e 's/^\.$//' -e 's/|//g')
else
echo "error: module name not found, continuing with next package..."
continue
fi
if egrep -q '"summary"|'"'summary'" ${m}; then
summary=$(${GET_MANIFEST_INFO} -f ${m} -a summary -p '' | sed -e 's/^\.$//' -e 's/|//g')
else
echo "error: module summary not found, continuing with next package..."
continue
fi
if egrep -q '"description"|'"'description'" ${m}; then
description=$(${GET_MANIFEST_INFO} -f ${m} -a description -p '' | sed -e 's/^\.$//' -e 's/|//g')
else
description='TODO'
fi
if egrep -q '"usage"|'"'usage'" ${m}; then
usage=$(${GET_MANIFEST_INFO} -f ${m} -a usage -p '' | sed -e 's/^\.$//' -e 's/|//g')
else
usage=''
fi
if egrep -q '"configuration"|'"'configuration'" ${m}; then
configuration=$(${GET_MANIFEST_INFO} -f ${m} -a configuration -p '' | sed -e 's/^\.$//' -e 's/|//g')
else
configuration=''
fi
if egrep -q '"contributors"|'"'contributors'" ${m}; then
contributors=$(${GET_MANIFEST_INFO} -f ${m} -a contributors -p '' | sed -e 's/^\.$//' -e 's/|//g')
else
contributors=''
fi
if egrep -q '"author"|'"'author'" ${m}; then
author=$(${GET_MANIFEST_INFO} -f ${m} -a author -p '' | sed -e 's/^\.$//' -e 's/|//g')
else
author=''
fi
{
echo ""
echo "Changelog"
echo "---------"
echo ""
git log --pretty=format:'%h %ad %ae %d %s' --date=iso -- ${p} | sed -e 's/^/- /' -e 's/\*/\\*/g'
if [[ "${p}" == rental_sale ]]; then
git log --pretty=format:'%h %ad %ae %d %s' --date=iso -- sale_rental | sed -e 's/^/- /' -e 's/\*/\\*/g'
fi
echo ""
} > ${historyfn}
{
echo "${name}"
echo "===================================================="
echo ""
echo "*This file has been generated on ${ds}. Changes to it will be overwritten.*"
echo ""
echo "Summary"
echo "-------"
echo ""
echo "${summary}"
echo ""
echo "Description"
echo "-----------"
echo ""
echo "${description}"
echo ""
} > ${descfn}
if [[ -n "${configuration}" ]]; then
{
echo ""
echo "Configuration"
echo "-------------"
echo ""
echo "${configuration}"
echo ""
} > ${configfn}
else
configfn=''
fi
if [[ -n "${usage}" ]]; then
{
echo ""
echo "Usage"
echo "-----"
echo ""
echo "${usage}"
echo ""
} > ${usagefn}
fi
if [[ -n "${author}" || -n "${contributors}" ]]; then
{
echo ""
echo "Contributors"
echo "------------"
echo ""
echo "${author}"
echo "${contributors}"
echo ""
} > ${contribfn}
fi
if [[ ${p} == 'rental_sale' ]]; then
allfn=${p}/README2.rst
else
allfn=${p}/README.rst
fi
cat ${descfn} ${configfn} ${usagefn} ${historyfn} > ${allfn}
echo "* [${p} (${name})](${p}/README.rst): ${summary}" >> index.txt
rst2html.py ${allfn} ${shtmlfn}
git add ${docdir}
git add ${shtmldir}
done
rm -f */*.tmp