#!/usr/bin/env python2 # usage="""usage: %prog [options] url Run the doxygen installdox script for each package so that the interpackage links will work correctly. The url specifies where the packages will be found. It can either be a web URL, or the cmt path root. This is used by build-doxygen-pages.py, and must be run"in-place".""" import optparse import sys import os.path import re import commands def System(command, dryrun=True): """Run a command this isn't a dry run.""" print "System(" + command + ")" if not options.DryRun: os.system(command) def CMTMakeDoxygen(): """Build all of the doxygen pages """ print "***** Build Documentation *****" # It's better to skip a broken package than to stop building all remaining # documentation System("cmt broadcast '(rm -f ../doc/dox ; make doxygen || true)'") print "***** Documentation Built *****" def CMTListPackages(): """Find list of all the packages to be scanned""" print "***** List Available Packages *****" output=commands.getoutput("cmt broadcast '(" + "echo ::::" + ")'") dict = {} for match in re.finditer("(?m)^:(.*):(.*):(.*):",output): (root, name, version) = match.groups() path = root + '/packages/'+ name dox = path + '/doc/dox' print "Check " + name + "_" + version + ".tag" if os.path.exists(dox): print " exists in " + dox tag = name + "_" + version + ".tag" dict[tag] = (name,version,root,path) print "***** Available Packages Listed *****" return dict def ParseInstalldox(input): """Parse an installdox file to find the tag files The installdox program requires a list of tag files to substitute links for in the documentation. Unfortunately, it doesn't provide any easy way of getting a list of required files. This routine kludges this by reading the installdox (perl) file and parsing out the required information. Returns a list of required tag files. """ try: installdox = file(input).read() match = re.search(r"%subst.*=.*\((.*)\).*;",installdox) return re.findall(r"\"([^\"]*tag)\"",match.group(1)) except: return None def RunInstalldox(path,url,dict): print "**** Running installdox ****" tags = ParseInstalldox(path + "/doc/dox/installdox") if tags == None: return installdox = "installdox" for tag in tags: try: (package, version, root, source) = dict[tag] installdox = installdox + " -l " + tag + "@" if url != "": installdox = installdox + url + "/" installdox = installdox + package + "/dox" except: print "Missing tag " + tag System("(cd " + path + "/doc/dox ; ./" + installdox + ")") print "**** installdox run ****" ############################################################# # START THE REAL SCRIPT # Parse the options for this installation. parser = optparse.OptionParser(usage=usage) parser.add_option("-d","--dry-run", dest="DryRun", action = "store_true", default=False, help="do a dry run without running the actual commands") (options, args) = parser.parse_args() # Set the home page url. try: homepage = args[0] except: homepage="" # Build all of the doxygen files. CMTMakeDoxygen() # Get a list of all of the doxygen directories. packageDict = CMTListPackages() print packageDict # Run installdox on all of the packages. print "**** Run installdox on all packages *****" for key,dict in packageDict.iteritems(): (name,version,root,path) = dict print "Installing Documentation for " + name + " " + version installdox = root + "/packages/" + name + "/" + version + "/doc/dox/installdox" RunInstalldox(path,homepage,packageDict) print "**** All Done ****"