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);
|