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

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

improve wiki FAQ production

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