#!/usr/local/bin/perl
# Index of property names.
# Arnaud Le Hors lehors@w3.org/Ian Jacobs ij@w3.org
# $Id: mkpropidx,v 2.16 2006-10-09 18:55:52 ihickson Exp $
use English;
$realpath = ();
while ($ARGV[0] =~ /^-/) {
if ($ARGV[0] eq "-r" && $ARGV[1]) {
shift;
$realpath = shift;
} else {
print "Usage: $PROGNAME [-r realpath] indexfile dbase\n";
exit 1;
}
}
$PROGNAME = substr($0, rindex($0, "/") + 1);
if (!$ARGV[1]) {
print "Usage: $PROGNAME [-r realpath] indexfile dbase\n";
exit 1;
} else {
$indexf = $ARGV[0];
$dbasef = $ARGV[1];
}
### main
# compute path relative to index file
$root = "";
@elems = split("/", $indexf);
pop @elems; # get rid of the file itself
foreach (@elems) {
$root .= "../";
}
# copy file in memory
sub readdb {
if (!open(DBASE, $_[0])) {
die "$PROGNAME Error: Cannot open file: $_[0]\n";
}
$INPUT_RECORD_SEPARATOR="/*";
$buf = "";
@indexes = ();
while ($buf = ";
foreach $name (split(' ', $_[0])) {
$name = cleanup($name);
print OUTPUT "'" . $name . "'<\/span>\n";
}
}
sub format_val {
# Replace $value\n";
}
sub format_init {
print OUTPUT " " . cleanup($_[0]) . "\n";
}
sub format_app {
# Replace * by a space (since most props take *).
$applies = cleanup($_[0]);
$applies =~ s/[*]/ /;
print OUTPUT " $applies\n";
}
sub format_inh {
# If not inherited, don't print anything.
$inherited = cleanup($_[0]);
# $inherited =~ s/^no$/ /;
print OUTPUT " $inherited\n";
}
sub format_perc {
# Replace N/A by a space (since most N/A).
$percentages = $_[0];
$percentages =~ s/^[ \t\n]+//gs;
$percentages =~ s/[ \t\n]+$//gs;
$percentages =~ s/N\/A/ /;
$percentages =~ s/\<\'(.+?)\'\>/\'\1\'<\/span>/sgi;
print OUTPUT " $percentages\n";
}
sub format_media {
# If just visual, replace by space.
$fmedia = cleanup($_[0]);
$fmedia =~ s/visual/visual<\/a>/;
$fmedia =~ s/aural/aural<\/a>/;
$fmedia =~ s/tactile/tactile<\/a>/;
$fmedia =~ s/continuous/continuous<\/a>/;
$fmedia =~ s/paged/paged<\/a>/;
$fmedia =~ s/grid/grid<\/a>/;
$fmedia =~ s/interactive/interactive<\/a>/;
$fmedia =~ s/static/static<\/a>/;
$fmedia =~ s/all/all<\/a>/;
print OUTPUT " $fmedia\n";
}
#sub format_compval {
# $compval = cleanup($_[0]);
# print OUTPUT " $compval\n";
#}
sub table_head {
print OUTPUT " \n";
print OUTPUT "";
print OUTPUT "
\n";
}
# main
readdb($dbasef);
open(OUTPUT, "> $indexf");
table_head();
table_body();
table_foot();
close(OUTPUT);
close(DBASE);
";
print OUTPUT " ";
print OUTPUT "\n";
}
sub table_body {
foreach $x (sort @indexes) {
($name, $val, $init, $app, $inh, $perc, $media, $compval) = split(/;;/, $x);
if ($name !~ /\s*property-name\s*/) { # Skip the example
print OUTPUT "Name";
print OUTPUT " Values";
print OUTPUT " Initial value";
print OUTPUT " Applies to
(Default: all)";
# print OUTPUT "Inherited?
(Default: no)";
print OUTPUT "Inherited?";
print OUTPUT " Percentages
(Default: N/A)";
print OUTPUT "Media groups";
#print OUTPUT " Computed value";
print OUTPUT " ";
format_name($name);
format_val($val);
format_init($init);
format_app($app);
format_inh($inh);
format_perc($perc);
format_media($media);
#format_compval($compval);
print OUTPUT "\n";
}
}
}
sub table_foot {
print OUTPUT "