man-page-fs-updates-20070817
[openafs.git] / doc / man-pages / generate-html
index 79d105e..11fdad1 100755 (executable)
@@ -7,9 +7,31 @@ use vars qw(@ISA);
 use Pod::Simple::Search;
 @ISA = qw(Pod::Simple::HTML);
 
+# Add a link back to the index page to the top and bottom of each generated
+# page.
+#
+# The hideous approach we have to use is because, unless we create a
+# Pod::Simple::HTML object and then rebless it, the html_header_after_title
+# and html_footer subs are placed in the OpenAFS::HTML package.  That means we
+# can't override them in a subclass and still call the SUPER version since
+# we'll be overwriting the SUPER version, and there aren't other good
+# opportunities to change the default values that I can see.
+sub new {
+    my $class = shift;
+    my $self = Pod::Simple::HTML->new (@_);
+    bless ($self, 'OpenAFS::HTML');
+    my $link = '<p class="indexlink"><a href="../index.html">'
+        . 'Back to Index</a></p>' . "\n";
+    my $after = $self->html_header_after_title;
+    $self->html_header_after_title ($after . $link);
+    my $end = $self->html_footer;
+    $self->html_footer ($link . $end);
+    return $self;
+}
+
 sub do_man_link {
     my ($self, $token) = @_;
-    my $page = $token->attr('to');
+    my $page = $token->attr ('to');
     my ($name, $section) = ($page =~ /^([^\(]+)\((\d+)\)$/);
     return unless $name;
     my @url = ('..', $section, $name);
@@ -17,7 +39,20 @@ sub do_man_link {
         . $Pod::Simple::HTML::HTML_EXTENSION;
 }
 
-sub VERSION () { '1.0' }
+# Underscore isn't allowed in man page names in Pod::Simple 3.04, so links
+# like L<fs_setacl(8)> show up as POD links.  Discover that case and dispatch
+# everything else to the standard do_pod_link implementation.
+sub do_pod_link {
+    my ($self, $token) = @_;
+    my $target = $token->attr ('to');
+    if ($target && $target =~ /^([^\s\(]+)\((\d+)\)$/) {
+        return $self->do_man_link ($token);
+    } else {
+        return $self->SUPER::do_pod_link ($token);
+    }
+}
+
+sub VERSION () { '1.1' }
 
 $Pod::Simple::HTML::Tagmap{'item-bullet'} = '<li><p>';
 $Pod::Simple::HTML::Tagmap{'/item-bullet'} = '</p></li>';