File: vspx_doc.sh

package info (click to toggle)
virtuoso-opensource 6.1.6+dfsg2-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 260,992 kB
  • ctags: 125,220
  • sloc: ansic: 652,748; sql: 458,419; xml: 282,834; java: 61,031; sh: 40,031; cpp: 36,890; cs: 25,240; php: 12,692; yacc: 9,523; lex: 7,018; makefile: 6,157; jsp: 4,484; awk: 1,643; perl: 1,013; ruby: 1,003; python: 326
file content (125 lines) | stat: -rwxr-xr-x 4,877 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/sh
#
#  $Id$
#  
#  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
#  project.
#  
#  Copyright (C) 1998-2012 OpenLink Software
#  
#  This project is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the
#  Free Software Foundation; only version 2 of the License, dated June 1991.
#  
#  This program is distributed in the hope that it will be useful, but
#  WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#  General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License along
#  with this program; if not, write to the Free Software Foundation, Inc.,
#  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#  

# ----------------------------------------------------------------------
#  Fix issues with LOCALE
# ----------------------------------------------------------------------
LANG=C
LC_ALL=POSIX
export LANG LC_ALL

vspxdir="${HOME}/binsrc/vspx"
vspxsql=${vspxsql-$vspxdir/vspx.sql}
vspxxsd=${vspxxsd-$vspxdir/vspx.xsd}
vspxmetadir=${vspxmetadir-$vspxdir/.vspxmeta}
vspxmetasrc=${vspxmetasrc-$vspxdir/vspxmeta.xml}
cutterdir="${HOME}/binsrc/sqldoc"
if [ "z$CUTTER" != "z" ] ; then
    cutter=$CUTTER
else
    cutter="${cutterdir}/cutter"
fi
pwddir=`pwd`
cd "${cutterdir}"
make
cd "${pwddir}"

begin_xml ()
{
	xml=$1
	printf "%s" '<?xml version="1.0" encoding="ISO-8859-1" ?>' > $xml
}

write_xml_cdata ()
{
	xml=$1
	tmp=$2
	printf "%s" '<![CDATA[' >> $xml
	sed 's/\]\]\>/\]\]\]\><![CDATA\]\>/g' < $tmp >> $xml
	printf "%s" ']]>' >> $xml
}

rm $vspxmetasrc
rm -rf $vspxmetadir
mkdir $vspxmetadir
echo 'Cutting SQLs for controls ...'
$cutter -P control -P validator -X -P obsolete -X -P base -N 1 -s $vspxsql -o $vspxmetadir/__controls.tmp
echo 'Grepping names of controls ...'
grep '^create type' $vspxmetadir/__controls.tmp | \
sed 's/\(create [ ]*type [ ]*vspx_\)\([a-zA-Z_][a-zA-Z0-9_]*\)\(.*\)/\2/g' > $vspxmetadir/__control_types0.tmp
sort $vspxmetadir/__control_types0.tmp > $vspxmetadir/__control_types.tmp
begin_xml $vspxmetasrc
echo "<controls>" >> $vspxmetasrc
for type in `cat $vspxmetadir/__control_types.tmp` ; do
	base=$vspxmetadir/${type}
	echo "Extracting 'create type' for control $type ..."
	echo "<control name=\"$type\">" >> $vspxmetasrc
	$cutter -BH1 "create type vspx_${type} " -BT3 ";" -s $vspxmetadir/__controls.tmp -o ${base}__all.tmp
	$cutter -BT1 "create type vspx_${type} " -s ${base}__all.tmp -o ${base}__comment0.tmp
	$cutter -BH1 "create type vspx_$type " -BS1 "create type vspx_" -s ${base}__all.tmp -o ${base}__code.tmp
	cat ${base}__comment0.tmp | sed 's/^--//g' > ${base}__comment.tmp
	write_xml_cdata ${base}__comment.xml ${base}__comment.tmp
	write_xml_cdata ${base}__code.xml ${base}__code.tmp
	echo "<!ENTITY vspx_${type}__comment SYSTEM \"${type}__comment.xml\">" >> $vspxmetadir/vspx.ent
	echo "<!ENTITY vspx_${type}__code SYSTEM \"${type}__code.xml\">" >> $vspxmetadir/vspx.ent
	echo "<sqlcomment>" >> $vspxmetasrc
	cat ${base}__comment.xml >> $vspxmetasrc
	echo "</sqlcomment>" >> $vspxmetasrc
	echo "<sqlcode>" >> $vspxmetasrc
	cat ${base}__code.xml >> $vspxmetasrc
	echo "</sqlcode>" >> $vspxmetasrc
	echo "</control>" >> $vspxmetasrc
done
echo 'Parsing examples ...'
for file in `ls $vspxdir/examples/*.vspx` ; do
	sedop0='s/\(.*\/\)//g'
	sedop1='s/\(__.*\)//g'
	sedop2='s/_/-/g'
	control=`echo $file | sed $sedop0 | sed $sedop1 | sed $sedop2`
	sedop1='s/\(\..*\)//g'
	example=`echo $file | sed $sedop0 | sed $sedop1`
	echo "Processing example '$example' for control '$control' ..."
	$cutter -BS1 "<v:page" -s $file -o $vspxmetadir/${example}__code.tmp
	$cutter -BT1 "<v:page" -s $file -o $vspxmetadir/${example}__cmt0.tmp
	cat $vspxmetadir/${example}__cmt0.tmp | sed 's/<!--!//g' | sed 's/-->//g' > $vspxmetadir/${example}__cmt1.tmp
	cat $vspxmetadir/${example}__cmt1.tmp | grep '\\brief' | sed 's/\\brief//g' > $vspxmetadir/${example}__cmttitle.tmp
	cat $vspxmetadir/${example}__cmt1.tmp | sed 's/^\([ ]*\\brief.*\)//g' > $vspxmetadir/${example}__cmtdescr.tmp
	echo "<example id='$example' control='$control'>" >> $vspxmetasrc
	echo "<title>" >> $vspxmetasrc
	write_xml_cdata $vspxmetasrc $vspxmetadir/${example}__cmttitle.tmp
	echo "</title>" >> $vspxmetasrc
	echo "<descr>" >> $vspxmetasrc
	write_xml_cdata $vspxmetasrc $vspxmetadir/${example}__cmtdescr.tmp
	echo "</descr>" >> $vspxmetasrc
	echo "<code>" >> $vspxmetasrc
	write_xml_cdata $vspxmetasrc $vspxmetadir/${example}__code.tmp
	echo "</code>" >> $vspxmetasrc
	echo "</example>" >> $vspxmetasrc
done

echo "Adding data from $vspxxsd ..."
cat $vspxxsd | sed "s/\([<][?]xml[^>]*[>]\)//g" >> $vspxmetasrc
echo "</controls>" >> $vspxmetasrc

#rm $vspxmetadir/*.tmp
echo "The result is in $vspxmetasrc and $vspxmetadir/*.xml"