diff mx/commands.py @ 5771:613a3ddb9a71

moved core site functionality into mx.py
author Doug Simon <doug.simon@oracle.com>
date Thu, 05 Jul 2012 16:24:18 +0200
parents 66ec0bc36a37
children 488864d5069a
line wrap: on
line diff
--- a/mx/commands.py	Thu Jul 05 11:18:12 2012 +0200
+++ b/mx/commands.py	Thu Jul 05 16:24:18 2012 +0200
@@ -969,142 +969,13 @@
         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 _fix_overview_summary(path, topLink):
-    """
-    Processes an "overview-summary.html" generated by javadoc to put the complete
-    summary text above the Packages table.
-    """
-
-    # This uses scraping and so will break if the relevant content produced by javadoc changes in any way!
-    with open(path) as fp:
-        content = fp.read()
-
-    class Chunk:
-        def __init__(self, content, ldelim, rdelim):
-            lindex = content.find(ldelim)
-            rindex = content.find(rdelim)
-            self.ldelim = ldelim
-            self.rdelim = rdelim
-            if lindex != -1 and rindex != -1 and rindex > lindex:
-                self.text = content[lindex + len(ldelim):rindex]
-            else:
-                self.text = None
-
-        def replace(self, content, repl):
-            lindex = content.find(self.ldelim)
-            rindex = content.find(self.rdelim)
-            old = content[lindex:rindex + len(self.rdelim)]
-            return content.replace(old, repl)
-
-    chunk1 = Chunk(content, """<div class="header">
-<div class="subTitle">
-<div class="block">""", """</div>
-</div>
-<p>See: <a href="#overview_description">Description</a></p>
-</div>""")
-
-    chunk2 = Chunk(content, """<div class="footer"><a name="overview_description">
-<!--   -->
-</a>
-<div class="subTitle">
-<div class="block">""", """</div>
-</div>
-</div>
-<!-- ======= START OF BOTTOM NAVBAR ====== -->""")
-
-    assert chunk1.text, 'Could not find header section in ' + path
-    assert chunk2.text, 'Could not find footer section in ' + path
-
-    content = chunk1.replace(content, '<div class="header"><div class="subTitle"><div class="block">' + topLink + chunk2.text +'</div></div></div>')
-    content = chunk2.replace(content, '')
-
-    with open(path, 'w') as fp:
-        fp.write(content)
-
 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>')
-
-    args = parser.parse_args(args)
-
-    args.base = os.path.abspath(args.base)
-    tmpbase = tempfile.mkdtemp(prefix=basename(args.base) + '.', dir=dirname(args.base))
-    unified = join(tmpbase, 'all')
-
-    try:
-        # Create javadoc for each project
-        mx.javadoc(['--base', tmpbase])
-
-        # Create unified javadoc for all projects
-        mx.javadoc(['--base', tmpbase,
-                    '--unified',
-                    '--arg', '@-windowtitle', '--arg', '@Graal OpenJDK Project Documentation',
-                    '--arg', '@-doctitle', '--arg', '@Graal OpenJDK Project Documentation',
-                    '--arg', '@-overview', '--arg', '@' + join(_graal_home, 'graal', 'overview.html')])
-        os.rename(join(tmpbase, 'javadoc'), unified)
-
-        # Generate dependency graph with Graphviz
-        _, tmp = tempfile.mkstemp()
-        try:
-            svg = join(tmpbase, 'all', 'modules.svg')
-            jpg = join(tmpbase, 'all', 'modules.jpg')
-            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, '-Tjpg', '-o' + jpg, tmp])
-
-        finally:
-            os.remove(tmp)
-
-        # Post-process generated SVG to remove 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)
-
-        # Post-process generated overview-summary.html files
-        top = join(tmpbase, 'all', 'overview-summary.html')
-        for root, _, files in os.walk(tmpbase):
-            for f in files:
-                if f == 'overview-summary.html':
-                    path = join(root, f)
-                    topLink = ''
-                    if top != path:
-                        link = os.path.relpath(join(tmpbase, 'all', 'index.html'), dirname(path))
-                        topLink = '<p><a href="' + link + '", target="_top"><b>[return to the overall Graal documentation]</b></a></p>'
-                    _fix_overview_summary(path, topLink)
-
-
-        if exists(args.base):
-            shutil.rmtree(args.base)
-        shutil.move(tmpbase, args.base)
-
-        print 'Created website - root is ' + join(args.base, 'all', 'index.html')
-
-    finally:
-        if exists(tmpbase):
-            shutil.rmtree(tmpbase)
+    return mx.site(['--name', 'Graal',
+                    '--overview', join(_graal_home, 'graal', 'overview.html'),
+                    '--title', 'Graal OpenJDK Project Documentation',
+                    '--dot-output-base', 'modules'] + args)
 
 def mx_init():
     _vmbuild = 'product'