Mercurial > hg > graal-jvmci-8
changeset 5700:12a34d1bcaa2
added site command to generate a javadoc-based website
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 27 Jun 2012 01:03:19 +0200 |
parents | e9f7d16194a8 |
children | d0a6e25de770 |
files | graal/overview.html mx/commands.py |
diffstat | 2 files changed, 105 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /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 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head> +<!-- + +Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + +This code is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License version 2 only, as +published by the Free Software Foundation. Oracle designates this +particular file as subject to the "Classpath" exception as provided +by Oracle in the LICENSE file that accompanied this code. + +This code is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +version 2 for more details (a copy is included in the LICENSE file that +accompanied this code). + +You should have received a copy of the GNU General Public License version +2 along with this work; if not, write to the Free Software Foundation, +Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +or visit www.oracle.com if you need additional information or have any +questions. +--> + +</head> +<body bgcolor="white"> + +<body> + +<a href="modules.svg" title="Click to enlarge"><img src="modules.svg" width="400"/></a> +<p> +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. + +</body> +</html>
--- 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='<dir>') + parser.add_argument('-c', '--clean', action='store_true', help='remove existing site in <dir>') + + 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('<title>.*</title>', '', 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...]']