Index: pkg/analyzer/tool/task_dependency_graph/generate.dart |
diff --git a/pkg/analyzer/tool/task_dependency_graph/generate.dart b/pkg/analyzer/tool/task_dependency_graph/generate.dart |
index 766ca03a8c6d341c26903bd126364d7568b69f3d..2b904bb7e308b5007ccccb61f1cb7a8155f86d17 100644 |
--- a/pkg/analyzer/tool/task_dependency_graph/generate.dart |
+++ b/pkg/analyzer/tool/task_dependency_graph/generate.dart |
@@ -42,9 +42,12 @@ import 'package:path/path.dart'; |
main() { |
String script = Platform.script.toFilePath(windows: Platform.isWindows); |
String pkgPath = normalize(join(dirname(script), '..', '..')); |
- GeneratedContent.generateAll(pkgPath, <GeneratedContent>[target]); |
+ GeneratedContent.generateAll(pkgPath, <GeneratedContent>[target, htmlTarget]); |
} |
+final GeneratedFile htmlTarget = new GeneratedFile( |
+ 'doc/tasks.html', (String pkgPath) => new Driver(pkgPath).generateHtml()); |
+ |
final GeneratedFile target = new GeneratedFile( |
'tool/task_dependency_graph/tasks.dot', |
(String pkgPath) => new Driver(pkgPath).generateFileContents()); |
@@ -52,6 +55,7 @@ final GeneratedFile target = new GeneratedFile( |
typedef void GetterFinderCallback(PropertyAccessorElement element); |
class Driver { |
+ static bool hasInitializedPlugins = false; |
PhysicalResourceProvider resourceProvider; |
AnalysisContext context; |
InterfaceType resultDescriptorType; |
@@ -59,6 +63,7 @@ class Driver { |
ClassElement enginePluginClass; |
CompilationUnitElement taskUnitElement; |
InterfaceType extensionPointIdType; |
+ |
final String rootDir; |
Driver(String pkgPath) : rootDir = new Directory(pkgPath).absolute.path; |
@@ -121,7 +126,28 @@ class Driver { |
* Generate the task dependency graph and return it as a [String]. |
*/ |
String generateFileContents() { |
- AnalysisEngine.instance.processRequiredPlugins(); |
+ return ''' |
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+// |
+// This file has been automatically generated. Please do not edit it manually. |
+// To regenerate the file, use the script |
+// "pkg/analyzer/tool/task_dependency_graph/generate.dart". |
+// |
+// To render this graph using Graphviz (www.graphviz.org) use the command: |
+// "dot tasks.dot -Tpdf -O". |
+digraph G { |
+${generateGraphData()} |
+} |
+'''; |
+ } |
+ |
+ String generateGraphData() { |
+ if (!hasInitializedPlugins) { |
+ AnalysisEngine.instance.processRequiredPlugins(); |
+ hasInitializedPlugins = true; |
+ } |
List<String> lines = <String>[]; |
resourceProvider = PhysicalResourceProvider.INSTANCE; |
DartSdk sdk = DirectoryBasedDartSdk.defaultSdk; |
@@ -197,20 +223,32 @@ class Driver { |
lines.add(' $result [shape=box]'); |
} |
lines.sort(); |
+ return lines.join('\n'); |
+ } |
+ |
+ String generateHtml() { |
return ''' |
-// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
-// for details. All rights reserved. Use of this source code is governed by a |
-// BSD-style license that can be found in the LICENSE file. |
-// |
-// This file has been automatically generated. Please do not edit it manually. |
-// To regenerate the file, use the script |
-// "pkg/analyzer/tool/task_dependency_graph/generate.dart". |
-// |
-// To render this graph using Graphviz (www.graphviz.org) use the command: |
-// "dot tasks.dot -Tpdf -O". |
+<!DOCTYPE html> |
+<html> |
+<head> |
+ <title>Analysis Task Dependency Graph</title> |
+ <link rel="stylesheet" href="support/style.css"> |
+ <script src="support/viz.js"></script> |
+ <script type="application/dart" src="support/web_app.dart.js"></script> |
+ <script src="support/dart.js"></script> |
+</head> |
+<body> |
+<button id="zoomBtn">Zoom</button> |
+<script type="text/vnd.graphviz" id="dot"> |
digraph G { |
-${lines.join('\n')} |
+ tooltip="Analysis Task Dependency Graph"; |
+ node [fontname=Helvetica]; |
+ edge [fontname=Helvetica, fontcolor=gray]; |
+${generateGraphData()} |
} |
+</script> |
+</body> |
+</html> |
'''; |
} |