Jpp 20.0.0-195-g190c9e876
the software that should make you happy
Loading...
Searching...
No Matches
doxygen.sh
Go to the documentation of this file.
1#!/usr/bin/env zsh
2#
3#--------------------------------------------------------------------------------------
4#
5# Utility script for generation of HTML Doxygen main page.
6#
7#--------------------------------------------------------------------------------------
8# \author mdejong
9#
10script=${0##*/}
11
12if [ -z $JPP_DIR ]; then
13 echo "Variable JPP_DIR undefined."
14 exit 1
15fi
16
17source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
18
19if do_usage $*; then
20 usage "$script"
21fi
22
23setopt +o nomatch
24
25set_variable NUMBER_OF_COLUMNS 3
26set_variable WORKDIR `mktemp -d ${TMPDIR:-/tmp}/XXXXXX`
27
28#
29function findapps()
30{
31 find $* -mindepth 1 -executable ! -regex ".*\.\‍(\‍(\|c\|z\‍)sh\|py\‍)" -printf "%f\n" | sort
32}
33
34#
35function findscripts()
36{
37 find $* -mindepth 1 -executable -regex ".*\.\‍(\‍(\|c\|z\‍)sh\|py\‍)" -printf "%f\n" | sort
38}
39
40#
41function findexamples()
42{
43 find $* -mindepth 1 -executable | sort
44}
45
46#
47# Method to get file name of source code.
48#
49# \param 1 executable file
50# \return source file
51#
52function get_source()
53{
54 file=`which $1 2> /dev/null`
55
56 if [[ -n "${file}" && -x ${file} ]]; then
57 if [[ $file == *\.((|c|z)sh|py) ]]; then
58 source=${file}
59 else
60 source=`${file} -v 2> /dev/null | sed -n 's/source: *//p'`
61 fi
62 else
63 source=$1
64 fi
65
66 echo ${source:a}
67}
68
69
70echo "/**"
71echo " * \mainpage Documentation"
72echo " * \htmlonly"
73echo " * <style>"
74echo " * ul.b { list-style-type: none; counter-reset: section; columns: ${NUMBER_OF_COLUMNS}; -moz-column-count: ${NUMBER_OF_COLUMNS}; -webkit-column-count: ${NUMBER_OF_COLUMNS}; column-count: ${NUMBER_OF_COLUMNS}; }"
75echo " * </style>"
76
77# Documents
78
79echo " * <hr>"
80echo " * <h2>Documents</h2>"
81echo " * <ul class=\"b\">"
82for file in `ls ${JPP_DOC}/*`; do
83 if [ -f ${file} ]; then
84 echo " * <li><a href=\"${file##*/}\">${file##*/}</a></li>"
85 fi
86done
87echo " * </ul>"
88
89
90# Applications header
91
92echo " * <hr>"
93echo " * <h2>Applications</h2>"
94echo " * <ul class=\"b\">"
95for file in `findapps ${JPP_BIN}`; do
96 echo " * <li><a href=\"#${file}\">${file}</a></li>"
97done
98echo " * </ul>"
99
100
101# Scripts header
102
103echo " * <hr>"
104echo " * <h2>Scripts</h2>"
105echo " * <ul class=\"b\">"
106for file in `findscripts ${JPP_BIN}`; do
107 echo " * <li><a href=\"#${file}\">${file}</a></li>"
108done
109echo " * </ul>"
110
111
112# Examples header
113
114echo " * <hr>"
115echo " * <h2>Examples</h2>"
116echo " * <ul class=\"b\">"
117for dir in `ls $JPP_DIR/examples`; do
118
119 if [[ -d $JPP_DIR/examples/${dir} ]]; then
120 echo " * <li><a href=\"#examples/${dir}\">${dir}</a></li>"
121 fi
122done
123echo " * </ul>"
124
125
126# Applications data
127
128function makeapp()
129{
130 file=$1
131
132 source=`get_source ${file}`
133
134 echo " * <hr>"
135 echo " * <h4 id=\"${file}\">"
136 if [[ -n "${source}" ]]; then
137 if (`ls $JPP_DIR/examples/*/${source:t} >& /dev/null`); then
138 source=${source##${JPP_DIR:a}/}
139 else
140 source=${source:t}
141 fi
142 echo " * \\\\endhtmlonly"
143 echo " * ${source}"
144 echo " * \htmlonly"
145 else
146 echo " * ${file}"
147 fi
148 echo " * </h4>"
149 echo " * <pre>"
150 ${file} -h! 2> /dev/null | sed 's/</\&lt;/g;s/>/\&gt;/g'
151 echo " * </pre>"
152 echo " * <a href="index.html">Go back to main page.</a>"
153}
154
155FS=()
156
157for file in `findapps ${JPP_BIN}`; do
158
159 makeapp $file > $WORKDIR/${file:t}.txt &
160
161 FS+=(${file:t}.txt)
162done
163
164if (( ${#FS} > 0 )); then
165
166 wait
167
168 cat $WORKDIR/${^FS}
169 rm -f $WORKDIR/${^FS} >& /dev/null
170fi
171
172
173# Scripts data
174
175function makescript()
176{
177 file=$1
178
179 source=`eval ls $JPP_DIR/software/*/$file`
180
181 echo " * <hr>"
182 echo " * <h4 id=\"${file}\">"
183 if [[ -n "${source}" ]]; then
184 if (`ls $JPP_DIR/examples/*/${source:t} >& /dev/null`); then
185 source=${source##${JPP_DIR:a}/}
186 else
187 source=${source:t}
188 fi
189 echo " * \\\\endhtmlonly"
190 echo " * ${source}"
191 echo " * \htmlonly"
192 else
193 echo " * ${file}"
194 fi
195 echo " * </h4>"
196 echo " * <pre>"
197 ${file} -h! 2> /dev/null | sed 's/</\&lt;/g;s/>/\&gt;/g'
198 echo " * </pre>"
199 echo " * <a href="index.html">Go back to main page.</a>"
200}
201
202FS=()
203
204for file in `findscripts ${JPP_BIN}`; do
205
206 makescript $file > $WORKDIR/${file:t}.txt &
207
208 FS+=(${file:t}.txt)
209done
210
211if (( ${#FS} > 0 )); then
212
213 wait
214
215 cat $WORKDIR/${^FS}
216 rm -f $WORKDIR/${^FS} >& /dev/null
217fi
218
219
220# Examples data
221
222function makeexample()
223{
224 file=$1
225
226 if [[ ! $file = *.sh && ! $file = *.csh ]]; then
227 source=`get_source ${file}`
228 else
229 source=$file
230 fi
231
232 echo " * <hr>"
233 echo " * <h4 id=\"${file}\">"
234 if [[ -n "${source}" ]]; then
235 if (`ls ${JPP_DIR}/software/*/${source:t} >& /dev/null`); then
236 source=${source##${JPP_DIR:a}/}
237 elif (( `ls ${JPP_DIR}/examples/*/${source:t} | wc -l` > 1 )); then
238 source=${source##${JPP_DIR:a}/examples/}
239 else
240 source=${source:t}
241 fi
242 echo " * \\\\endhtmlonly"
243 echo " * ${source}"
244 echo " * \htmlonly"
245 else
246 echo " * ${file}"
247 fi
248 echo " * </h4>"
249 echo " * <pre>"
250 ${file} -h! 2>&1 | sed 's/</\&lt;/g;s/>/\&gt;/g'
251 echo " * </pre>"
252 echo " * <a href="index.html">Go back to main page.</a>"
253}
254
255for dir in `ls $JPP_DIR/examples`; do
256
257 if [[ -d $JPP_DIR/examples/${dir} ]]; then
258
259 echo " * <hr>"
260 echo " * <h4 id=\"examples/${dir}\">${dir}</h4>"
261 echo " * <ul class=\"b\">"
262 for file in `findexamples $JPP_DIR/examples/${dir}`; do
263 echo " * <li><a href=\"#${file}\">${file:t}</a></li>"
264 done
265 echo " * </ul>"
266 echo " * <a href="index.html">Go back to main page.</a>"
267
268 FS=()
269
270 for file in `findexamples $JPP_DIR/examples/${dir}/`; do
271
272 makeexample $file > $WORKDIR/${file:t}.txt &
273
274 FS+=(${file:t}.txt)
275 done
276
277 if (( ${#FS} > 0 )); then
278
279 wait
280
281 cat $WORKDIR/${^FS}
282 rm -f $WORKDIR/${^FS} >& /dev/null
283 fi
284 fi
285done
286
287
288echo " * \\\\endhtmlonly"
289echo " */"
290
291rm -rf $WORKDIR >& /dev/null