-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathinvenio-code-browser
executable file
·78 lines (73 loc) · 2.94 KB
/
invenio-code-browser
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
#!/bin/sh
#
# Generates and publishes Invenio code browser pages. Assumes having
# installed Invenio locally first.
#
# Tibor Simko <[email protected]>
#
# Copyright (C) 2011 CERN
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
CODEBROWSERTMPDIR=/tmp/$(basename $0)-pages
[email protected]:/opt/websites/invenio-software.org/htdocs/code-browser
ACTION=$1
# config section:
CFG_INVENIO_PREFIX=${CFG_INVENIO_PREFIX:=/opt/invenio}
usage () {
echo "Usage: $0 [options]"
echo "Options:"
echo " --help print this help"
echo " --check-docstrings check overall docstrings compliance (rough only)"
echo " --generate-code-browser-pages generate Invenio code browser pages (locally)"
echo " --publish-code-browser-pages publish previsouly generated Invenio code browser pages (on the web)"
}
if [ "$ACTION" = "--help" ] || [ "$ACTION" = "-h" ]; then
usage
elif [ "$ACTION" = "--check-docstrings" ]; then
cd /tmp
for afile in ${CFG_INVENIO_PREFIX}/lib/python/invenio/*.py; do
epydoc $afile > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "[ERROR] Bad docstrings in ${afile}; won't be able to generate code browser pages."
fi
done
elif [ "$ACTION" = "--generate-code-browser-pages" ]; then
echo "[INFO] Preparing ${CODEBROWSERTMPDIR}..."
rm -rf $CODEBROWSERTMPDIR
mkdir -p $CODEBROWSERTMPDIR
echo "[INFO] Launching epydoc..."
epydoc --verbose \
--name="Invenio" \
--url="http://invenio-software.org/" \
--exclude='refextract' \
--output=$CODEBROWSERTMPDIR \
--debug \
invenio
cp -a $CODEBROWSERTMPDIR/frames.html $CODEBROWSERTMPDIR/index.html
echo "[INFO] Code browser pages are generated. Check them out in your browser via:"
echo "[INFO] conkeror file://${CODEBROWSERTMPDIR}/frames.html"
echo "[INFO] If OK, then publish these pages via $0 --publish-code-browser-pages."
elif [ "$ACTION" = "--publish-code-browser-pages" ]; then
echo "[INFO] Copying files onto ${CODEBROWSERTARGETDIR}..."
rsync -rlptDvz -e ssh \
--exclude '*~' \
--exclude 'Publish*' \
--delete \
${CODEBROWSERTMPDIR}/ ${CODEBROWSERTARGETDIR}
echo "[INFO] Code browser pages have been published."
else
echo "[ERROR] Please specify appropriate CLI option."
usage
exit 1
fi