Skip to content

Commit 80edb31

Browse files
committed
[css2] Verify that property (and descriptor) instances are defined in a database, verify that all definitions appear in the spec, verify that the markup and the content match.
--HG-- extra : convert_revision : svn%3A73dc7c4b-06e6-40f3-b4f7-9ed1dbc14bfc/trunk%40582
1 parent ec197e4 commit 80edb31

3 files changed

Lines changed: 180 additions & 1 deletion

File tree

css2/Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Makefile to generate the CSS2 document based on its "source files"
22
# Arnaud Le Hors - lehors@w3.org
3-
# $Id: Makefile,v 1.59 1997-12-16 20:42:06 ijacobs Exp $
3+
# $Id: Makefile,v 1.60 1997-12-28 23:17:43 ijacobs Exp $
44

55
# what needs to be set for every new release:
66
THIS_VERSION= http://www.w3.org/Style/Group/9712/WD-css2-971211
@@ -166,6 +166,8 @@ CHKSAMPLE= $(PERL) ./bin/chksample
166166
MKREFDB = $(PERL) ./bin/mkrefdb
167167
# check references.
168168
CHKREFS= $(PERL) ./bin/chkrefs
169+
# check property/descriptor defs and instances
170+
CHKPROPS= $(PERL) ./bin/chkprops
169171
# add reference normative/informative class info.
170172
ADDREFCLASS= $(PERL) ./bin/addrefclass
171173

@@ -461,6 +463,15 @@ checklnx: all
461463
-@$(RM) linklint
462464
$(LINKLINT) -doc linklint $(FILES)
463465

466+
### check property instances
467+
468+
checkprops: $(SPECSRCS) $(PROPSRC) $(DESCSRC)
469+
-@echo "Checking property instances and defs."
470+
-@$(CHKPROPS) $(PROPSRC) propinst $(SPECSRCS)
471+
-@echo
472+
-@echo "Checking descriptor instances and defs."
473+
-@$(CHKPROPS) $(DESCSRC) descinst $(SPECSRCS)
474+
464475
# get cvs logs
465476

466477
FROMDATE=1 week ago

