source: trunk/SRC/Documentation/xmldoc/pro2href.sh @ 237

Last change on this file since 237 was 237, checked in by pinsard, 17 years ago

replace some print by some report in some .pro (continuation) + improvements/corrections of some *.pro headers

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
1#! /bin/sh
2# replace <pro>ginette</pro> by a sequence like
3# <a href="./ginette.html">ginette</a>
4# we have to deal with the path of ginette.html ...
5#
6# see call in savesaxo.sh
7#
8# update :
9# $Id$
10# fplod 2007-03-20T14:02:14Z aedon.locean-ipsl.upmc.fr (Darwin)
11# creation
12#
13set -u
14output=${1} # ++ parameter
15#
16# first find all files containing <pro>..</pro>
17list_html_pro=$(find ${output} -name "*.html" -exec grep -l "<pro>.*</pro>" {} \;)
18if [ "${list_html_pro}" = " " ]
19then
20   echo "iii : no <pro>..</pro> in html files"
21else
22   for file_html in ${list_html_pro}
23   do
24       fpath=$(dirname ${file_html} | sed -e "s+\(${output}/\)\(.*\)+\2+")
25       list_llink=$(grep -n "<pro>.*</pro>" ${file_html} | awk -F ":" '{print $1}')
26       # ++ repérer si plusieurs <pro>.*</pro> par ligne
27       # ++ sortir en erreur si c'est le cas
28       for line in ${list_llink}
29       do
30          # replace <pro>something</pro> by
31          #<a href="something.html">something</a>
32          # module is the html file name to be used
33          module=$(sed -ne "${line},${line}p" ${file_html} | \
34                   grep "<pro>.*</pro>" | \
35                   sed -e "s+\(.*<pro>\)\(.*\)\(</pro>.*\)+\\2.html+")
36          modulemin=$(echo ${module} | tr "[:upper:]" "[:lower:]" )
37          # lpath is the path on module relatively to the location of
38          # the html file containing the <pro>..</pro>
39          lpath=$(find ${output} -name "${modulemin}")
40           # ++ repérer si doublons
41           # ++ sortir en erreur si c'est le cas
42          if [ "${lpath}" = "" ]
43          then
44             echo "eee : path of ${modulemin} not found under ${output}"
45             echo "eee : ${module} is used in ${file_html}"
46          else
47             lpath=$(dirname ${lpath} | sed -e "s+\(${output}/\)\(.*\)+\2+")
48#echo "path du fichier html ${fpath}"
49#echo "lpath ${lpath}"
50             if [ "${lpath}" = "${fpath}" ]
51             then
52                relpath="./"
53             else
54                nblev=$(echo ${fpath} |  sed -e "s@/\$@@" | awk -F "/" '{print NF}')
55           #     nblev=$(( ${nblev} + 1))
56                relpath=""
57                ilev=1
58                while [ ${ilev} -le ${nblev} ]
59                do
60                   relpath="${relpath}../"
61                   ilev=$(( ${ilev} + 1 ))
62                done
63                relpath=${relpath}/${lpath}
64             fi
65#echo "relpath ${relpath}"
66             sed -e "${line}s+\(<pro>\)\(.*\)\(</pro>\)+<a href=\"${relpath}/\\2.html\">\2</a>+" \
67             ${file_html} > ${file_html}_modify
68             mv ${file_html}_modify ${file_html}
69          fi
70       done
71   done
72fi
73exit 0
Note: See TracBrowser for help on using the repository browser.