123 lines
4.3 KiB
Perl
123 lines
4.3 KiB
Perl
#!/usr/bin/perl
|
|
|
|
# updateMasterIndex.pl {path to un-jarred documentation}
|
|
# updateMasterIndex.pl /var/www/html/development
|
|
# This script will find all the project documentation's index.html
|
|
# files, and create a top level 'master' for use with docserv.
|
|
|
|
if (@ARGV != 1)
|
|
{
|
|
print "Usage:\n";
|
|
print "updateMasterIndex.pl {path to un-jarred documentation}\n";
|
|
}
|
|
else
|
|
{
|
|
%remoteBranchHash = {};
|
|
@remoteBranches = `git ls-remote --heads ssh://git.sl.int/git`;
|
|
@remoteBranches = (@remoteBranches, `git ls-remote --heads ssh://git.sl.int/git-restricted`);
|
|
foreach $remoteBranch (@remoteBranches)
|
|
{
|
|
chomp $remoteBranch;
|
|
$remoteBranch =~ s/^.*refs\/heads\///g;
|
|
$remoteBranch =~ s/\//-/g;
|
|
$remoteBranchHash{$remoteBranch} = 1;
|
|
}
|
|
@indexFiles = `find $ARGV[0] -name "index.html"`;
|
|
if (@indexFiles > 0)
|
|
{
|
|
# Create a file called "masterIndex.html" in the dest directory.
|
|
if (open(MASTER_IDX_FILE, ">$ARGV[0]/masterIndex.html"))
|
|
{
|
|
print MASTER_IDX_FILE <<ENDOFHEADER;
|
|
<html>
|
|
<head>
|
|
<title>Sequence Logic Code Documentation</title>
|
|
</head>
|
|
<body>
|
|
ENDOFHEADER
|
|
|
|
foreach $indexFile (@indexFiles)
|
|
{
|
|
chomp $indexFile;
|
|
if (index($indexFile, "pit-reports") == 0)
|
|
{
|
|
next;
|
|
}
|
|
$indexFile =~ s/$ARGV[0]//g;
|
|
if (index($indexFile, "/") == 0)
|
|
{
|
|
$indexFile = substr($indexFile, 1);
|
|
}
|
|
|
|
#print "Found index: $indexFile\n";
|
|
@pathList = split(/\//, $indexFile);
|
|
$branchName = "";
|
|
$i = 0;
|
|
foreach $pathPart(@pathList)
|
|
{
|
|
#print " Path part: $pathPart\n";
|
|
if ($i < @pathList - 2)
|
|
{
|
|
$branchName .= $pathPart; # + "/";
|
|
$branchName .= "-";
|
|
}
|
|
++$i;
|
|
}
|
|
chop $branchName;
|
|
# If this branch is in Git, display it!
|
|
if (exists($remoteBranchHash{$branchName}))
|
|
{
|
|
open (TMP_BRANCH_FILE, ">>$ARGV[0]/$branchName.tmpBranch");
|
|
print TMP_BRANCH_FILE "$indexFile\n";
|
|
close TMP_BRANCH_FILE;
|
|
|
|
print "Index file: $indexFile, Branch name: $branchName\n";
|
|
}
|
|
}
|
|
|
|
$contentsBlock = " <H1>Contents</h1>\n <ul>\n";
|
|
$linkBlock = "";
|
|
@branchFiles = `ls -1 $ARGV[0]/*.tmpBranch`;
|
|
foreach $branch (@branchFiles)
|
|
{
|
|
chomp $branch;
|
|
$branchName = $branch;
|
|
$branchName =~ s/-/\//g;
|
|
$branchName =~ s/\.tmpBranch//g;
|
|
$branchName =~ s/$ARGV[0]//g;
|
|
if (index($branchName, "/") == 0)
|
|
{
|
|
$branchName = substr($branchName, 1);
|
|
}
|
|
|
|
#print MASTER_IDX_FILE " <h2>Branch: $branchName</h2>\n";
|
|
$contentsBlock .= " <li><a href=\"#$branchName\">$branchName</a></li>";
|
|
$linkBlock .= " <a name=\"$branchName\"><h2>Branch: $branchName</h2></a>\n";
|
|
if (open (BRANCH_FILE, "<$branch"))
|
|
{
|
|
while (<BRANCH_FILE>)
|
|
{
|
|
chomp;
|
|
@pathList = split(/\//);
|
|
#print MASTER_IDX_FILE "<a href=\"$_\">$pathList[@pathList - 2]</a><br>\n";
|
|
$linkBlock .= " <a href=\"$_\">$pathList[@pathList - 2]</a><br>\n"
|
|
}
|
|
close BRANCH_FILE;
|
|
unlink $branch or die "Failed to delete temp file ($branch): $!";
|
|
}
|
|
else
|
|
{
|
|
print MASTER_IDX_FILE "<b>ERROR: Cannot read temp file $branch</b><br>\n";
|
|
}
|
|
}
|
|
print MASTER_IDX_FILE $contentsBlock;
|
|
print MASTER_IDX_FILE $linkBlock;
|
|
print MASTER_IDX_FILE <<ENDOFFOOTER;
|
|
</body>
|
|
</html>
|
|
ENDOFFOOTER
|
|
}
|
|
}
|
|
}
|
|
|