| 1 |
#!/usr/bin/perl -- # -*- Perl -*- |
| 2 |
|
| 3 |
use strict; |
| 4 |
|
| 5 |
my $LIBDIR = "/sourceforge/docbook/defguide/en/refpages/elements"; |
| 6 |
|
| 7 |
my %examples = (); |
| 8 |
|
| 9 |
opendir (LDIR, $LIBDIR); |
| 10 |
while (my $dname = readdir(LDIR)) { |
| 11 |
next if $dname =~ /^\.+$/; |
| 12 |
next if $dname eq 'CVS'; |
| 13 |
my $dir = "$LIBDIR/$dname"; |
| 14 |
next if -f $dir; |
| 15 |
|
| 16 |
opendir (DIR, $dir); |
| 17 |
while (my $name = readdir(DIR)) { |
| 18 |
next if $name =~ /^\.+$/; |
| 19 |
next if $name eq 'CVS'; |
| 20 |
my $file = "$LIBDIR/$dname/$name"; |
| 21 |
|
| 22 |
next if ! -f $file; |
| 23 |
next if $name !~ /^example\.\d+\.xml$/; |
| 24 |
open (F, $file); |
| 25 |
read (F, $_, -s $file); |
| 26 |
close (F); |
| 27 |
|
| 28 |
my %elements = (); |
| 29 |
while (/^.*?<([a-z0-9]+)/si) { |
| 30 |
my $elem = $1; |
| 31 |
$_ = $'; # ' |
| 32 |
|
| 33 |
next if $elem eq $dname; |
| 34 |
next if $elem eq 'mml' && $dname eq 'mml-math'; |
| 35 |
next if $elem eq 'html' && $dname eq 'html-form'; |
| 36 |
|
| 37 |
$examples{$elem} = () if !exists($examples{$elem}); |
| 38 |
$examples{$elem}->{$dname} = 1; |
| 39 |
} |
| 40 |
} |
| 41 |
closedir (DIR); |
| 42 |
} |
| 43 |
closedir (LDIR); |
| 44 |
|
| 45 |
opendir (LDIR, $LIBDIR); |
| 46 |
while (my $dname = readdir(LDIR)) { |
| 47 |
next if $dname eq 'CVS'; |
| 48 |
next if $dname =~ /^\.+$/; |
| 49 |
my $dir = "$LIBDIR/$dname"; |
| 50 |
next if -f $dir; |
| 51 |
|
| 52 |
open (F, ">$LIBDIR/$dname/example.seealso.gen"); |
| 53 |
if ($examples{$dname}) { |
| 54 |
if (-f "$LIBDIR/$dname/example.1.xml") { |
| 55 |
print F "<para>For additional examples, see also\n"; |
| 56 |
} else { |
| 57 |
print F "<para>For examples, see\n"; |
| 58 |
} |
| 59 |
print F "<simplelist type=\"inline\">\n"; |
| 60 |
foreach my $elem (sort keys %{$examples{$dname}}) { |
| 61 |
print F " <member><sgmltag>$elem</sgmltag></member>\n"; |
| 62 |
} |
| 63 |
print F "</simplelist>.\n"; |
| 64 |
print F "</para>\n"; |
| 65 |
} else { |
| 66 |
print F "<!-- no examples to see also -->\n"; |
| 67 |
} |
| 68 |
close (F); |
| 69 |
|
| 70 |
} |
| 71 |
closedir (LDIR); |
| 72 |
|
| 73 |
opendir (LDIR, $LIBDIR); |
| 74 |
while (my $dname = readdir(LDIR)) { |
| 75 |
next if $dname =~ /^\.+$/; |
| 76 |
next if $dname eq 'CVS'; |
| 77 |
next if $examples{$dname}; |
| 78 |
my $dir = "$LIBDIR/$dname"; |
| 79 |
next if -f $dir; |
| 80 |
next if -f "$dir/example.1.xml"; |
| 81 |
|
| 82 |
print "No examples: $dname\n"; |
| 83 |
} |
| 84 |
closedir (LDIR); |