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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
#!/usr/bin/perl -w
# This is a utility to create the history
# include files for the EMBOSS application documentation.
# GWW 24 Jan 2003
###################################################################
#
# Some useful definitions
#
###################################################################
# where the web pages include files live
$incdir = "/data/www/Software/EMBOSS/Apps/inc";
# colours for backgrounds of usage examples, input and output files
$outputcolour = "#FFFFCC"; # light yellow
###################################################################
# run cvs to create the logs for all applications
my $apps = "app.log";
my $acds = "acd.log";
my $app;
my $acd;
my @files;
my $line;
my ($date, $author, $desc);
chdir "/packages/emboss_dev/$ENV{'USER'}/emboss/emboss/emboss/";
system("cvs log *.c >$apps");
parse($apps);
unlink $apps;
chdir "/packages/emboss_dev/$ENV{'USER'}/emboss/emboss/emboss/acd/";
system("cvs log *.acd >$acds");
parse($acds);
unlink $acds;
# merge the two sets of files together
chdir $incdir;
@files = glob("*.applog");
foreach $app (@files) {
($file) = ($app =~ /(\S+)\.applog/);
$acd = $file . ".acdlog";
if (-f $acd) {
system("cat $acd >> $app");
system("sort $app > $app.sorted");
if (open(SORT, "< $app.sorted")) {
open (OUT, "> $file.history") || die "Can't open history file\n";
print OUT "<table border cellspacing=0 cellpadding=3 bgcolor=\"$outputcolour\">\n";
print OUT "<tr><th>Date</th><th>Editor</th><th>Comment</th></tr>\n";
while ($line = <SORT>) {
($date, $author, $desc) = ($line =~ /(\S+)\s+(\S+)\s+(.+)/);
print OUT "<tr><td>$date</td><td>$author</td><td>$desc</td></tr>\n";
}
print OUT "</table>\n";
close(SORT);
close(OUT);
chmod 0664, "$file.history"; # rw-rw-r--
}
unlink "$app.sorted";
unlink $acd;
}
unlink $app;
}
exit(0);
###################################################################
# Name: parse
# Function: Gets history data from log files.
# Produces intermediate data file.
# Args:
# file - file name to parse
# Returns: parsed data returned in 'data'
###################################################################
sub parse {
my ($file) = @_;
my $line;
my $desc;
my $outfile = ""; # initialise it to blank to indicate we have no open files
open (LOG, "< $file") || die "Couldn't open file $file";
while ($line = <LOG>) {
# get the name of the next output file
if ($line =~ "RCS file:") {
($outfile, $extension) = ($line =~ /RCS file: \/home\/repository\/emboss\/emboss\/emboss\/emboss\/(\S+)\.(\S)/);
# close previous file
if ($outfile ne "") {
close (OUT);
}
# open new file
#print "ext=$extension\n";
if ($extension eq "c") { # .c file
#print "open $outfile.applog\n";
open (OUT, "> $incdir/$outfile.applog");
$extra = "Program:";
} else { # .acd file
$outfile =~ s/acd\///; # remove the 'acd/' from the file name
#print "open $outfile.acdlog\n";
open (OUT, "> $incdir/$outfile.acdlog");
$extra = "ACD file:";
}
}
if ($line =~ "date") {
($date, $author) = ($line =~ /\S+\s+(\S+)\s+\S+\s+\S+\s+(\S+);/);
$desc = <LOG>;
chomp $desc;
# change any ampersands or angle brackets to HTML codes
$desc =~ s/&/&/g;
$desc =~ s/</</g;
$desc =~ s/>/>/g;
# write data out
print OUT "$date\t$author\t$extra $desc\n";
}
}
close (OUT);
close (LOG);
}
|