source: trunk/SRC/Documentation/xmldoc/showpalettes.sh @ 218

Last change on this file since 218 was 218, checked in by pinsard, 14 years ago

add design target for documents productions

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 5.3 KB
Line 
1#! /bin/sh
2#+
3#
4# NAME
5# ====
6#
7# showpalettes.sh - show available palettes
8#
9# SYNOPSIS
10# ========
11#
12# ::
13#
14# $ showpalettes.sh -i indir -idl_dir idl_dir -o outdir -t tempdir
15#
16# DESCRIPTION
17# ===========
18#
19# ``showpalettes.sh`` inspect ``indir`` and look for  ``.cpt`` files.
20#
21# A XML/DocBook outdir/showpalette.xml is produced to present palettes usage and
22# building.
23#
24# By default, indir is the current directory.
25#
26# Log file is written on ${tempdir}/showpalette.log.\ *YYYYMMDDTHHMMSSZ*
27#
28# CAUTIONS
29# ========
30#
31# SAXO_DIR must be set. The value should be the directory where
32# SAXO is available.
33#
34# for example, if you work at LOCEAN and work with default SAXO,
35# SAXO_DIR=/usr/home/smasson/SAXO_DIR.
36#
37# For working in progress, you should checkout SAXO on a personnal
38# directory and set SAXO_DIR to the working space.
39#
40# example for me : SAXO_DIR=/usr/lodyc/incas/fplod/SAXO_DIR_ws/
41#
42# EXAMPLES
43# ========
44#
45# For POST_IT in working space /usr/lodyc/incas/fplod/post_it_ws/
46# with IDL 6.4
47#
48# ::
49#
50# $ /usr/lodyc/incas/fplod/post_it_ws/SRC/Documentation/xmldoc/showpalettes.sh -i /usr/lodyc/incas/fplod/post_it_ws/ -idl_dir /usr/local_linux/idl/idl_6.4/idl/ -o /tmp/ -t /tmp/
51#
52# For POST_IT in working space /usr/lodyc/incas/fplod/post_it_ws/
53# with IDL 7.0
54#
55# ::
56#
57# $ /usr/lodyc/incas/fplod/post_it_ws/SRC/Documentation/xmldoc/showpalettes.sh -i /usr/lodyc/incas/fplod/post_it_ws/ -idl_dir /usr/local_linux/idl/idl70/ -o /tmp/ -t /tmp/
58#
59# TODO
60# ====
61#
62# Some IDL files should be produced and processed to produce some plots (png files)
63# to be added in each ctp file.
64#
65# EVOLUTIONS
66# ==========
67#
68# $Id$
69#
70# - fplod 20100120T090231Z aedon.locean-ipsl.upmc.fr (Darwin)
71#
72#   * fix typo
73#   * add outdir and tempdir parameters
74#
75# - fplod 20091207T112658Z aedon.locean-ipsl.upmc.fr (Darwin)
76#
77#   * creation
78#
79system=$(uname)
80case "${system}" in
81   AIX|IRIX64)
82      echo " www : no specific posix checking"
83   ;;
84   *)
85      set -o posix
86   ;;
87esac
88command=$(basename ${0})
89log_date=$(date -u +"%Y%m%dT%H%M%SZ")
90#
91usage=" Usage : ${command} -i indir -idl_dir idl_dir -o outdir -t tempdir"
92#
93minargcount=8
94#echo " narg ${#}"
95if [ ${#} -lt ${minargcount} ]
96then
97   echo "eee : not enought arguments (${#} vs ${minargcount})"
98   echo "${usage}"
99   exit 1
100fi
101#
102# default
103# default IDL command and directory
104#idl_dir=/usr/local_linux/idl/idl64/ # overriding idl_dir for test ++
105#
106# default indir directory
107indir=$(pwd)
108# default outdir directory
109outdir=/tmp/
110# default tempdir directory
111tempdir=/tmp/
112#
113# read parameters on command line
114while [ ! -z "${1}" ]
115do
116   case ${1} in
117      -i)
118         indir=${2}
119         shift
120      ;;
121      -idl_dir)
122         idl_dir=${2}
123         shift
124      ;;
125      -o)
126         # directory for outputs choosen by user
127         outdir=${2}
128         shift
129      ;;
130      -t)
131         # directory for temporary outputs choosen by user
132         tempdir=${2}
133         shift
134      ;;
135      -h)
136         echo "${usage}"
137         exit 0
138      ;;
139      *)
140         # other choice
141         echo "${usage}"
142         exit 1
143      ;;
144   esac
145   # next flag
146   shift
147done
148#
149set -u
150#
151# test if ${indir} exist
152if [ ! -d ${indir} ]
153then
154   echo "eee : ${indir} not found"
155   exit 1
156fi
157#
158# test if ${tempdir} exist
159if [ ! -d ${tempdir} ]
160then
161    mkdir -p ${tempdir}
162    echo "${command} : iii : creation of \${tempdir}"
163fi
164#
165# check for permission on ${tempdir}
166if [ ! -x ${tempdir} ]
167then
168   echo " eee : ${tempdir} not reachable"
169   exit 1
170fi
171#
172# test if ${outdir} exist
173if [ ! -d ${outdir} ]
174then
175    mkdir -p ${outdir}
176    echo "${command} : iii : creation of \${outdir}"
177fi
178#
179# check for permission on ${outdir}
180if [ ! -x ${outdir} ]
181then
182   echo " eee : ${outdir} not reachable"
183   exit 1
184fi
185#
186if [ ! -w ${outdir} ]
187then
188   echo " eee : ${outdir} not writable"
189   exit 1
190fi
191#
192log=${tempdir}/$(basename ${command} .sh).log.${log_date}
193#
194# ++ test si IDL (car GDL inutilisable)
195application=${idl_dir}/bin/idl
196#
197# find cpt files
198list_cpt_files=$(find ${indir} \! \( -name '.svn' -prune \) -name "*.cpt")
199#
200# test if at least one found
201if [ "${list_cpt_files}" = "" ]
202then
203   echo "iii : no cpt files found under ++"
204   echo "iii : nothing to do !"
205   exit 0 #++ 1
206fi
207#
208# header of XML/DocBook file
209cat << EOF > ${tempdir}/showpalettes${log_date}.xml
210<?xml version="1.0" encoding="iso-8859-1"?>
211<!DOCTYPE article [
212<!ENTITY promptidl "idl&gt;">
213]>
214
215<article version="5.0"
216xmlns="http://docbook.org/ns/docbook"
217xmlns:xl="http://www.w3.org/1999/xlink"
218xml:lang="en"
219xml:id="palettes">
220
221<title>Palettes</title>
222<para>
223Here are available palettes.
224</para>
225<sect1>
226<title>How to use ?</title>
227<para>
228++
229</para>
230</sect1>
231<sect1>
232<title>Available palettes</title>
233<para>
234++
235</para>
236<variablelist>
237EOF
238#
239# loop on palette files
240for cpt_file in ${list_cpt_files}
241do
242   cpt_bfile=$(basename ${cpt_file})
243   cat << EOF >> ${tempdir}/showpalettes${log_date}.xml
244<varlistentry>
245<term><filename>${cpt_bfile}</filename></term>
246<listitem>
247<para>
248<mediaobject>
249<imageobject>
250<imagedata fileref="figpng/${cpt_bfile}.png"/>
251</imageobject>
252</mediaobject>
253</para>
254</listitem>
255</varlistentry>
256EOF
257done
258#
259# footer of XML/DocBook file
260cat << EOF >> ${tempdir}/showpalettes${log_date}.xml
261</variablelist>
262</sect1>
263<sect1>
264<title>How to build ?</title>
265<para>
266++
267</para>
268</sect1>
269</article>
270EOF
271#
272mv ${tempdir}/showpalettes${log_date}.xml ${outdir}/showpalettes.xml
273echo "iii : ${outdir}/showpalettes.xml can be processed"
274#
275# end
276exit 0
Note: See TracBrowser for help on using the repository browser.