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

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

small things for documentations

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