Changeset 644

Show
Ignore:
Timestamp:
01/05/07 10:44:51 (3 years ago)
Author:
hachi
Message:

r23460@lj: lj | 2007-01-04 15:51:37 -0800
Better doc generation... now I just need to get the index file correct.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/server/makedocs.pl

    r587 r644  
    22 
    33use strict; 
    4 my @files = ("mogstored", "mogilefsd"); 
    5 push @files, `find lib -name '*.pm'`; 
    6 chomp @files; 
    74 
    85my $base = "/home/lj/htdocs/dev/mogdocs/"; 
    9 #system("find $base -type f -exec rm {} \;"); 
    10 my %html; # perl file -> html file 
     6my $pshb = Goats->new; 
     7$pshb->batch_convert([qw(mogstored mogilefsd lib)], $base); 
    118 
    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; 
     9package Goats; 
     10 
     11use strict; 
     12use base 'Pod::Simple::HTMLBatch'; 
     13 
     14sub 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; 
    2136} 
    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 }