7 use Pod::Simple::Search;
8 @ISA = qw(Pod::Simple::HTML);
11 my ($self, $token) = @_;
12 my $page = $token->attr ('to');
13 my ($name, $section) = ($page =~ /^([^\(]+)\((\d+)\)$/);
15 my @url = ('..', $section, $name);
16 return join ('/', map { $self->pagepath_url_escape ($_) } @url)
17 . $Pod::Simple::HTML::HTML_EXTENSION;
20 # Underscore isn't allowed in man page names in Pod::Simple 3.04, so links
21 # like L<fs_setacl(8)> show up as POD links. Discover that case and dispatch
22 # everything else to the standard do_pod_link implementation.
24 my ($self, $token) = @_;
25 my $target = $token->attr ('to');
26 if ($target && $target =~ /^([^\s\(]+)\((\d+)\)$/) {
27 return $self->do_man_link ($token);
29 return $self->SUPER::do_pod_link ($token);
33 sub VERSION () { '1.1' }
35 $Pod::Simple::HTML::Tagmap{'item-bullet'} = '<li><p>';
36 $Pod::Simple::HTML::Tagmap{'/item-bullet'} = '</p></li>';
37 $Pod::Simple::HTML::Tagmap{'item-number'} = '<li><p>';
38 $Pod::Simple::HTML::Tagmap{'/item-number'} = '</p></li>';
40 # This horrific hack is required because Pod::Simple::HTMLBatch has no way
41 # of setting search options and we have to set laborious to true in order
42 # to pick up man pages like krb.conf(5).
43 package OpenAFS::Search;
48 use Pod::Simple::Search;
49 @ISA = qw(Pod::Simple::HTML);
53 my $object = Pod::Simple::Search->new;
54 $object->laborious (1);
63 use Pod::Simple::HTMLBatch;
65 # Override the search class to set laborious.
66 $Pod::Simple::HTMLBatch::SEARCH_CLASS = 'OpenAFS::Search';
68 our $HEADER = <<'EOH';
71 <title>OpenAFS Reference Manual</title>
72 <link rel="stylesheet" title="style" type="text/css" href="style.css" media="all">
74 <body class='contentspage'>
75 <h1>OpenAFS Reference Manual</h1>
78 our %HEADINGS = (1 => 'User Commands',
79 5 => 'Configuration and Data Files',
80 8 => 'Administrator Commands');
82 # Scan all of the POD files and build a list of section, name, and short
83 # description, returning that as an array.
86 for my $dir (qw(pod1 pod5 pod8)) {
89 opendir (D, $dir) or die "Cannot open $dir: $!\n";
90 for my $file (sort grep { !/^\./ && !/CVS/ } readdir D) {
91 open (F, "$dir/$file") or die "Cannot open $dir/$file: $!\n";
95 last if /^=head1/ && !/^=head1\s+NAME\b/;
96 next unless /\s+-\s+/;
97 ($name, $desc) = split (/\s+-\s+/, $_, 2);
100 warn "$dir/$file: cannot find NAME section, skipping\n";
102 $name =~ s/^(backup|bos|fs|fstrace|kas|pts|symlink|uss|vos)_/$1 /;
105 push (@index, [ $section, $name, $page, $desc ]);
113 mkdir ('html', 0755) or die "Cannot create html directory: $!\n";
115 for my $dir (qw(pod1 pod5 pod8)) {
117 $section =~ s/^pod//;
118 mkdir ("html/$section", 0755) unless -d "html/$section";
120 my $conv = Pod::Simple::HTMLBatch->new;
122 $conv->index (undef);
123 $conv->contents_file (undef);
124 $conv->add_css ('../style.css', 1);
125 $conv->css_flurry (0);
126 $conv->javascript_flurry (0);
127 $conv->html_render_class ('OpenAFS::HTML');
128 $conv->batch_convert ($dir, "html/$section");
130 copy ('style.css', 'html/style.css') or die "Cannot copy style.css: $!\n";
132 open (INDEX, '> html/index.html')
133 or die "Cannot create html/index.html: $!\n";
135 print INDEX "<table>\n";
136 my @index = scan_names;
138 for my $entry (@index) {
139 my ($section, $name, $page, $desc) = @$entry;
145 if (!$current || $section != $current) {
146 print INDEX qq(<tr><td> </td></tr>\n);
147 print INDEX qq(<tr class="heading"><th colspan="2">);
148 print INDEX qq($HEADINGS{$section}</th></tr>\n);
151 print INDEX qq(<tr><td><a href="$section/$page.html">$name</a></td>);
152 print INDEX qq(<td>$desc</td></tr>\n);
154 print INDEX "</table>\n</body>\n</html>\n";