css2/bin/Attic/chkprops

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/local/bin/perl
2+
# Check validity of property instances in sepc.
3+
# Ian Jacobs - ij@w3.org
4+
# $Id: chkprops,v 1.1 1997-12-28 23:19:35 ijacobs Exp $
5+
6+
$PROGNAME = substr($0, rindex($0, "/") + 1);
7+
if ($#ARGV < 1) {
8+
warn "Usage: $PROGNAME propdb prefix file1 file2 ...\n";
9+
exit 1;
10+
} else {
11+
$propdb = $ARGV[0];
12+
shift;
13+
$prefix = $ARGV[0];
14+
shift;
15+
}
16+
17+
18+
$blockst = "[/][*]";
19+
$blocket = "[*][/]";
20+
sub readpropdb {
21+
if (!open(DBASE, $_[0])) {
22+
warn "$PROGNAME Error: Cannot open dbfile: $_[0]\n";
23+
return;
24+
}
25+
$dbbuf = "";
26+
while (<DBASE>) {
27+
$dbbuf .= $_;
28+
}
29+
$_ = $dbbuf;
30+
while (/$blockst\s*([\w-]+)\s*;;.*?$blocket/so) {
31+
$placeholder = $';
32+
$prop = $1;
33+
$prop =~ s/^\s+//;
34+
# Initialize each property to "False"
35+
$propdb{$prop} = "False";
36+
$_ = $placeholder;
37+
}
38+
}
39+
40+
41+
# copy file in memory
42+
sub readfile {
43+
$buf = "";
44+
if (!open(INPUT, $_[0])) {
45+
warn "$PROGNAME Error: Cannot open file: $_[0]\n";
46+
return;
47+
}
48+
while (<INPUT>) {
49+
$buf .= $_;
50+
}
51+
close(INPUT);
52+
}
53+
54+
readpropdb($propdb);
55+
foreach $file (@ARGV) {
56+
print STDOUT "Checking $file\n";
57+
if (readfile($file)) {
58+
$_ = $buf;
59+
while (/<span\s*\bclass\s*=\s*(?:\"$prefix-([^\"]+)\"|$prefix-([^\s>]+))\s*>(.*?)<\/span>/sio) {
60+
$continue = $';
61+
# One of $1 and $2 will be non-empty.
62+
$propkey = "$1$2";
63+
$content = "$3";
64+
if ( ! (exists $propdb{$propkey}) ) {
65+
warn "Undefined name $propkey in $file\n";
66+
} else {
67+
# This key is referenced from the spec, so set to true
68+
$propdb{$propkey} =~ s/False/True/si;
69+
}
70+
if ( $content !~ /\s*'$propkey'\s*/ ) {
71+
warn "Content $content not same as name for $propkey in $file\n";
72+
}
73+
$_ = $continue;
74+
}
75+
}
76+
}
77+
78+
# For each key in the hash table, see if used in the spec.
79+
80+
while ($key = each %propdb) {
81+
if ($propdb{$key} eq "False") {
82+
print STDOUT "No instances of property $key in document\n";
83+
}
84+
}

css2/bin/chkprops

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/local/bin/perl
2+
# Check validity of property instances in sepc.
3+
# Ian Jacobs - ij@w3.org
4+
# $Id: chkprops,v 1.1 1997-12-28 23:19:35 ijacobs Exp $
5+
6+
$PROGNAME = substr($0, rindex($0, "/") + 1);
7+
if ($#ARGV < 1) {
8+
warn "Usage: $PROGNAME propdb prefix file1 file2 ...\n";
9+
exit 1;
10+
} else {
11+
$propdb = $ARGV[0];
12+
shift;
13+
$prefix = $ARGV[0];
14+
shift;
15+
}
16+
17+
18+
$blockst = "[/][*]";
19+
$blocket = "[*][/]";
20+
sub readpropdb {
21+
if (!open(DBASE, $_[0])) {
22+
warn "$PROGNAME Error: Cannot open dbfile: $_[0]\n";
23+
return;
24+
}
25+
$dbbuf = "";
26+
while (<DBASE>) {
27+
$dbbuf .= $_;
28+
}
29+
$_ = $dbbuf;
30+
while (/$blockst\s*([\w-]+)\s*;;.*?$blocket/so) {
31+
$placeholder = $';
32+
$prop = $1;
33+
$prop =~ s/^\s+//;
34+
# Initialize each property to "False"
35+
$propdb{$prop} = "False";
36+
$_ = $placeholder;
37+
}
38+
}
39+
40+
41+
# copy file in memory
42+
sub readfile {
43+
$buf = "";
44+
if (!open(INPUT, $_[0])) {
45+
warn "$PROGNAME Error: Cannot open file: $_[0]\n";
46+
return;
47+
}
48+
while (<INPUT>) {
49+
$buf .= $_;
50+
}
51+
close(INPUT);
52+
}
53+
54+
readpropdb($propdb);
55+
foreach $file (@ARGV) {
56+
print STDOUT "Checking $file\n";
57+
if (readfile($file)) {
58+
$_ = $buf;
59+
while (/<span\s*\bclass\s*=\s*(?:\"$prefix-([^\"]+)\"|$prefix-([^\s>]+))\s*>(.*?)<\/span>/sio) {
60+
$continue = $';
61+
# One of $1 and $2 will be non-empty.
62+
$propkey = "$1$2";
63+
$content = "$3";
64+
if ( ! (exists $propdb{$propkey}) ) {
65+
warn "Undefined name $propkey in $file\n";
66+
} else {
67+
# This key is referenced from the spec, so set to true
68+
$propdb{$propkey} =~ s/False/True/si;
69+
}
70+
if ( $content !~ /\s*'$propkey'\s*/ ) {
71+
warn "Content $content not same as name for $propkey in $file\n";
72+
}
73+
$_ = $continue;
74+
}
75+
}
76+
}
77+
78+
# For each key in the hash table, see if used in the spec.
79+
80+
while ($key = each %propdb) {
81+
if ($propdb{$key} eq "False") {
82+
print STDOUT "No instances of property $key in document\n";
83+
}
84+
}

0 commit comments

Comments
 (0)