Jpp  master_rocky-40-g5f0272dcd
the software that should make you happy
doxygen.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 #
3 #--------------------------------------------------------------------------------------
4 #
5 # Utility script for generation of HTML Doxygen main page.
6 #
7 #--------------------------------------------------------------------------------------
8 # \author mdejong
9 #
10 script=${0##*/}
11 
12 if [ -z $JPP_DIR ]; then
13  echo "Variable JPP_DIR undefined."
14  exit 1
15 fi
16 
17 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
18 
19 if do_usage $*; then
20  usage "$script"
21 fi
22 
23 setopt +o nomatch
24 
25 set_variable NUMBER_OF_COLUMNS 3
26 
27 #
28 function findapps()
29 {
30  find $* -mindepth 1 -executable ! -regex ".*\.\‍(\‍(\|c\|z\‍)sh\|py\‍)" -printf "%f\n" | sort
31 }
32 
33 #
34 function findscripts()
35 {
36  find $* -mindepth 1 -executable -regex ".*\.\‍(\‍(\|c\|z\‍)sh\|py\‍)" -printf "%f\n" | sort
37 }
38 
39 #
40 function findexamples()
41 {
42  find $* -mindepth 1 -executable | sort
43 }
44 
45 #
46 # Method to get file name of source code.
47 #
48 # \param 1 executable file
49 # \return source file
50 #
51 function get_source()
52 {
53  file=`which $1 2> /dev/null`
54 
55  if [[ -n "${file}" && -x ${file} ]]; then
56  if [[ $file == *\.((|c|z)sh|py) ]]; then
57  source=${file}
58  else
59  source=`${file} -v 2> /dev/null | sed -n 's/source: *//p'`
60  fi
61  else
62  source=$1
63  fi
64 
65  echo ${source:a}
66 }
67 
68 
69 echo "/**"
70 echo " * \mainpage Documentation"
71 echo " * \htmlonly"
72 echo " * <style>"
73 echo " * 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}; }"
74 echo " * </style>"
75 
76 # Documents
77 
78 echo " * <hr>"
79 echo " * <h2>Documents</h2>"
80 echo " * <ul class=\"b\">"
81 for file in `ls ${JPP_DOC}/*`; do
82  if [ -f ${file} ]; then
83  echo " * <li><a href=\"${file##*/}\">${file##*/}</a></li>"
84  fi
85 done
86 echo " * </ul>"
87 
88 
89 # Applications header
90 
91 echo " * <hr>"
92 echo " * <h2>Applications</h2>"
93 echo " * <ul class=\"b\">"
94 for file in `findapps ${JPP_BIN}`; do
95  echo " * <li><a href=\"#${file}\">${file}</a></li>"
96 done
97 echo " * </ul>"
98 
99 
100 # Scripts header
101 
102 echo " * <hr>"
103 echo " * <h2>Scripts</h2>"
104 echo " * <ul class=\"b\">"
105 for file in `findscripts ${JPP_BIN}`; do
106  echo " * <li><a href=\"#${file}\">${file}</a></li>"
107 done
108 echo " * </ul>"
109 
110 
111 # Examples header
112 
113 echo " * <hr>"
114 echo " * <h2>Examples</h2>"
115 echo " * <ul class=\"b\">"
116 for dir in `ls $JPP_DIR/examples`; do
117 
118  if [[ -d $JPP_DIR/examples/${dir} ]]; then
119  echo " * <li><a href=\"#examples/${dir}\">${dir}</a></li>"
120  fi
121 done
122 echo " * </ul>"
123 
124 
125 # Applications data
126 
127 for file in `findapps ${JPP_BIN}`; do
128 
129  source=`get_source ${file}`
130 
131  echo " * <hr>"
132  echo " * <h4 id=\"${file}\">"
133  if [[ -n "${source}" ]]; then
134  if (`ls $JPP_DIR/examples/*/${source:t} >& /dev/null`); then
135  source=${source##${JPP_DIR:a}/}
136  else
137  source=${source:t}
138  fi
139  echo " * \\\\endhtmlonly"
140  echo " * ${source}"
141  echo " * \htmlonly"
142  else
143  echo " * ${file}"
144  fi
145  echo " * </h4>"
146  echo " * <pre>"
147  ${file} -h! 2> /dev/null | sed 's/</\&lt;/g;s/>/\&gt;/g'
148  echo " * </pre>"
149  echo " * <a href="#top">Go back to top of page.</a>"
150 done
151 
152 
153 # Scripts data
154 
155 for file in `findscripts ${JPP_BIN}`; do
156 
157  source=`eval ls $JPP_DIR/software/*/$file`
158 
159  echo " * <hr>"
160  echo " * <h4 id=\"${file}\">"
161  if [[ -n "${source}" ]]; then
162  if (`ls $JPP_DIR/examples/*/${source:t} >& /dev/null`); then
163  source=${source##${JPP_DIR:a}/}
164  else
165  source=${source:t}
166  fi
167  echo " * \\\\endhtmlonly"
168  echo " * ${source}"
169  echo " * \htmlonly"
170  else
171  echo " * ${file}"
172  fi
173  echo " * </h4>"
174  echo " * <pre>"
175  ${file} -h! 2> /dev/null | sed 's/</\&lt;/g;s/>/\&gt;/g'
176  echo " * </pre>"
177  echo " * <a href="#top">Go back to top of page.</a>"
178 done
179 
180 
181 # Examples data
182 
183 for dir in `ls $JPP_DIR/examples`; do
184 
185  if [[ -d $JPP_DIR/examples/${dir} ]]; then
186 
187  echo " * <hr>"
188  echo " * <h4 id=\"examples/${dir}\">${dir}</h4>"
189  echo " * <ul class=\"b\">"
190  for file in `findexamples $JPP_DIR/examples/${dir}`; do
191  echo " * <li><a href=\"#${file}\">${file:t}</a></li>"
192  done
193  echo " * </ul>"
194  echo " * <a href="#top">Go back to top of page.</a>"
195 
196  for file in `findexamples $JPP_DIR/examples/${dir}/`; do
197 
198  if [[ ! $file = *.sh && ! $file = *.csh ]]; then
199  source=`get_source ${file}`
200  else
201  source=$file
202  fi
203 
204  echo " * <hr>"
205  echo " * <h4 id=\"${file}\">"
206  if [[ -n "${source}" ]]; then
207  if (`ls ${JPP_DIR}/software/*/${source:t} >& /dev/null` || `ls ${JPP_DIR}/examples/^${dir}/${source:t} >& /dev/null`); then
208  source=${source##${JPP_DIR:a}/}
209  else
210  source=${source:t}
211  fi
212  echo " * \\\\endhtmlonly"
213  echo " * ${source}"
214  echo " * \htmlonly"
215  else
216  echo " * ${file}"
217  fi
218  echo " * </h4>"
219  echo " * <pre>"
220  ${file} -h! 2>&1 | sed 's/</\&lt;/g;s/>/\&gt;/g'
221  echo " * </pre>"
222  echo " * <a href="#top">Go back to top of page.</a>"
223  done
224  fi
225 done
226 
227 echo " * \\\\endhtmlonly"
228 echo " */"