File: update.example.seealso

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 (84 lines) | stat: -rwxr-xr-x 1,977 bytes parent folder | download | duplicates (11)
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
#!/usr/bin/perl -- # -*- Perl -*-

use strict;

my $LIBDIR = "/sourceforge/docbook/defguide/en/refpages/elements";

my %examples = ();

opendir (LDIR, $LIBDIR);
while (my $dname = readdir(LDIR)) {
    next if $dname =~ /^\.+$/;
    next if $dname eq 'CVS';
    my $dir = "$LIBDIR/$dname";
    next if -f $dir;

    opendir (DIR, $dir);
    while (my $name = readdir(DIR)) {
	next if $name =~ /^\.+$/;
	next if $name eq 'CVS';
	my $file = "$LIBDIR/$dname/$name";

	next if ! -f $file;
	next if $name !~ /^example\.\d+\.xml$/;
	open (F, $file);
	read (F, $_, -s $file);
	close (F);

	my %elements = ();
	while (/^.*?<([a-z0-9]+)/si) {
	    my $elem = $1;
	    $_ = $'; # '

	    next if $elem eq $dname;
	    next if $elem eq 'mml' && $dname eq 'mml-math';
	    next if $elem eq 'html' && $dname eq 'html-form';

	    $examples{$elem} = () if !exists($examples{$elem});
	    $examples{$elem}->{$dname} = 1;
	}
    }
    closedir (DIR);
}
closedir (LDIR);

opendir (LDIR, $LIBDIR);
while (my $dname = readdir(LDIR)) {
    next if $dname eq 'CVS';
    next if $dname =~ /^\.+$/;
    my $dir = "$LIBDIR/$dname";
    next if -f $dir;

    open (F, ">$LIBDIR/$dname/example.seealso.gen");
    if ($examples{$dname}) {
	if (-f "$LIBDIR/$dname/example.1.xml") {
	    print F "<para>For additional examples, see also\n";
	} else {
	    print F "<para>For examples, see\n";
	}
	print F "<simplelist type=\"inline\">\n";
	foreach my $elem (sort keys %{$examples{$dname}}) {
	    print F "  <member><sgmltag>$elem</sgmltag></member>\n";
	}
	print F "</simplelist>.\n";
	print F "</para>\n";
    } else {
	print F "<!-- no examples to see also -->\n";
    }
    close (F);

}
closedir (LDIR);

opendir (LDIR, $LIBDIR);
while (my $dname = readdir(LDIR)) {
    next if $dname =~ /^\.+$/;
    next if $dname eq 'CVS';
    next if $examples{$dname};
    my $dir = "$LIBDIR/$dname";
    next if -f $dir;
    next if -f "$dir/example.1.xml";

    print "No examples: $dname\n";
}
closedir (LDIR);