Chromium Code Reviews| Index: pkg/docgen/lib/docgen.dart |
| =================================================================== |
| --- pkg/docgen/lib/docgen.dart (revision 32632) |
| +++ pkg/docgen/lib/docgen.dart (working copy) |
| @@ -106,6 +106,8 @@ |
| /// also be documented. |
| /// If [parseSdk] is `true`, then all Dart SDK libraries will be documented. |
| /// This option is useful when only the SDK libraries are needed. |
| +/// If [compile] is `true`, then after generating the documents, compile the |
| +/// viewer with dart2js. |
| /// If [serve] is `true`, then after generating the documents we fire up a |
| /// simple server to view the documentation. |
| /// |
| @@ -114,7 +116,7 @@ |
| bool outputToYaml: true, bool includePrivate: false, bool includeSdk: false, |
| bool parseSdk: false, bool append: false, String introFileName: '', |
| out: _DEFAULT_OUTPUT_DIRECTORY, List<String> excludeLibraries : const [], |
| - bool includeDependentPackages: false, bool serve: false, |
| + bool includeDependentPackages: false, bool compile: false, bool serve: false, |
| bool noDocs: false, String startPage, |
| String pubScript, String dartBinary}) { |
| var result; |
| @@ -128,19 +130,27 @@ |
| includeDependentPackages: includeDependentPackages, |
| startPage: startPage, pubScript: pubScript, dartBinary: dartBinary); |
| _Viewer.addBackViewerCode(); |
| - if (serve) { |
| + if (compile || serve) { |
| result.then((success) { |
| if (success) { |
| - _Viewer._cloneAndServe(); |
| + _createViewer(serve); |
| } |
| }); |
| - } |
| - } else if (serve) { |
| - _Viewer._cloneAndServe(); |
| + } |
| + } else if (compile || serve) { |
| + _createViewer(serve); |
| } |
| return result; |
| } |
| +void _createViewer(bool serve) { |
| + _Viewer._clone(); |
| + _Viewer._compile(); |
| + if (serve) { |
| + _Viewer._runServer(); |
| + } |
| +} |
| + |
| /// Analyzes set of libraries by getting a mirror system and triggers the |
| /// documentation of the libraries. |
| Future<MirrorSystem> getMirrorSystem(List<Uri> libraries, |
| @@ -650,6 +660,7 @@ |
| 'dartdoc-viewer'); |
| static Directory _dartdocViewerDir = new Directory(_dartdocViewerString); |
| static Directory _topLevelTempDir; |
| + static Directory _webDocsDir; |
| static bool movedViewerCode = false; |
| /// If our dartdoc-viewer code is already checked out, move it to a temporary |
| @@ -671,7 +682,7 @@ |
| } |
| /// Serve up our generated documentation for viewing in a browser. |
| - static void _cloneAndServe() { |
| + static void _clone() { |
| // If the viewer code is already there, then don't clone again. |
| if (_dartdocViewerDir.existsSync()) { |
| _moveDirectoryAndServe(); |
| @@ -682,7 +693,22 @@ |
| runInShell: true); |
| if (processResult.exitCode == 0) { |
| - _moveDirectoryAndServe(); |
| + /// Move the generated json/yaml docs directory to the dartdoc-viewer |
| + /// directory, to run as a webpage. |
| + var processResult = Process.runSync(_Generator._pubScript, |
| + ['upgrade'], runInShell: true, |
| + workingDirectory: path.join(_dartdocViewerDir.path, 'client')); |
| + print('process output: ${processResult.stdout}'); |
| + print('process stderr: ${processResult.stderr}'); |
| + |
| + var dir = new Directory(_Generator._outputDirectory == null? 'docs' : |
| + _Generator._outputDirectory); |
| + _webDocsDir = new Directory(path.join(_dartdocViewerDir.path, 'client', |
| + 'web', 'docs')); |
| + if (dir.existsSync()) { |
| + // Move the docs folder to dartdoc-viewer/client/web/docs |
| + dir.renameSync(_webDocsDir.path); |
| + } |
| } else { |
| print('Error cloning git repository:'); |
| print('process output: ${processResult.stdout}'); |
| @@ -691,25 +717,8 @@ |
| } |
| } |
| - /// Move the generated json/yaml docs directory to the dartdoc-viewer |
| - /// directory, to run as a webpage. |
| - static void _moveDirectoryAndServe() { |
|
kevmoo
2014/02/19 21:57:16
Still being used...
https://code.google.com/p/dar
|
| - var processResult = Process.runSync(_Generator._pubScript, ['upgrade'], |
| - runInShell: true, workingDirectory: path.join(_dartdocViewerDir.path, |
| - 'client')); |
| - print('process output: ${processResult.stdout}'); |
| - print('process stderr: ${processResult.stderr}'); |
| - |
| - var dir = new Directory(_Generator._outputDirectory == null? 'docs' : |
| - _Generator._outputDirectory); |
| - var webDocsDir = new Directory(path.join(_dartdocViewerDir.path, 'client', |
| - 'web', 'docs')); |
| - if (dir.existsSync()) { |
| - // Move the docs folder to dartdoc-viewer/client/web/docs |
| - dir.renameSync(webDocsDir.path); |
| - } |
| - |
| - if (webDocsDir.existsSync()) { |
| + static void _compile() { |
| + if (_webDocsDir.existsSync()) { |
| // Compile the code to JavaScript so we can run on any browser. |
| print('Compile app to JavaScript for viewing.'); |
| var processResult = Process.runSync(_Generator._dartBinary, |
| @@ -717,7 +726,8 @@ |
| 'client'), runInShell: true); |
| print('process output: ${processResult.stdout}'); |
| print('process stderr: ${processResult.stderr}'); |
| - _runServer(); |
| + var outputDir = path.join(_dartdocViewerDir.path, 'client', 'out', 'web'); |
| + print('Docs are available at $outputDir'); |
| } |
| } |