| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /// **docgen** is a tool for creating machine readable representations of Dart | 5 /// **docgen** is a tool for creating machine readable representations of Dart |
| 6 /// code metadata, including: classes, members, comments and annotations. | 6 /// code metadata, including: classes, members, comments and annotations. |
| 7 /// | 7 /// |
| 8 /// docgen is run on a `.dart` file or a directory containing `.dart` files. | 8 /// docgen is run on a `.dart` file or a directory containing `.dart` files. |
| 9 /// | 9 /// |
| 10 /// $ dart docgen.dart [OPTIONS] [FILE/DIR] | 10 /// $ dart docgen.dart [OPTIONS] [FILE/DIR] |
| (...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 else { | 722 else { |
| 723 var processResult = Process.runSync('git', ['clone', '-b', 'master', | 723 var processResult = Process.runSync('git', ['clone', '-b', 'master', |
| 724 'git://github.com/dart-lang/dartdoc-viewer.git'], | 724 'git://github.com/dart-lang/dartdoc-viewer.git'], |
| 725 runInShell: true); | 725 runInShell: true); |
| 726 | 726 |
| 727 if (processResult.exitCode == 0) { | 727 if (processResult.exitCode == 0) { |
| 728 /// Move the generated json/yaml docs directory to the dartdoc-viewer | 728 /// Move the generated json/yaml docs directory to the dartdoc-viewer |
| 729 /// directory, to run as a webpage. | 729 /// directory, to run as a webpage. |
| 730 var processResult = Process.runSync(_Generator._pubScript, | 730 var processResult = Process.runSync(_Generator._pubScript, |
| 731 ['upgrade'], runInShell: true, | 731 ['upgrade'], runInShell: true, |
| 732 workingDirectory: path.join(viewerCodePath, 'client')); | 732 workingDirectory: viewerCodePath); |
| 733 print('process output: ${processResult.stdout}'); | 733 print('process output: ${processResult.stdout}'); |
| 734 print('process stderr: ${processResult.stderr}'); | 734 print('process stderr: ${processResult.stderr}'); |
| 735 | 735 |
| 736 var dir = new Directory(_Generator._outputDirectory == null? 'docs' : | 736 var dir = new Directory(_Generator._outputDirectory == null? 'docs' : |
| 737 _Generator._outputDirectory); | 737 _Generator._outputDirectory); |
| 738 _webDocsDir = new Directory(path.join(viewerCodePath, 'client', | 738 _webDocsDir = new Directory(path.join(viewerCodePath, 'web', 'docs')); |
| 739 'web', 'docs')); | |
| 740 if (dir.existsSync()) { | 739 if (dir.existsSync()) { |
| 741 // Move the docs folder to dartdoc-viewer/client/web/docs | 740 // Move the docs folder to dartdoc-viewer/client/web/docs |
| 742 dir.renameSync(_webDocsDir.path); | 741 dir.renameSync(_webDocsDir.path); |
| 743 } | 742 } |
| 744 } else { | 743 } else { |
| 745 print('Error cloning git repository:'); | 744 print('Error cloning git repository:'); |
| 746 print('process output: ${processResult.stdout}'); | 745 print('process output: ${processResult.stdout}'); |
| 747 print('process stderr: ${processResult.stderr}'); | 746 print('process stderr: ${processResult.stderr}'); |
| 748 } | 747 } |
| 749 } | 748 } |
| 750 } | 749 } |
| 751 | 750 |
| 752 static void _compile() { | 751 static void _compile() { |
| 753 if (_webDocsDir.existsSync()) { | 752 if (_webDocsDir.existsSync()) { |
| 754 // Compile the code to JavaScript so we can run on any browser. | 753 // Compile the code to JavaScript so we can run on any browser. |
| 755 print('Compile app to JavaScript for viewing.'); | 754 print('Compile app to JavaScript for viewing.'); |
| 756 var processResult = Process.runSync(_Generator._dartBinary, | 755 var processResult = Process.runSync(_Generator._dartBinary, |
| 757 ['deploy.dart'], workingDirectory : path.join(viewerCodePath, | 756 ['deploy.dart'], workingDirectory: viewerCodePath, runInShell: true); |
| 758 'client'), runInShell: true); | |
| 759 print('process output: ${processResult.stdout}'); | 757 print('process output: ${processResult.stdout}'); |
| 760 print('process stderr: ${processResult.stderr}'); | 758 print('process stderr: ${processResult.stderr}'); |
| 761 var outputDir = path.join(viewerCodePath, 'client', 'out', 'web'); | 759 var outputDir = path.join(viewerCodePath, 'out', 'web'); |
| 762 print('Docs are available at $outputDir'); | 760 print('Docs are available at $outputDir'); |
| 763 } | 761 } |
| 764 } | 762 } |
| 765 | 763 |
| 766 /// A simple HTTP server. Implemented here because this is part of the SDK, | 764 /// A simple HTTP server. Implemented here because this is part of the SDK, |
| 767 /// so it shouldn't have any external dependencies. | 765 /// so it shouldn't have any external dependencies. |
| 768 static void _runServer() { | 766 static void _runServer() { |
| 769 // Launch a server to serve out of the directory dartdoc-viewer/client/web. | 767 // Launch a server to serve out of the directory dartdoc-viewer/client/web. |
| 770 HttpServer.bind('localhost', 8080).then((HttpServer httpServer) { | 768 HttpServer.bind('localhost', 8080).then((HttpServer httpServer) { |
| 771 print('Server launched. Navigate your browser to: ' | 769 print('Server launched. Navigate your browser to: ' |
| 772 'http://localhost:${httpServer.port}'); | 770 'http://localhost:${httpServer.port}'); |
| 773 httpServer.listen((HttpRequest request) { | 771 httpServer.listen((HttpRequest request) { |
| 774 var response = request.response; | 772 var response = request.response; |
| 775 var basePath = path.join(viewerCodePath, 'client', 'out', | 773 var basePath = path.join(viewerCodePath, 'out', 'web'); |
| 776 'web'); | |
| 777 var requestPath = path.join(basePath, request.uri.path.substring(1)); | 774 var requestPath = path.join(basePath, request.uri.path.substring(1)); |
| 778 bool found = true; | 775 bool found = true; |
| 779 var file = new File(requestPath); | 776 var file = new File(requestPath); |
| 780 if (file.existsSync()) { | 777 if (file.existsSync()) { |
| 781 // Set the correct header type. | 778 // Set the correct header type. |
| 782 if (requestPath.endsWith('.html')) { | 779 if (requestPath.endsWith('.html')) { |
| 783 response.headers.set('Content-Type', 'text/html'); | 780 response.headers.set('Content-Type', 'text/html'); |
| 784 } else if (requestPath.endsWith('.js')) { | 781 } else if (requestPath.endsWith('.js')) { |
| 785 response.headers.set('Content-Type', 'application/javascript'); | 782 response.headers.set('Content-Type', 'application/javascript'); |
| 786 } else if (requestPath.endsWith('.dart')) { | 783 } else if (requestPath.endsWith('.dart')) { |
| (...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2232 .map((e) => originalMirror.getField(e.simpleName).reflectee) | 2229 .map((e) => originalMirror.getField(e.simpleName).reflectee) |
| 2233 .where((e) => e != null) | 2230 .where((e) => e != null) |
| 2234 .toList(); | 2231 .toList(); |
| 2235 } | 2232 } |
| 2236 | 2233 |
| 2237 Map toMap() => { | 2234 Map toMap() => { |
| 2238 'name': Indexable.getDocgenObject(mirror, owningLibrary).docName, | 2235 'name': Indexable.getDocgenObject(mirror, owningLibrary).docName, |
| 2239 'parameters': parameters | 2236 'parameters': parameters |
| 2240 }; | 2237 }; |
| 2241 } | 2238 } |
| OLD | NEW |