Newer
Older
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/bin/sh -e
do_html_cleanup()
{
sed -e 's/id="current"/class="current"/' \
| tidy -ascii -q --wrap 0 --show-warnings no --fix-uri no \
| sed -e 's/name="\([^"]*\)"\([^>]*\) id="\1"/name="\1"\2/g' \
| xsltproc --novalid --nonet --html --stringparam topdir $TOPDIR "$base/html-munge.xsl" -
}
###########################################################################
name="`basename "$0"`"; #`"
base="`dirname "$0"`"; base="`cd "$base"; pwd`" #`"
TEMP=`getopt -n $name -o '' -l html,tagfile,tagfile-name:,tagfiles:,output-dir:,html-dir: -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
eval set -- "$TEMP"
tagxsl="$base/tag-munge.xsl"
html="NO"; tagfile="NO"; tagfile_name=""; tagfiles=""; output_dir="doc"; html_dir="html"
while true; do
case "$1" in
--html)
html="YES" ; shift ;;
--tagfile)
tagfile="YES" ; shift ;;
--tagfile-name)
tagfile_name="$2"; shift 2 ;;
--tagfiles)
for f in $2; do
f="`readlink -mn "$f"`" #`"
tagfiles="$tagfiles${tagfiles:+ }$f"
done
shift 2
;;
--output-dir)
output_dir="$2"; shift 2 ;;
--html-dir)
html_dir="$2"; shift 2 ;;
--)
shift; break ;;
*)
echo "Internal error: $*"; exit 1 ;;
esac
done
if [ -z "$1" ]; then
cat <<EOF
Usage:
$name
[--html]
[--tagfile]
[--tagfile-name=<name>]
[--tagfiles=<files>]
[--output-dir=<dir>]
[--html-dir=<dir>]
<doxyfile-or-dir>
EOF
exit 1
fi
if [ "$tagfile" == "YES" -a -z "$tagfile_name" ]; then
echo "--tagfile-name is required with --tagfile"
exit 1
fi
doxydir="$1"
if [ -f "$doxydir" ]; then
doxydir="`dirname "$doxydir"`" #`"
fi
doxydir="`readlink -mn "$doxydir"`" #`"
###########################################################################
# Create relative path from absolute directory $1 to absolute path $2
relpath()
{
local src="${1#/}"
local dst="${2#/}"
while true; do
srcd="${src%%/*}"
dstd="${dst%%/*}"
if [ "$srcd" = "$dstd" ]; then
src="${src#*/}"
dst="${dst#*/}"
else
break
fi
done
echo "`echo "$src" | sed -e "s/[^\/]*/../g"`/$dst" # `"
}
# Log executed commands
cmd()
{
echo "+" "$@"
"$@"
}
html_cleanup()
{
mv "$1" "${1}.orig"
do_html_cleanup <"${1}.orig" >"$1"
}
###########################################################################
## Find $TOPDIR
cd "$doxydir"
while [ ! -r "SConstruct" -a "`pwd`" != "/" ]; do cd ..; done
if [ ! -r "SConstruct" ]; then
echo "topdir not found"
exit 1;
fi
TOPDIR="`pwd`";
cd "$doxydir"
## Remove tagfile_name from list of tagfiles
if [ -n "$tagfile_name" ]; then
tagfile_name="`readlink -mn "$output_dir/$tagfile_name"`" #`"
x="$tagfiles"; tagfiles=""
for f in $x; do
if [ "$f" != "$tagfile_name" ]; then
tagfiles="$tagfiles${tagfiles:+ }$f"
fi
done
fi
## Call doxygen proper
generate_tagfile=""
if [ "$tagfile" == "YES" ]; then
generate_tagfile="$tagfile_name"
fi
export TOPDIR html tagfile tagfile_name tagfiles output_dir html_dir generate_tagfile
cmd ${DOXYGEN:-doxygen}
## Clean up tagfile, if generated
if [ "$tagfile" == "YES" ]; then
mv "$tagfile_name" "${tagfile_name}.orig"
cmd xsltproc --novalid --nonet -o "$tagfile_name" "$tagxsl" "${tagfile_name}.orig"
fi
## Call installdox
if [ -n "$tagfiles" ]; then
args=""
for f in $tagfiles; do
n="`basename "$f"`" #`"
d="`dirname "$f"`" #`"
url="`relpath "$doxydir/$output_dir/$html_dir" "$d/$html_dir"`" #`"
args="$args${args:+ }-l $n@$url"
done
(
cd "./$output_dir/$html_dir"
cmd "./installdox" $args
)
fi
## Postprocess html files, if generated
if [ "$html" == "YES" ]; then
for h in "$doxydir/$output_dir/$html_dir"/*.html; do
cmd html_cleanup "$h"
done
fi