# HG changeset patch # User Doug Simon # Date 1340751799 -7200 # Node ID 12a34d1bcaa26da4abea174ce0ebd83852d601a1 # Parent e9f7d16194a85be49cf81f7165267e8f4336bc51 added site command to generate a javadoc-based website diff -r e9f7d16194a8 -r 12a34d1bcaa2 graal/overview.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/overview.html Wed Jun 27 01:03:19 2012 +0200 @@ -0,0 +1,42 @@ + + + + + + + + + + + +

+This document is the unified Javadoc for the Graal code base. +The module dependency graph is shown above. +Each node in the diagram is a link to the standalone Javadoc for the denoted module. + + + diff -r e9f7d16194a8 -r 12a34d1bcaa2 mx/commands.py --- a/mx/commands.py Wed Jun 27 01:02:43 2012 +0200 +++ b/mx/commands.py Wed Jun 27 01:03:19 2012 +0200 @@ -1001,6 +1001,68 @@ mx.abort('jacocoreport takes only one argument : an output directory') mx.run_java(['-jar', jacocoreport.get_path(True), '-in', 'jacoco.exec', '-g', join(_graal_home, 'graal'), out]) +def site(args): + """creates a website containing javadoc and the project dependency graph""" + + parser = ArgumentParser(prog='site') + parser.add_argument('-d', '--base', action='store', help='directory for generated site', required=True, metavar='

') + parser.add_argument('-c', '--clean', action='store_true', help='remove existing site in ') + + args = parser.parse_args(args) + + args.base = os.path.abspath(args.base) + + if not exists(args.base): + os.mkdir(args.base) + elif args.clean: + shutil.rmtree(args.base) + os.mkdir(args.base) + + mx.javadoc(['--base', args.base]) + + unified = join(args.base, 'all') + if exists(unified): + shutil.rmtree(unified) + mx.javadoc(['--base', args.base, '--unified', '--arg', '@-overview', '--arg', '@' + join(_graal_home, 'graal', 'overview.html')]) + os.rename(join(args.base, 'javadoc'), unified) + + _, tmp = tempfile.mkstemp() + try: + svg = join(args.base, 'all', 'modules.svg') + with open(tmp, 'w') as fp: + print >> fp, 'digraph projects {' + print >> fp, 'rankdir=BT;' + print >> fp, 'size = "13,13";' + print >> fp, 'node [shape=rect, fontcolor="blue"];' + print >> fp, 'edge [color="green"];' + for p in mx.projects(): + print >> fp, '"' + p.name + '" [URL = "../' + p.name + '/javadoc/index.html", target = "_top"]' + for dep in p.canonical_deps(): + if mx.project(dep, False): + print >> fp, '"' + p.name + '" -> "' + dep + '"' + depths = dict() + for p in mx.projects(): + d = p.max_depth() + depths.setdefault(d, list()).append(p.name) + for d, names in depths.iteritems(): + print >> fp, '{ rank = same; "' + '"; "'.join(names) + '"; }' + print >> fp, '}' + + mx.run(['dot', '-Tsvg', '-o' + svg, tmp]) + + # Post-process generated SVG to remove unified title elements which most browsers + # render as redundant (and annoying) tooltips. + with open(svg, 'r') as fp: + content = fp.read() + content = re.sub('.*', '', content) + content = re.sub('xlink:title="[^"]*"', '', content) + with open(svg, 'w') as fp: + fp.write(content) + + print 'Created website - root is ' + join(unified, 'index.html') + finally: + os.remove(tmp) + def mx_init(): _vmbuild = 'product' commands = { @@ -1022,6 +1084,7 @@ 'unittest' : [unittest, '[filters...]'], 'jtt' : [jtt, '[filters...]'], 'jacocoreport' : [jacocoreport, '[output directory]'], + 'site' : [site, '[-options]'], 'vm': [vm, '[-options] class [args...]'], 'vmg': [vmg, '[-options] class [args...]'], 'vmfg': [vmfg, '[-options] class [args...]']