#!/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 "For additional examples, see also\n"; } else { print F "For examples, see\n"; } print F "\n"; foreach my $elem (sort keys %{$examples{$dname}}) { print F " $elem\n"; } print F ".\n"; print F "\n"; } else { print F "\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);