Changeset 644
- Timestamp:
- 01/05/07 10:44:51 (3 years ago)
- Files:
-
- 1 modified
-
trunk/server/makedocs.pl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/makedocs.pl
r587 r644 2 2 3 3 use strict; 4 my @files = ("mogstored", "mogilefsd");5 push @files, `find lib -name '*.pm'`;6 chomp @files;7 4 8 5 my $base = "/home/lj/htdocs/dev/mogdocs/"; 9 #system("find $base -type f -exec rm {} \;");10 my %html; # perl file -> html file 6 my $pshb = Goats->new; 7 $pshb->batch_convert([qw(mogstored mogilefsd lib)], $base); 11 8 12 foreach my $f (@files) { 13 my $outfile = $f; 14 $outfile =~ s!^lib/!!; 15 $outfile =~ s!\.pm$!!; 16 $outfile .= ".html"; 17 system("install -D /dev/null $base/$outfile"); 18 system("pod2html --podroot=. --podpath=.:lib --htmlroot=/dev/mogdocs $f > $base/$outfile"); 19 print "F = $f => $outfile\n"; 20 $html{$f} = $outfile; 9 package Goats; 10 11 use strict; 12 use base 'Pod::Simple::HTMLBatch'; 13 14 sub modnames2paths { 15 my ($self, $dirs) = @_; 16 17 my @files; 18 my @dirs; 19 20 foreach my $path (@{$dirs || []}) { 21 if (-f $path) { 22 push @files, $path; 23 } else { 24 push @dirs, $path; 25 } 26 } 27 28 my $m2p = $self->SUPER::modnames2paths(\@dirs); 29 30 foreach my $file (@files) { 31 my ($tail) = $file =~ m!([^/]+)\z!; 32 $m2p->{$tail} = $file; 33 } 34 35 return $m2p; 21 36 } 22 23 open (my $fh, ">$base/index.html") or die;24 print $fh "<html><head><title>MogileFS server docs</title></head><body><pre>";25 foreach my $f (@files) {26 if (has_pod($f)) {27 print $fh "<a href='$html{$f}'>$f</a>\n";28 } else {29 print $fh "$f\n";30 }31 }32 print $fh "</pre></body></html>\n";33 close($fh);34 35 sub has_pod {36 my $f = shift;37 open(my $fh, $f) or die;38 while (<$fh>) {39 return 1 if /=head1/;40 }41 return 0;42 }
