Mercurial > hg > truffle
comparison mxtool/mx.py @ 6506:305b9166b455
added projects table to the top level javadoc page generated by the site command
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 04 Oct 2012 11:22:09 +0200 |
parents | f45d5cb03c3b |
children | 534c45127aad |
comparison
equal
deleted
inserted
replaced
6505:1ecf984d490c | 6506:305b9166b455 |
---|---|
1213 | 1213 |
1214 if suppliedParser: | 1214 if suppliedParser: |
1215 parser.add_argument('remainder', nargs=REMAINDER, metavar='...') | 1215 parser.add_argument('remainder', nargs=REMAINDER, metavar='...') |
1216 | 1216 |
1217 args = parser.parse_args(args) | 1217 args = parser.parse_args(args) |
1218 | 1218 |
1219 jdtJar = None | 1219 jdtJar = None |
1220 if args.jdt is not None: | 1220 if args.jdt is not None: |
1221 if args.jdt.endswith('.jar'): | 1221 if args.jdt.endswith('.jar'): |
1222 jdtJar=args.jdt | 1222 jdtJar=args.jdt |
1223 if not exists(jdtJar) and os.path.abspath(jdtJar) == os.path.abspath(defaultEcjPath): | 1223 if not exists(jdtJar) and os.path.abspath(jdtJar) == os.path.abspath(defaultEcjPath): |
2428 try: | 2428 try: |
2429 # Create javadoc for each project | 2429 # Create javadoc for each project |
2430 javadoc(['--base', tmpbase] + exclude_packages_arg + projects_arg + extra_javadoc_args) | 2430 javadoc(['--base', tmpbase] + exclude_packages_arg + projects_arg + extra_javadoc_args) |
2431 | 2431 |
2432 # Create unified javadoc for all projects | 2432 # Create unified javadoc for all projects |
2433 with open(args.overview) as fp: | |
2434 content = fp.read() | |
2435 idx = content.rfind('</body>') | |
2436 if idx != -1: | |
2437 args.overview = join(tmpbase, 'overview_with_projects.html') | |
2438 with open(args.overview, 'w') as fp2: | |
2439 print >> fp2, content[0:idx] | |
2440 print >> fp2, """<div class="contentContainer"> | |
2441 <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Projects table"> | |
2442 <caption><span>Projects</span><span class="tabEnd"> </span></caption> | |
2443 <tr><th class="colFirst" scope="col">Project</th><th class="colLast" scope="col"> </th></tr> | |
2444 <tbody>""" | |
2445 color = 'row' | |
2446 for p in projects: | |
2447 print >> fp2, '<tr class="{1}Color"><td class="colFirst"><a href="../{0}/javadoc/index.html", target = "_top">{0}</a></td><td class="colLast"> </td></tr>'.format(p.name, color) | |
2448 color = 'row' if color == 'alt' else 'alt' | |
2449 | |
2450 print >> fp2, '</tbody></table></div>' | |
2451 print >> fp2, content[idx:] | |
2452 | |
2433 title = args.title if args.title is not None else args.name | 2453 title = args.title if args.title is not None else args.name |
2434 javadoc(['--base', tmpbase, | 2454 javadoc(['--base', tmpbase, |
2435 '--unified', | 2455 '--unified', |
2436 '--arg', '@-windowtitle', '--arg', '@' + title, | 2456 '--arg', '@-windowtitle', '--arg', '@' + title, |
2437 '--arg', '@-doctitle', '--arg', '@' + title, | 2457 '--arg', '@-doctitle', '--arg', '@' + title, |
2438 '--arg', '@-overview', '--arg', '@' + args.overview] + exclude_packages_arg + projects_arg + extra_javadoc_args) | 2458 '--arg', '@-overview', '--arg', '@' + args.overview] + exclude_packages_arg + projects_arg + extra_javadoc_args) |
2439 os.rename(join(tmpbase, 'javadoc'), unified) | 2459 os.rename(join(tmpbase, 'javadoc'), unified) |
2440 | 2460 |
2441 # Generate dependency graph with Graphviz | 2461 # Generate dependency graph with Graphviz |
2442 if args.dot_output_base is not None: | 2462 if args.dot_output_base is not None: |
2463 dotErr = None | |
2464 try: | |
2465 if not 'version' in subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT): | |
2466 dotErr = 'dot -V does not print a string containing "version"' | |
2467 except subprocess.CalledProcessError as e: | |
2468 dotErr = 'error calling "dot -V": {}'.format(e) | |
2469 except OSError as e: | |
2470 dotErr = 'error calling "dot -V": {}'.format(e) | |
2471 | |
2472 if dotErr != None: | |
2473 abort('cannot generate dependency graph: ' + dotErr) | |
2474 | |
2443 dot = join(tmpbase, 'all', str(args.dot_output_base) + '.dot') | 2475 dot = join(tmpbase, 'all', str(args.dot_output_base) + '.dot') |
2444 svg = join(tmpbase, 'all', str(args.dot_output_base) + '.svg') | 2476 svg = join(tmpbase, 'all', str(args.dot_output_base) + '.svg') |
2445 jpg = join(tmpbase, 'all', str(args.dot_output_base) + '.jpg') | 2477 jpg = join(tmpbase, 'all', str(args.dot_output_base) + '.jpg') |
2446 html = join(tmpbase, 'all', str(args.dot_output_base) + '.html') | 2478 html = join(tmpbase, 'all', str(args.dot_output_base) + '.html') |
2447 with open(dot, 'w') as fp: | 2479 with open(dot, 'w') as fp: |
2459 depths = dict() | 2491 depths = dict() |
2460 for p in projects: | 2492 for p in projects: |
2461 d = p.max_depth() | 2493 d = p.max_depth() |
2462 depths.setdefault(d, list()).append(p.name) | 2494 depths.setdefault(d, list()).append(p.name) |
2463 print >> fp, '}' | 2495 print >> fp, '}' |
2464 | 2496 |
2465 run(['dot', '-Tsvg', '-o' + svg, '-Tjpg', '-o' + jpg, dot]) | 2497 run(['dot', '-Tsvg', '-o' + svg, '-Tjpg', '-o' + jpg, dot]) |
2466 | 2498 |
2467 # Post-process generated SVG to remove title elements which most browsers | 2499 # Post-process generated SVG to remove title elements which most browsers |
2468 # render as redundant (and annoying) tooltips. | 2500 # render as redundant (and annoying) tooltips. |
2469 with open(svg, 'r') as fp: | 2501 with open(svg, 'r') as fp: |
2470 content = fp.read() | 2502 content = fp.read() |
2471 content = re.sub('<title>.*</title>', '', content) | 2503 content = re.sub('<title>.*</title>', '', content) |
2472 content = re.sub('xlink:title="[^"]*"', '', content) | 2504 content = re.sub('xlink:title="[^"]*"', '', content) |
2473 with open(svg, 'w') as fp: | 2505 with open(svg, 'w') as fp: |
2474 fp.write(content) | 2506 fp.write(content) |
2475 | 2507 |
2476 # Create HTML that embeds the svg file in an <object> frame | 2508 # Create HTML that embeds the svg file in an <object> frame |
2477 with open(html, 'w') as fp: | 2509 with open(html, 'w') as fp: |
2478 print >> fp, '<html><body><object data="modules.svg" type="image/svg+xml"></object></body></html>' | 2510 print >> fp, '<html><body><object data="{}.svg" type="image/svg+xml"></object></body></html>'.format(args.dot_output_base) |
2479 | 2511 |
2480 top = join(tmpbase, 'all', 'overview-summary.html') | 2512 top = join(tmpbase, 'all', 'overview-summary.html') |
2481 for root, _, files in os.walk(tmpbase): | 2513 for root, _, files in os.walk(tmpbase): |
2482 for f in files: | 2514 for f in files: |
2483 if f == 'overview-summary.html': | 2515 if f == 'overview-summary.html': |