Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 80 lines (66 sloc) 1.522 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
#!/usr/bin/perl -w
use strict;

use Cwd;

# doco.perl - 24 Jan 18:09:40 EST 2001
# Addi - (addi@umich.edu)
#
# Extract documentation and help from the source files
#
# -f <files> list FIXME comments for files
# -f list FIXME comments for all files
# -d <file> list pod comments from file

my $comm = shift or USAGE();

my @files;
if ($comm eq "-f") {
if (@ARGV) {
@files = @ARGV;
}
else {
@files = getfiles();
}

for my $file (@files) {
local(*FH, $/); open(FH,"< $file") or die $!;
my $data = <FH>; close(FH);
while( $data =~ m/FIXME:(.*?)\*\//sg ) {
printf("%10.10s:%5d %s\n", $file, ptol($data, pos($data)), $1);
}
}
exit(0);
}

if ($comm eq "-d") {
USAGE() if !@ARGV;
my $file = shift;
getfiles();
local(*FH, $/); open(FH, "< $file") or die $!;
my $data = <FH>; close(FH);
$data =~ s/^(=item)/\n$1/mg;
$data =~ s/^(=cut)/\n~~~~~~~~\n\n$1\n\n/mg;
print "\n";
open(FH,"|pod2text ") or die "Cannot run pod2text: $!\n";
print FH $data;
close(FH);
exit(2);
}


sub USAGE {

print<<'EOF';
doco.perl [-f files| stuff]

-f <files> list FIXME comments for files.
-f list FIXME comments for all files.

EOF
exit;
}

sub getfiles {
my $BASE=cwd;
local(*FH);
open(FH,"$BASE/MANIFEST") or die "Cannot open MANIFEST file: $!\n";
my @MANIFEST = <FH>;
chomp(@MANIFEST);
return grep { m/\.(c|im)\s*$/ } @MANIFEST;
}

# string position to line number in string

sub ptol {
my ($str, $pos) = @_;
my $lcnt=1;
$lcnt++ while(substr($str,0,$pos)=~m/\n/g);
$lcnt;
}
Something went wrong with that request. Please try again.