source: trunk/SRC/Documentation/xmldoc/doidldoc.sh @ 412

Last change on this file since 412 was 412, checked in by pinsard, 15 years ago

draft for docompileall.sh, not yet in production

  • Property svn:executable set to *
  • Property svn:keyword set to Id
  • Property svn:keywords set to Id
File size: 14.2 KB
Line 
1#! /bin/sh
2#
3#+
4#
5# NAME
6# ====
7#
8# idldoc.sh - build idldoc documentations
9#
10# SYNOPSYS
11# ========
12#
13# ``doidldoc.sh -i indir -t title -o outdir -idldoc_version idldoc_version -idldoc_dir idldoc_dir``
14#
15# DESCRIPTION
16# ===========
17#
18# Produce HTML files from IDL sources using idldoc.
19#
20# -i directory input
21# -t title
22# -o directory output
23# -idldoc_version idldoc_version
24# -idldoc_dir idldoc_dir
25#
26# Two pass : first *classic* idldoc then some home made transformation to avoid
27# for example version of idldoc on each HTML files.
28#
29# The first pass produce files in /tmp/idldoc_output_${$}/ directory.
30#
31# At the end the result is in ``outdir``.
32#
33#
34# By default, embedded ``idldoc`` 2.0 in SAXO is used.
35#
36# You can specified an other ``idldoc`` implentation by specify directory and
37# version using *idldoc_dir* and *idldoc_version*.
38#
39# Be warned that assitant help is only available with ``idldoc 2.0``.
40#
41# CAUTIONS
42# ========
43#
44# SAXO_DIR must be set. The value should be the directory where
45# SAXO is available.
46#
47# for example, if you work at LOCEAN and work with default SAXO,
48# SAXO_DIR=/usr/home/smasson/SAXO_DIR/.
49#
50# For working in progress, you should checkout SAXO on a personnal
51# directory and set SAXO_DIR to the working space.
52#
53# example for me : SAXO_DIR=${HOME}/SAXO_DIR_ws/
54#
55# EXAMPLES
56# ========
57#
58# Results can be seen be opening a browser on /tmp/idldoc_html_output/index.html
59#
60# To produce SAXO HTML outputs :
61# ::
62#
63# $ cd SAXO_ws/SRC/Documentation/xmldoc/
64# $ ${SAXO_DIR}/SRC/Documentation/xmldoc/doidldoc.sh -i ../.. -t "SAXO Documentation" -o ./idldoc_html_output/
65#
66# To produce VARAMMA HTML outputs :
67# ::
68#
69# $ cd /usr/home/fplod/incas/varamma/varamma_ws/
70# $ ${SAXO_DIR}/SRC/Documentation/xmldoc/doidldoc.sh -i . -t "VARAMMA Documentation" -o /tmp/idldoc_html_output/
71#
72# TODO
73# ====
74#
75# ++ pb PATH introduire SAXO_PATH
76# can be solved with:
77# ::
78#
79# $ export PATH=${HOME}/SAXO_DIR/SRC/Documentation/xmldoc/:${PATH}
80#
81# ++ pb avec IDL_DIR pas tjs positionné
82# can be solved for linux with
83# ::
84#
85# $ export IDL_DIR=/usr/local_linux/idl/
86#
87# or for MacOSX with
88# ::
89#
90# $ export IDL_DIR=/usr/local_macosx/idl//idl_6.2/idl_6.2/
91#
92#
93# ++ choix de la version de idldoc et consequences sur assistant
94#
95# ++ choix de la version de IDL et consequences sur assistant et lien sur
96# doc idl
97#
98# SEE ALSO
99# ========
100#
101# idldoc++ lien
102#
103# EVOLUTIONS
104# ==========
105#
106# $Id$
107#
108# - fplod 20091110T151839Z aedon.locean-ipsl.upmc.fr (Darwin)
109#   
110#   * add CAUTIONS about SAXO_DIR environment variable
111#     and usage in EXAMPLES
112#
113# - ++
114#
115# * add idldoc_version and idldoc_dir parameters
116# idldoc version is usefull because parameters of ``idldoc``
117# have been modified (see ``CHARSET`` in 3.1.1.).
118#
119# ``idldoc`` release can not be guessed
120#
121# - fplod 2008-08-11T12:57:48Z aedon.locean-ipsl.upmc.fr (Darwin)
122#
123# * comments in this file in ReST format
124# * add ``-i``, ``-t`` and ``-o`` parameters
125#
126# - fplod 2008-06-20T13:07:59Z aedon.locean-ipsl.upmc.fr (Darwin)
127#
128# * evaluation version 3.1.1
129#
130# we are not yet still ready to migrate to rst format because of lack of
131# assistant transformation independant of IDLdoc release (at least
132# between 2. and 3.)
133#
134# - fplod 2008-01-10T08:13:41Z aedon.locean-ipsl.upmc.fr (Darwin)
135#
136# * version http://cookbook.idldev.com/idldoc-3.0rc2.zip
137#
138# - fplod 2008-01-03T09:59:18Z aedon.locean-ipsl.upmc.fr (Darwin)
139#
140# * version http://cookbook.idldev.com/idldoc-3.0rc1.zip
141#
142# - fplod 2007-12-12T09:47:04Z aedon.locean-ipsl.upmc.fr (Darwin)
143#
144# * version http://michaelgalloy.com/wp-content/uploads/2007/12/idldoc-3.0b4.zip
145#
146# - fplod 2007-12-11T09:14:04Z aedon.locean-ipsl.upmc.fr (Darwin)
147#
148# * version http://michaelgalloy.com/wp-content/uploads/2007/12/idldoc-3.0b4-src.zip
149# * ++ pb path
150# * beginning of docbook templates writing (from html 3.0b3 tt files)
151#
152# - fplod 2007-12-10T09:28:11Z aedon.locean-ipsl.upmc.fr (Darwin)
153#
154# * test with gdl : pas possible car compatibility < 6.1
155#
156# - fplod 2007-12-04T09:21:18Z aedon.locean-ipsl.upmc.fr (Darwin)
157#
158# * version http://michaelgalloy.com/wp-content/uploads/2007/12/idldoc-3.0b3.zip
159# * pb parser if ; after ;-
160# * ++ plus de param et keyword dans l'index
161# * ++ pas w3c tilte au lieu de title, pas de charset, pas de alt, pas de summary
162# * ++ css pas ok
163# * ++ plus de @restrictions
164#
165# - fplod 2007-12-04T09:10:55Z aedon.locean-ipsl.upmc.fr (Darwin)
166#
167# * externalisation of idldoc issues from savesaxo.sh
168# * previous release of idldoc was 2.0
169# * this tool can be checked by creating doc from Michael Galloy librayry
170# available on http://www.michaelgalloy.com/lib-docs/
171# * version http://michaelgalloy.com/wp-content/uploads/2007/11/idldoc-3.0b1.zip
172# * pas ok ne reconnait pas les @param, @keyword
173#-
174#
175system=$(uname)
176case "${system}" in
177AIX|IRIX64)
178 echo " www : no specific posix checking"
179;;
180*)
181 set -o posix
182;;
183esac
184#
185command=$(basename ${0})
186log_date=$(date -u +"%Y%m%dT%H%M%SZ")
187#
188usage=" Usage : ${command} -i indir -t title -o outdir [-idldoc_dir idldoc_dir -idldoc_version idldoc_version]"
189#
190# default ++ pas encore en parametre
191assistant=0
192#assistant=1
193transform=1
194command_dir=$(dirname ${0})
195idldoc_dir="${command_dir}/../idldoc/"
196idldoc_version="2.0"
197unset command_dir
198
199#idldoc_dir="/usr/home/fplod/src/idldoc-3.1.1/" # overriding idldoc_dir for test ++
200#
201minargcount=4
202if [ ${#} -lt ${minargcount} ]
203then
204 echo "eee : not enought arguments"
205 echo "${usage}"
206 exit 1
207fi
208#
209while [ ! -z "${1}" ] # ++ pb bash
210do
211 case ${1} in
212 -i)
213 indir=${2}
214 shift
215 ;;
216 -t)
217 title=${2}
218 shift
219 ;;
220 -o)
221 outdir=${2}
222 shift
223 ;;
224 -idldoc_dir)
225 idldoc_dir=${2}
226 shift
227 ;;
228 -idldoc_version)
229 idldoc_version=${2}
230 shift
231 ;;
232 -h)
233 echo "${usage}"
234 exit 0
235 ;;
236 *) # other choice
237 echo "${usage}"
238 exit 1
239 ;;
240 esac
241 shift # next flag
242done
243#
244set -u
245#
246# ++ test si IDL (car GDL inutilisable)
247application=idl
248#
249# memorize current directory
250memopwd=$(pwd) # should be <working space>/SRC/Documentation/xmldoc
251#
252# build a IDL file to launch idldoc
253outputtmp=/tmp/idldoc_output${$}/
254idldoc_log="/tmp/idldochtml_${$}.log"
255pro="/tmp/idldochtml_${$}.pro"
256#
257cd ${idldoc_dir}
258case ${idldoc_version} in
259 3.1.1)
260 cat << EOF > ${pro}
261!path = expand_path('+' + '${idldoc_dir}')
262idldoc,root="${indir}",title="${title}", $
263CHARSET="ISO-8859-15", $
264LOG_FILE="${idldoc_log}", $
265output="${outputtmp}", $
266overview="../../overview", /statistics
267exit
268EOF
269 ;;
270 2.0)
271 cat << EOF > ${pro}
272!path = expand_path('+' + '${idldoc_dir}')
273idldoc,root="${indir}",title="${title}", $
274LOG_FILE="${idldoc_log}", $
275output="${outputtmp}", $
276overview="../../overview", /statistics, /preformat
277exit
278EOF
279 ;;
280 *)
281  echo "eee : idldoc version not implemented ${idldoc_version}"
282  exit 1
283 ;;
284esac
285# launch IDL with the file built above
286export IDL_STARTUP=${pro}
287${application}
288rm ${pro}
289#
290if [ ${transform} -eq 1 ]
291then
292# In order to do not have to many revision in svn, we modify some
293# lines produced by idldoc :
294# - add Source link in each html file corresponding to a .pro file
295# example :
296# <td>Source</td>
297# will be replaced by
298# <td><a href="../../Calendar/caldat.pro" title="Source code of a file">Source</a></td>
299#
300# - remove version, date and time of idldoc production
301# ++ je ne sais pas dire en sed la ligne suivant l'occurence de Modification date
302#
303# count of directory levels in output
304# this count will be use to format relative path later
305nblev1=$(echo ${outputtmp} | sed -e "s@/\$@@" |awk -F "/" '{print NF}')
306#
307list_html_pro=$(find ${outputtmp} -name "*.html" -exec grep -l "<title>.*\.pro" {} \;)
308for file_html in ${list_html_pro}
309do
310 # build the .pro file name
311 bfile=$(basename ${file_html} .html)
312 # retrieve the path of html file relative to memopwd (so relative to
313 # output). This path will be used in "Source" link.
314 nblev2=$(dirname ${file_html} | sed -e "s@/\$@@" | awk -F "/" '{print NF}')
315 difflev=$((${nblev2} - ${nblev1}))
316 if [ ${difflev} -ge 2 ]
317 then
318 ilev=1
319 reloutput_html=".."
320 while [ ${ilev} -le ${difflev} ]
321 do
322 reloutput_html="${reloutput_html}/.."
323 ilev=$(( ${ilev} + 1 ))
324 done
325 relpath_html=$(dirname ${file_html} | \
326 sed \
327 -e "s@${outputtmp}@${reloutput_html}@" \
328 -e "s@\$@/@")
329 # echo "relpath ${relpath_html})"
330 else
331 relpath_html="./"
332 fi
333 # echo "relpath ${relpath_html}/${bfile}"
334 sed \
335 -e "s@<td >Source<\/td>@<td><a href=\"${relpath_html}/${bfile}.pro\" title=\"Source code of a file\">Source<\/a><\/td>@" \
336 ${file_html} > ${file_html}_modify
337 mv ${file_html}_modify ${file_html}
338done
339list_html=$(find ${outputtmp} -name "*.html")
340for file_html in ${list_html}
341do
342 sed \
343 -e "s/\(Generated by IDLdoc\)\( .* on .*\)\( -->\)/\1\3/" \
344 -e "s/\(Produced by IDLdoc\)\( .* on .*\)\(<\/td>\)/\1\3/" \
345 -e "/<h2>Produced on/d" \
346 -e "/Modifcation:/d" \
347 -e "/<td>... ... .* ..:..:.. ....<\/td>/d" \
348 -e 's@<div class="value">@<div class="preformat">@' \
349 -e 's/div\#file_comments {/div\#file_comments { white-space: pre;/' \
350 -e 's@^ <fixe>@<pre>@' \
351 -e 's@^ </fixe>@</pre>@' \
352 -e 's@xhtml-transitional@xhtml1-transitional@' \
353 ${file_html} > ${file_html}_modify
354 mv ${file_html}_modify ${file_html}
355done
356# suppress ".html" in idldoc-index*.html in lines like
357# a parameter from the routine ./ReadWrite/idl-NetCDF/ncdf_read.html
358list_html=$(find ${outputtmp} -name "idldoc-index*.html")
359for file_html in ${list_html}
360do
361 sed \
362 -e "s/\(a parameter from the routine \)\(.*\)\(.html\)/\1\2/" \
363 ${file_html} > ${file_html}_modify
364 mv ${file_html}_modify ${file_html}
365done
366# replace <pro>ginette</pro> by a sequence like
367# <a href="./ginette.html">ginette</a>
368pro2href.sh -i ${outputtmp} -r ${outputtmp} -e pro
369status=${?}
370if [ ${status} -ne 0 ]
371then
372 echo "eee : pb during pro2href.sh for <pro>...</pro>"
373 exit 1
374fi
375# replace <proidl>ginette</proidl> by a sequence like
376# <a href="./ginette.html">ginette</a>
377pro2href.sh -i ${outputtmp} -r ${IDL_DIR}/help/online_help -e proidl
378status=${?}
379if [ ${status} -ne 0 ]
380then
381 echo "eee : pb during pro2href.sh for <proidl>...</proidl>"
382 exit 1
383fi
384fi # end of transform = 1
385#
386#
387if [ ${assistant} -eq 1 ]
388then
389 # build a IDL file to launch idldoc
390 idldoc_log="/tmp/idldocassistant_${$}.log"
391 pro="/tmp/idldocassistant_${$}.pro"
392 case ${idldoc_version} in
393 3.1.1)
394  echo "iii : assistant is not feasable with idldoc > 2.0"
395 ;;
396 2.0)
397  cat << EOF > ${pro}
398!path = expand_path('+' + '${idldoc_dir}')
399idldoc,root="${indir}",title="${title}", $
400LOG_FILE="${idldoc_log}", $
401output="${outputtmp}", overview='../../overview', /statistics, /embed, /assistant
402exit
403EOF
404 ;;
405 *)
406  echo "eee : idldoc version not implemented ${idldoc_version}"
407  exit 1
408 ;;
409esac
410more ${pro}
411read a
412# launch IDL with the file built above
413IDL_STARTUP=${pro};${IDL_DIR}/bin/idl
414/bin/rm ${pro}
415# In order to do not have to many revision in svn, we modify some
416# lines produced by idldoc :
417# examples :
418# <!-- Generated by IDLdoc 2.0 on Wed Jun 7 10:25:28 2006 -->
419# will be replaced by
420# <!-- Generated by IDLdoc 2.0 -->
421# <p><font color="gray" size="-3">&nbsp;&nbsp;Produced by IDLdoc 2.0 on Wed Sep 13 16:32:10 2006.</font></p>
422# will be replaced by
423# <p><font color="gray" size="-3">&nbsp;&nbsp;Produced by IDLdoc 2.0</font></p>
424# <h2>Produced on Wed Jun 7 10:23:13 2006</h2>
425# will be delete
426# other lines will be deleted because the time is the time of checkout not
427# the time of revision.
428# the sequence of lines
429#<dl>
430# <dt>Last modification:</dt>
431# <dd>Fri Jun 2 11:46:24 2006</dd>
432# </dl>
433# should also be removed ++ je ne sais pas dire en sed la ligne
434# suivant l'occurence de Last modification
435# replace *_param_* in href attributes because anchors are badly written
436# with _keyword_
437#++ -e 's@\(href="#_.*\)\(_param_\)\(.*"\)@\1_keyword_\3@g' \ # ++ pb global
438# ONLINE_HELP, book="../idldoc_assistant_output/idldoc-lib.adp", /full_path # won't work
439# encaspulate example content in <pre> </pre> in idldoc assistant outputs
440# Examples section is supposed to start with <h3>Examples</h3>
441# and end is before <h3>Version history</h3>
442list_html=$(find ${outputtmp} -name "*.html")
443for file_html in ${list_html}
444do
445 sed \
446 -e "s/\(Generated by IDLdoc 2.0\)\( on .*\)\( -->\)/\1\3/" \
447 -e "s/\(Produced by IDLdoc 2.0\)\( on .*\)\(\.<\/font>\)/\1\3/" \
448 -e "/<h2>Produced on/d" \
449 -e "/Last modification:/d" \
450 -e "/<dd>... ... .* ..:..:.. ....<\/dd>/d" \
451 -e '/href/s@_param_@_keyword_@g' \
452 -e 's@<div class="value">@<div class="preformat">@' \
453 -e 's/div\#file_comments {/div\#file_comments { white-space: pre;/' \
454 -e 's@^ <fixe>@<pre>@' \
455 -e 's@^ </fixe>@</pre>@' \
456 -e "s@<h3>Examples</h3>@<h3>Examples</h3><pre>@" \
457 -e "s@<h3>Version history</h3>@</pre><h3>Version history</h3>@" \
458 ${file_html} > ${file_html}_modify
459 mv ${file_html}_modify ${file_html}
460done
461# replace <pro>ginette</pro> by a sequence like
462# <a href="./ginette.html">ginette</a>
463pro2href.sh -i ${outputtmp} -r ${outputtmp} -e pro
464status=${?}
465if [ ${status} -ne 0 ]
466then
467 echo "eee : pb during pro2href.sh for <pro>...</pro>"
468 exit 1
469fi
470# replace <proidl>ginette</proidl> by a sequence like
471# <a href="./ginette.html">ginette</a>
472pro2href.sh -i ${outputtmp} -r ${IDL_DIR}/help/online_help -e proidl
473status=${?}
474if [ ${status} -ne 0 ]
475then
476 echo "eee : pb during pro2href.sh for <proidl>...</proidl>"
477 exit 1
478fi
479# add the directory-overview.html from dir-files.html in idldoc_html_output
480list_html=$(find ../idldoc_html_output -name dir-files.html)
481for file_html in ${list_html}
482do
483 fout=../idldoc_assistant_output/${file_html#../idldoc_html_output/*}
484 fout=${fout%/*}/directory-overview.html
485 cp ${file_html} ${fout}
486done
487# copy listings.css (needed by directory-overview.html files)
488cp ../idldoc/resource/listings.css ${outputtmp}
489# add an id in idldoc-lib.adp
490cat << EOF > /tmp/adp_modification
491<!-- \$Id\$ -->
492EOF
493sed -e "/<\/profile>/r /tmp/adp_modification" \
494 ../idldoc_assistant_output/idldoc-lib.adp > \
495 ../idldoc_assistant_output/idldoc-lib.adp_${$}
496mv ../idldoc_assistant_output/idldoc-lib.adp_${$} \
497../idldoc_assistant_output/idldoc-lib.adp
498rm /tmp/adp_modification
499# check that the number of existing html files for each .pro file is 2!
500for i in $( find ../.. -name "*.pro" )
501do
502 nhtml=$( find ../.. -name $( basename ${i} .pro ).html | wc -l )
503 if [ ${nhtml} -ne 2 ]
504         then
505         echo "ERROR there is not 2 $( basename ${i} .pro ).html files"
506         find ../.. -name $( basename ${i} .pro ).html
507         echo
508 fi
509done
510#
511fi
512# copy of temporary outputs on final directory
513# ++ if transform
514mv ${outputtmp} ${outdir}
515echo "iii : look at ${outdir}/index.html"
516echo "iii : you can see idldoc log file in ${idldoc_log}"
517echo "iii : and look ${outdir}/idldoc-warnings.html#undoc"
518#
519# end
520exit 0
Note: See TracBrowser for help on using the repository browser.