8000 [css2] Added scripts to create indexes of properties and descriptors · w3c/csswg-drafts@027c7b6 · GitHub
Skip to content

Commit 027c7b6

Browse files
committed
[css2] Added scripts to create indexes of properties and descriptors
--HG-- extra : convert_revision : svn%3A73dc7c4b-06e6-40f3-b4f7-9ed1dbc14bfc/trunk%40511
1 parent f83d6f9 commit 027c7b6

4 files changed

Lines changed: 598 additions & 0 deletions

File tree

css2/bin/Attic/mkdescidx

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#!/usr/local/bin/perl
2+
# Index of descriptor names.
3+
# Arnaud Le Hors lehors@w3.org/Ian Jacobs ij@w3.org
4+
# $Id: mkdescidx,v 1.1 1997-12-10 23:06:29 ijacobs Exp $
5+
use English;
6+
7+
8+
if (($_ = $ARGV[0], /^-r/) && $ARGV[0]) {
9+
shift;
10+
$realpath = $ARGV[0];
11+
shift;
12+
} else {
13+
$realpath = ();
14+
}
15+
16+
$PROGNAME = substr($0, rindex($0, "/") + 1);
17+
18+
if (!$ARGV[1]) {
19+
print "Usage: $PROGNAME [-r realpath] indexfile dbase\n";
20+
exit 1;
21+
} else {
22+
$indexf = $ARGV[0];
23+
$dbasef = $ARGV[1];
24+
}
25+
26+
### main
27+
28+
# compute path relative to index file
29+
$root = "";
30+
@elems = split("/", $indexf);
31+
pop @elems; # get rid of the file itself
32+
foreach (@elems) {
33+
$root .= "../";
34+
}
35+
36+
# copy file in memory
37+
sub readdb {
38+
if (!open(DBASE, $_[0])) {
39+
die "$PROGNAME Error: Cannot open file: $_[0]\n";
40+
}
41+
$INPUT_RECORD_SEPARATOR="/*";
42+
$buf = "";
43+
$indexes = ();
44+
while ($buf = <DBASE>) {
45+
$INPUT_RECORD_SEPARATOR="*/";
46+
unless (eof(DBASE)) {
47+
$entry=<DBASE>;
48+
$INPUT_RECORD_SEPARATOR="/*";
49+
if ($entry =~ /((.*?);;.*)\*\//sio) {
50+
$data = $1;
51+
$key = $2;
52+
# Newlines and tabs-> space
53+
$data =~ s/[\n\t]+/ /gs;
54+
$indexes{$key} = $data;
55+
} else {
56+
warn "Bad syntax: $entry\n";
57+
}
58+
}
59+
}
60+
close(DBASE);
61+
}
62+
63+
sub cleanup {
64+
# Put in right HTML markup
65+
$arg = $_[0];
66+
$arg =~ s/^[ \t\n]+//gs;
67+
$arg =~ s/[ \t\n]+$//gs;
68+
$arg =~ s/[&]/\&amp\;/gs;
69+
$arg =~ s/[<]/\&lt\;/gs;
70+
$arg =~ s/[>]/\&gt\;/gs;
71+
return "$arg";
72+
}
73+
74+
# Descriptor database entries between "/*" and "*/"
75+
76+
sub format_name {
77+
$name = cleanup($_[0]);
78+
print OUTPUT "<td><span class=\"descinst-" . $name . "\">'" . $name . "'<\/span>\n";
79+
}
80+
81+
82+
sub format_val {
83+
# Replace <n> by link to value def of n
84+
# Replace <'m'> by link to descriptor 'm'
85+
$value = $_[0];
86+
$value =~ s/^[ \t\n]+//gs;
87+
$value =~ s/[ \t\n]+$//gs;
88+
$value =~ s/\<([^']+?)\>/<span class=\"value-inst-\1\">\&lt\;\1\&gt\;<\/span>/sgi;
89+
$value =~ s/\<\'(.+?)\'\>/<span class=\"descinst-\1\">\'\1\'<\/span>/sgi;
90+
print OUTPUT "<td>$value\n";
91+
}
92+
93+
sub format_init {
94+
print OUTPUT "<td>" . cleanup($_[0]) . "\n";
95+
}
96+
97+
#sub format_media {
98+
# # If just visual, replace by space.
99+
# $fmedia = cleanup($_[0]);
100+
# $fmedia =~ s/^visual$/&nbsp;/;
101+
# print OUTPUT "<td>$fmedia\n";
102+
#}
103+
104+
sub table_head {
105+
print OUTPUT "<table border=1 align=center>\n";
106+
print OUTPUT "<tr align=center>";
107+
print OUTPUT "<th>Name";
108+
print OUTPUT "<th>Values";
109+
print OUTPUT "<th>Initial valu 5D33 e";
110+
print OUTPUT "\n";
111+
}
112+
113+
sub table_body {
114+
foreach $key (sort (keys %indexes)) {
115+
($name, $val, $init, $media) = split(/;;/, $indexes{$key});
116+
print OUTPUT "<tr>";
117+
format_name($name);
118+
format_val($val);
119+
format_init($init);
120+
print OUTPUT "\n";
121+
}
122+
}
123+
124+
sub table_foot {
125+
print OUTPUT "</table>\n";
126+
}
127+
128+
# main
129+
readdb($dbasef);
130+
open(OUTPUT, "> $indexf");
131+
table_head();
132+
table_body();
133+
table_foot();
134+
close(OUTPUT);
135+
close(DBASE);

css2/bin/Attic/mkpropidx

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
#!/usr/local/bin/perl
2+
# Index of property names.
3+
# Arnaud Le Hors lehors@w3.org/Ian Jacobs ij@w3.org
4+
# $Id: mkpropidx,v 1.1 1997-12-10 23:06:30 ijacobs Exp $
5+
use English;
6+
7+
8+
if (($_ = $ARGV[0], /^-r/) && $ARGV[0]) {
9+
shift;
10+
$realpath = $ARGV[0];
11+
shift;
12+
} else {
13+
$realpath = ();
14+
}
15+
16+
$PROGNAME = substr($0, rindex($0, "/") + 1);
17+
18+
if (!$ARGV[1]) {
19+
print "Usage: $PROGNAME [-r realpath] indexfile dbase\n";
20+
exit 1;
21+
} else {
22+
$indexf = $ARGV[0];
23+
$dbasef = $ARGV[1];
24+
}
25+
26+
### main
27+
28+
# compute path relative to index file
29+
$root = "";
30+
@elems = split("/", $indexf);
31+
pop @elems; # get rid of the file itself
32+
foreach (@elems) {
33+
$root .= "../";
34+
}
35+
36+
# copy file in memory
37+
sub readdb {
38+
if (!open(DBASE, $_[0])) {
39+
die "$PROGNAME Error: Cannot open file: $_[0]\n";
40+
}
41+
$INPUT_RECORD_SEPARATOR="/*";
42+
$buf = "";
43+
$indexes = ();
44+
while ($buf = <DBASE>) {
45+
$INPUT_RECORD_SEPARATOR="*/";
46+
unless (eof(DBASE)) {
47+
$entry=<DBASE>;
48+
$INPUT_RECORD_SEPARATOR="/*";
49+
if ($entry =~ /((.*?);;.*)\*\//sio) {
50+
$data = $1;
51+
$key = $2;
52+
# Newlines and tabs-> space
53+
$data =~ s/[\n\t]+/ /gs;
54+
$indexes{$key} = $data;
55+
} else {
56+
warn "Bad syntax: $entry\n";
57+
}
58+
}
59+
}
60+
close(DBASE);
61+
}
62+
63+
sub cleanup {
64+
# Put in right HTML markup
65+
$arg = $_[0];
66+
$arg =~ s/^[ \t\n]+//gs;
67+
$arg =~ s/[ \t\n]+$//gs;
68+
$arg =~ s/[&]/\&amp\;/gs;
69+
$arg =~ s/[<]/\&lt\;/gs;
70+
$arg =~ s/[>]/\&gt\;/gs;
71+
return "$arg";
72+
}
73+
74+
# Property database entries between "/*" and "*/"
75+
76+
sub format_name {
77+
$name = cleanup($_[0]);
78+
print OUTPUT "<td><span class=\"propinst-" . $name . "\">'" . $name . "'<\/span>\n";
79+
}
80+
81+
82+
sub format_val {
83+
# Replace <n> by link to value def of n
84+
# Replace <'m'> by link to property 'm'
85+
$value = $_[0];
86+
$value =~ s/^[ \t\n]+//gs;
87+
$value =~ s/[ \t\n]+$//gs;
88+
$value =~ s/\<([^']+?)\>/<span class=\"value-inst-\1\">\&lt\;\1\&gt\;<\/span>/sgi;
89+
$value =~ s/\<\'(.+?)\'\>/<span class=\"propinst-\1\">\'\1\'<\/span>/sgi;
90+
print OUTPUT "<td>$value\n";
91+
}
92+
93+
sub format_init {
94+
print OUTPUT "<td>" . cleanup($_[0]) . "\n";
95+
}
96+
97+
sub format_app {
98+
# Replace * by a space (since most props take *).
99+
$applies = cleanup($_[0]);
100+
$applies =~ s/[*]/&nbsp;/;
101+
print OUTPUT "<td>$applies\n";
102+
}
103+
104+
sub format_inh {
105+
# If not inherited, don't print anything.
106+
$inherited = cleanup($_[0]);
107+
$inherited =~ s/^no$/&nbsp;/;
108+
print OUTPUT "<td>$inherited\n";
109+
}
110+
111+
sub format_perc {
112+
# Replace N/A by a space (since most N/A).
113+
$percentages = cleanup($_[0]);
114+
$percentages =~ s/N\/A/&nbsp;/;
115+
print OUTPUT "<td>$percentages\n";
116+
}
117+
118+
sub format_media {
119+
# If just visual, replace by space.
120+
$fmedia = cleanup($_[0]);
121+
$fmedia =~ s/^visual$/&nbsp;/;
122+
print OUTPUT "<td>$fmedia\n";
123+
}
124+
125+
sub table_head {
126+
print OUTPUT "<table border=1 align=center>\n";
127+
print OUTPUT "<tr align=center>";
128+
print OUTPUT "<th>Name";
129+
print OUTPUT "<th>Values";
130+
print OUTPUT "<th>Initial value";
131+
print OUTPUT "<th>Applies to <BR> (Default: all)";
132+
print OUTPUT "<th>Inherited? <BR> (Default: no)";
133+
print OUTPUT "<th>Percentages <BR> (Default: N/A)";
134+
print OUTPUT "<th>Media <BR> (Default: visual)";
135+
print OUTPUT "\n";
136+
}
137+
138+
sub table_body {
139+
foreach $key (sort (keys %indexes)) {
140+
($name, $val, $init, $app, $inh, $perc, $media) = split(/;;/, $indexes{$key});
141+
print OUTPUT "<tr>";
142+
format_name($name);
143+
format_val($val);
144+
format_init($init);
145+
format_app($app);
146+
format_inh($inh);
147+
format_perc($perc);
148+
format_media($media);
149+
print OUTPUT "\n";
150+
}
151+
}
152+
153+
sub table_foot {
154+
print OUTPUT "</table>\n";
155+
}
156+
157+
# main
158+
readdb($dbasef);
159+
open(OUTPUT, "> $indexf");
160+
table_head();
161+
table_body();
162+
table_foot();
163+
close(OUTPUT);
164+
close(DBASE);

0 commit comments

Comments
 (0)