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

Last change on this file since 377 was 377, checked in by pinsard, 16 years ago

parameters in doidldoc.sh but still not yet ready for production

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