[325] | 1 | #! /bin/sh |
---|
[186] | 2 | # |
---|
[325] | 3 | # module : |
---|
| 4 | # build idldoc documentations |
---|
| 5 | # |
---|
[123] | 6 | # update : |
---|
| 7 | # $Id$ |
---|
[327] | 8 | # fplod 2007-12-12T09:47:04Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 9 | # version |
---|
| 10 | # http://michaelgalloy.com/wp-content/uploads/2007/12/idldoc-3.0b4.zip |
---|
| 11 | # fplod 2007-12-11T09:14:04Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 12 | # version |
---|
| 13 | # http://michaelgalloy.com/wp-content/uploads/2007/12/idldoc-3.0b4-src.zip |
---|
| 14 | # ++ pb path |
---|
| 15 | # beginning of docbook templates writing (from html 3.0b3 tt files) |
---|
| 16 | # fplod 2007-12-10T09:28:11Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 17 | # test with gdl : pas possible car compatibility < 6.1 |
---|
[325] | 18 | # fplod 2007-12-04T09:21:18Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 19 | # version |
---|
| 20 | # http://michaelgalloy.com/wp-content/uploads/2007/12/idldoc-3.0b3.zip |
---|
| 21 | # pb parser if ; after ;- |
---|
| 22 | # ++ plus de param et keyword dans l'index |
---|
| 23 | # ++ pas w3c tilte au lieu de title, pas de charset, pas de alt, pas de summary |
---|
| 24 | # ++ css pas ok |
---|
| 25 | # ++ plus de @restrictions |
---|
| 26 | # fplod 2007-12-04T09:10:55Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 27 | # externalisation of idldoc issues from savesaxo.sh |
---|
| 28 | # previous release of idldoc was 2.0 |
---|
| 29 | # this tool can be checked by creating doc from Michael Galloy librayry |
---|
| 30 | # available on http://www.michaelgalloy.com/lib-docs/ |
---|
| 31 | # version |
---|
| 32 | # http://michaelgalloy.com/wp-content/uploads/2007/11/idldoc-3.0b1.zip |
---|
| 33 | # pas ok ne reconnait pas les @param, @keyword |
---|
| 34 | # |
---|
[86] | 35 | set -x |
---|
| 36 | set -u |
---|
[327] | 37 | # ++ test si idl (car gdl inutilisable) |
---|
| 38 | application=idl |
---|
[325] | 39 | assistant=0 |
---|
| 40 | transform=0 |
---|
| 41 | title="SAXO Documentation" # ++ parametre |
---|
| 42 | root="../../" |
---|
[327] | 43 | root="/Users/fplod/SAXO_DIR_ws/SRC/" #++ à cause du cd pour éviter expand_path |
---|
| 44 | #root="/usr/home/fplod/src/mglib/" # overriding root for test ++ |
---|
[86] | 45 | # |
---|
[327] | 46 | # |
---|
[325] | 47 | idldoc_dir="../idldoc/" # |
---|
[327] | 48 | idldoc_dir="/usr/home/fplod/src/idldoc-3.0b3/" # overriding idldoc_dir for ctest ++ |
---|
| 49 | #idldoc_dir="/usr/home/fplod/src/idldoc-3.0b4-src/" # overriding idldoc_dir for test ++ |
---|
| 50 | idldoc_dir="/usr/home/fplod/src/idldoc-3.0b4/" # overriding idldoc_dir for test ++ |
---|
| 51 | template_location=${idldoc_dir}/templates/ |
---|
| 52 | #++ pas fini |
---|
| 53 | #template_location=${idldoc_dir}/templates_dbk/ # overriding TEMPLATE_LOCATION++ |
---|
[86] | 54 | # |
---|
| 55 | # memorize current directory |
---|
| 56 | memopwd=$(pwd) # should be <working space>/SRC/Documentation/xmldoc |
---|
[325] | 57 | #------------------------------------------------------------------ |
---|
[100] | 58 | # |
---|
[325] | 59 | # build a idl file to launch idldoc |
---|
| 60 | output=../idldoc_html_output/ |
---|
| 61 | #++outputtmp=/tmp/idldoc_html_output${$}/ |
---|
| 62 | outputtmp=/tmp/idldoc_html_output/ |
---|
| 63 | log="/tmp/idldochtml_${$}.log" |
---|
| 64 | pro="/tmp/idldochtml_${$}.pro" |
---|
[327] | 65 | |
---|
| 66 | #+++ a remettre pour dbk template_location="${template_location}", $ |
---|
| 67 | # !path = expand_path('+' + '${idldoc_dir}') |
---|
| 68 | cd ${idldoc_dir} |
---|
| 69 | pwd |
---|
| 70 | read a |
---|
[325] | 71 | cat <<EOF > ${pro} |
---|
| 72 | idldoc,root="${root}",title="${title}", $ |
---|
| 73 | LOG_FILE="${log}", $ |
---|
| 74 | output="${outputtmp}", $ |
---|
[327] | 75 | template_location="${template_location}", $ |
---|
| 76 | COMMENT_STYLE="latex", $ |
---|
[325] | 77 | overview="../../overview", /statistics |
---|
| 78 | exit |
---|
[100] | 79 | EOF |
---|
[327] | 80 | more ${pro} |
---|
| 81 | read a |
---|
[325] | 82 | # launch idl with the file built above |
---|
[327] | 83 | IDL_STARTUP=${pro};${application} |
---|
[325] | 84 | /bin/rm ${pro} |
---|
[100] | 85 | # |
---|
[325] | 86 | if [ ${transform} -eq 1 ] |
---|
[86] | 87 | then |
---|
[325] | 88 | # In order to do not have to many revision in svn, we modify some |
---|
| 89 | # lines produced by idldoc : |
---|
| 90 | # - add Source link in each html file corresponding to a .pro file |
---|
| 91 | # example : |
---|
| 92 | # <td>Source</td> |
---|
| 93 | # will be replaced by |
---|
| 94 | # <td><a href="../../Calendar/caldat.pro" title="Source code of a file">Source</a></td> |
---|
[86] | 95 | # |
---|
[325] | 96 | # - remove date and time of idldoc production |
---|
| 97 | # examples : |
---|
| 98 | # <!-- Generated by IDLdoc 2.0 on Wed Jun 7 10:25:28 2006 --> |
---|
| 99 | # will be replaced by |
---|
| 100 | # <!-- Generated by IDLdoc 2.0 --> |
---|
| 101 | # <div id="tagline">Produced by IDLdoc 2.0 on Wed Jun 7 10:54:37 2006.</div |
---|
| 102 | # will be replaced by |
---|
| 103 | # <div id="tagline">Produced by IDLdoc 2.0</div> |
---|
| 104 | # <h2>Produced on Wed Jun 7 10:23:13 2006</h2> |
---|
| 105 | # will be delete |
---|
| 106 | # other lines will be deleted because the time is the time of checkout not |
---|
| 107 | # the time of revision. |
---|
| 108 | # the sequence of lines |
---|
| 109 | #<dl> |
---|
| 110 | # <dt>Last modification:</dt> |
---|
| 111 | # <dd>Fri Jun 2 11:46:24 2006</dd> |
---|
| 112 | # </dl> |
---|
| 113 | # should also be removed ++ je ne sais pas dire en sed la ligne |
---|
| 114 | # suivant l'occurence de Last modification |
---|
[86] | 115 | # |
---|
[325] | 116 | # count of directory levels in output |
---|
| 117 | # this count will be use to format relative path later |
---|
| 118 | nblev1=$(echo ${outputtmp} | sed -e "s@/\$@@" |awk -F "/" '{print NF}') |
---|
| 119 | # |
---|
| 120 | list_html_pro=$(find ${outputtmp} -name "*.html" -exec grep -l "<title>.*\.pro" {} \;) |
---|
| 121 | for file_html in ${list_html_pro} |
---|
| 122 | do |
---|
| 123 | # build the .pro file name |
---|
| 124 | bfile=$(basename ${file_html} .html) |
---|
| 125 | # retrieve the path of html file relative to memopwd (so relative to |
---|
| 126 | # output). This path will be used in "Source" link. |
---|
| 127 | nblev2=$(dirname ${file_html} | sed -e "s@/\$@@" | awk -F "/" '{print NF}') |
---|
| 128 | difflev=$((${nblev2} - ${nblev1})) |
---|
| 129 | if [ ${difflev} -ge 2 ] |
---|
| 130 | then |
---|
| 131 | ilev=1 |
---|
| 132 | reloutput_html=".." |
---|
| 133 | while [ ${ilev} -le ${difflev} ] |
---|
| 134 | do |
---|
| 135 | reloutput_html="${reloutput_html}/.." |
---|
| 136 | ilev=$(( ${ilev} + 1 )) |
---|
| 137 | done |
---|
| 138 | relpath_html=$(dirname ${file_html} | \ |
---|
| 139 | sed \ |
---|
| 140 | -e "s@${outputtmp}@${reloutput_html}@" \ |
---|
| 141 | -e "s@\$@/@") |
---|
| 142 | # echo "relpath ${relpath_html})" |
---|
| 143 | else |
---|
| 144 | relpath_html="./" |
---|
| 145 | fi |
---|
| 146 | # echo "relpath ${relpath_html}/${bfile}" |
---|
| 147 | sed \ |
---|
| 148 | -e "s@<td >Source<\/td>@<td><a href=\"${relpath_html}/${bfile}.pro\" title=\"Source code of a file\">Source<\/a><\/td>@" \ |
---|
| 149 | ${file_html} > ${file_html}_modify |
---|
| 150 | mv ${file_html}_modify ${file_html} |
---|
| 151 | done |
---|
| 152 | list_html=$(find ${outputtmp} -name "*.html") |
---|
| 153 | for file_html in ${list_html} |
---|
| 154 | do |
---|
| 155 | sed \ |
---|
| 156 | -e "s/\(Generated by IDLdoc 2.0\)\( on .*\)\( -->\)/\1\3/" \ |
---|
| 157 | -e "s/\(Produced by IDLdoc 2.0\)\( on .*\)\(\.<\/div>\)/\1\3/" \ |
---|
| 158 | -e "/<h2>Produced on/d" \ |
---|
| 159 | -e "/Last modification:/d" \ |
---|
| 160 | -e "/<dd>... ... .* ..:..:.. ....<\/dd>/d" \ |
---|
| 161 | -e 's@<div class="value">@<div class="preformat">@' \ |
---|
| 162 | -e 's/div\#file_comments {/div\#file_comments { white-space: pre;/' \ |
---|
| 163 | -e 's@^ <fixe>@<pre>@' \ |
---|
| 164 | -e 's@^ </fixe>@</pre>@' \ |
---|
| 165 | -e 's@xhtml-transitional@xhtml1-transitional@' \ |
---|
| 166 | ${file_html} > ${file_html}_modify |
---|
| 167 | mv ${file_html}_modify ${file_html} |
---|
| 168 | done |
---|
| 169 | # suppress ".html" in idldoc-index*.html in lines like |
---|
| 170 | # a parameter from the routine ./ReadWrite/idl-NetCDF/ncdf_read.html |
---|
| 171 | list_html=$(find ${outputtmp} -name "idldoc-index*.html") |
---|
| 172 | for file_html in ${list_html} |
---|
| 173 | do |
---|
| 174 | sed \ |
---|
| 175 | -e "s/\(a parameter from the routine \)\(.*\)\(.html\)/\1\2/" \ |
---|
| 176 | ${file_html} > ${file_html}_modify |
---|
| 177 | mv ${file_html}_modify ${file_html} |
---|
| 178 | done |
---|
| 179 | # replace <pro>ginette</pro> by a sequence like |
---|
| 180 | # <a href="./ginette.html">ginette</a> |
---|
| 181 | ./pro2href.sh -i ${outputtmp} -r ${outputtmp} -e pro |
---|
| 182 | status=${?} |
---|
| 183 | if [ ${status} -ne 0 ] |
---|
| 184 | then |
---|
| 185 | echo "eee : pb during ./pro2href.sh for <pro>...</pro>" |
---|
| 186 | exit 1 |
---|
[86] | 187 | fi |
---|
[325] | 188 | # replace <proidl>ginette</proidl> by a sequence like |
---|
| 189 | # <a href="./ginette.html">ginette</a> |
---|
| 190 | ./pro2href.sh -i ${outputtmp} -r ${IDL_DIR}/help/online_help -e proidl |
---|
| 191 | status=${?} |
---|
| 192 | if [ ${status} -ne 0 ] |
---|
[86] | 193 | then |
---|
[325] | 194 | echo "eee : pb during ./pro2href.sh for <proidl>...</proidl>" |
---|
| 195 | exit 1 |
---|
[86] | 196 | fi |
---|
[325] | 197 | fi # end of transform = 1 |
---|
[86] | 198 | # |
---|
[325] | 199 | echo "iii : you can see log file in ${log}" |
---|
| 200 | echo "iii : and look ${outputtmp}/idldoc-warnings.html#undoc" |
---|
[86] | 201 | # |
---|
[325] | 202 | if [ ${assistant} -eq 1 ] |
---|
[86] | 203 | then |
---|
[325] | 204 | # build a idl file to launch idldoc |
---|
| 205 | output=../idldoc_assistant_output/ |
---|
| 206 | log="/tmp/idldocassistant_${$}.log" |
---|
| 207 | pro="/tmp/idldocassistant_${$}.pro" |
---|
| 208 | cat <<EOF > ${pro} |
---|
| 209 | !path = expand_path('+' + '${idldoc_dir}') |
---|
| 210 | idldoc,root="${root}",title="${title}", $ |
---|
[111] | 211 | LOG_FILE="${log}", $ |
---|
[325] | 212 | output="${outputtmp}", overview='../../overview', /statistics, /embed, /assistant |
---|
[89] | 213 | exit |
---|
| 214 | EOF |
---|
[325] | 215 | # launch idl with the file built above |
---|
| 216 | IDL_STARTUP=${pro};${IDL_DIR}/bin/idl |
---|
| 217 | /bin/rm ${pro} |
---|
| 218 | # In order to do not have to many revision in svn, we modify some |
---|
| 219 | # lines produced by idldoc : |
---|
| 220 | # examples : |
---|
| 221 | # <!-- Generated by IDLdoc 2.0 on Wed Jun 7 10:25:28 2006 --> |
---|
| 222 | # will be replaced by |
---|
| 223 | # <!-- Generated by IDLdoc 2.0 --> |
---|
| 224 | # <p><font color="gray" size="-3"> Produced by IDLdoc 2.0 on Wed Sep 13 16:32:10 2006.</font></p> |
---|
| 225 | # will be replaced by |
---|
| 226 | # <p><font color="gray" size="-3"> Produced by IDLdoc 2.0</font></p> |
---|
| 227 | # <h2>Produced on Wed Jun 7 10:23:13 2006</h2> |
---|
| 228 | # will be delete |
---|
| 229 | # other lines will be deleted because the time is the time of checkout not |
---|
| 230 | # the time of revision. |
---|
| 231 | # the sequence of lines |
---|
| 232 | #<dl> |
---|
| 233 | # <dt>Last modification:</dt> |
---|
| 234 | # <dd>Fri Jun 2 11:46:24 2006</dd> |
---|
| 235 | # </dl> |
---|
| 236 | # should also be removed ++ je ne sais pas dire en sed la ligne |
---|
| 237 | # suivant l'occurence de Last modification |
---|
| 238 | # replace *_param_* in href attributes because anchors are badly written |
---|
| 239 | # with _keyword_ |
---|
| 240 | #++ -e 's@\(href="#_.*\)\(_param_\)\(.*"\)@\1_keyword_\3@g' \ # ++ pb global |
---|
| 241 | # ONLINE_HELP, book="../idldoc_assistant_output/idldoc-lib.adp", /full_path # won't work |
---|
| 242 | # encaspulate example content in <pre> </pre> in idldoc assistant outputs |
---|
| 243 | # Examples section is supposed to start with <h3>Examples</h3> |
---|
| 244 | # and end is before <h3>Version history</h3> |
---|
| 245 | list_html=$(find ${outputtmp} -name "*.html") |
---|
| 246 | for file_html in ${list_html} |
---|
| 247 | do |
---|
| 248 | sed \ |
---|
| 249 | -e "s/\(Generated by IDLdoc 2.0\)\( on .*\)\( -->\)/\1\3/" \ |
---|
| 250 | -e "s/\(Produced by IDLdoc 2.0\)\( on .*\)\(\.<\/font>\)/\1\3/" \ |
---|
| 251 | -e "/<h2>Produced on/d" \ |
---|
| 252 | -e "/Last modification:/d" \ |
---|
| 253 | -e "/<dd>... ... .* ..:..:.. ....<\/dd>/d" \ |
---|
| 254 | -e '/href/s@_param_@_keyword_@g' \ |
---|
| 255 | -e 's@<div class="value">@<div class="preformat">@' \ |
---|
| 256 | -e 's/div\#file_comments {/div\#file_comments { white-space: pre;/' \ |
---|
| 257 | -e 's@^ <fixe>@<pre>@' \ |
---|
| 258 | -e 's@^ </fixe>@</pre>@' \ |
---|
| 259 | -e "s@<h3>Examples</h3>@<h3>Examples</h3><pre>@" \ |
---|
| 260 | -e "s@<h3>Version history</h3>@</pre><h3>Version history</h3>@" \ |
---|
| 261 | ${file_html} > ${file_html}_modify |
---|
| 262 | mv ${file_html}_modify ${file_html} |
---|
| 263 | done |
---|
| 264 | # replace <pro>ginette</pro> by a sequence like |
---|
| 265 | # <a href="./ginette.html">ginette</a> |
---|
| 266 | ./pro2href.sh -i ${outputtmp} -r ${outputtmp} -e pro |
---|
| 267 | status=${?} |
---|
| 268 | if [ ${status} -ne 0 ] |
---|
| 269 | then |
---|
| 270 | echo "eee : pb during ./pro2href.sh for <pro>...</pro>" |
---|
| 271 | exit 1 |
---|
| 272 | fi |
---|
| 273 | # replace <proidl>ginette</proidl> by a sequence like |
---|
| 274 | # <a href="./ginette.html">ginette</a> |
---|
| 275 | ./pro2href.sh -i ${outputtmp} -r ${IDL_DIR}/help/online_help -e proidl |
---|
| 276 | status=${?} |
---|
| 277 | if [ ${status} -ne 0 ] |
---|
| 278 | then |
---|
| 279 | echo "eee : pb during ./pro2href.sh for <proidl>...</proidl>" |
---|
| 280 | exit 1 |
---|
| 281 | fi |
---|
| 282 | # add the directory-overview.html from dir-files.html in idldoc_html_output |
---|
| 283 | list_html=$(find ../idldoc_html_output -name dir-files.html) |
---|
| 284 | for file_html in ${list_html} |
---|
| 285 | do |
---|
| 286 | fout=../idldoc_assistant_output/${file_html#../idldoc_html_output/*} |
---|
| 287 | fout=${fout%/*}/directory-overview.html |
---|
| 288 | cp ${file_html} ${fout} |
---|
| 289 | done |
---|
| 290 | # copy listings.css (needed by directory-overview.html files) |
---|
| 291 | cp ../idldoc/resource/listings.css ${outputtmp} |
---|
| 292 | # add an id in idldoc-lib.adp |
---|
| 293 | cat << EOF > /tmp/adp_modification |
---|
[189] | 294 | <!-- \$Id\$ --> |
---|
| 295 | EOF |
---|
[325] | 296 | sed -e "/<\/profile>/r /tmp/adp_modification" \ |
---|
| 297 | ../idldoc_assistant_output/idldoc-lib.adp > \ |
---|
| 298 | ../idldoc_assistant_output/idldoc-lib.adp_${$} |
---|
| 299 | mv ../idldoc_assistant_output/idldoc-lib.adp_${$} \ |
---|
| 300 | ../idldoc_assistant_output/idldoc-lib.adp |
---|
| 301 | rm /tmp/adp_modification |
---|
| 302 | echo "iii : you can see log file in ${log}" |
---|
| 303 | echo "iii : and look ${outputtmp}/idldoc-warnings.html#undoc" |
---|
| 304 | # check that the number of existing html files for each .pro file is 2! |
---|
| 305 | for i in $( find ../.. -name "*.pro" ) |
---|
| 306 | do |
---|
| 307 | nhtml=$( find ../.. -name $( basename ${i} .pro ).html | wc -l ) |
---|
| 308 | if [ ${nhtml} -ne 2 ] |
---|
[195] | 309 | then |
---|
[291] | 310 | echo "ERROR there is not 2 $( basename ${i} .pro ).html files" |
---|
[233] | 311 | find ../.. -name $( basename ${i} .pro ).html |
---|
[195] | 312 | echo |
---|
[325] | 313 | fi |
---|
| 314 | done |
---|
[86] | 315 | # |
---|
[87] | 316 | fi |
---|
[325] | 317 | # copy of temporary outputs on final directory |
---|
| 318 | # ++ if transform |
---|
| 319 | #++mv ${outputtmp} ${output} # ++ rsync |
---|
| 320 | echo "look at ${outputtmp}/index.html" #++ |
---|
| 321 | # end |
---|
| 322 | exit 0 |
---|