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

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

migration from DocBook? 4 to Docbook 5 : sources and production tools

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