File: attrcheck

package info (click to toggle)
docbook-defguide 2.0.17%2Bsvn9912-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 93,432 kB
  • ctags: 299
  • sloc: xml: 396,482; perl: 4,471; python: 879; makefile: 150; sh: 80
file content (59 lines) | stat: -rwxr-xr-x 1,383 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/perl -- # -*- Perl -*-

use strict;

my $elemdir = "refpages/elements";

opendir (DIR, $elemdir);
while (my $name = readdir(DIR)) {
    next if $name =~ /^\.\.?$/;
    my $dir = "$elemdir/$name";
    next if ! -d $dir;
    next if ! -f "$dir/refentry.xml" || ! -f "$dir/synopsis.e.gen";
    checkAttr($dir);
}
closedir (DIR);

sub checkAttr {
    my $dir = shift;
    my $synopsis = "$dir/synopsis.e.gen";
    my $refentry = "$dir/refentry.xml";
    my %rattr = ();
    my %sattr = ();

    open (F, $refentry);
    read (F, $_, -s $refentry);
    close (F);

    if (/<refsec.*\scondition=.ref.elem.attrdesc.(.*?)<\/refsec/s) {
	$_ = $1;
	my @terms = m/<term>.*?<\/term>/sg;
	foreach my $term (@terms) {
	    $rattr{$1} = 1 if $term =~ /<term>(.*?)<\/term>/s;
	}
    }

    open (F, $synopsis);
    read (F, $_, -s $synopsis);
    close (F);

    my @rows = m/<row[^>]+role=[\'\"]attr[\'\"].*?<\/row>/sg;
    foreach my $row (@rows) {
	$sattr{$1} = 1 if $row =~ /.*?<entry[^>]*>(.*?)<\/entry/s;
    }

    my @keys = keys %rattr;
    foreach my $key (@keys) {
	if (exists($sattr{$key})) {
	    delete $rattr{$key};
	    delete $sattr{$key};
	}
    }

    return if (!%rattr && !%sattr);

    print "$dir:\n";
    print "\tRefentry: ", join(", ", sort keys %rattr), "\n" if %rattr;
    print "\tSynopsis: ", join(", ", sort keys %sattr), "\n" if %sattr;
    print "\n";
}