#!/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 < Sequence Logic Code Documentation 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 = "

Contents

\n