Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Unified Diff: pkg/docgen/lib/docgen.dart

Issue 162223002: Add --compile flag. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« pkg/docgen/bin/docgen.dart ('K') | « pkg/docgen/bin/docgen.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,15 +130,23 @@
includeDependentPackages: includeDependentPackages,
startPage: startPage, pubScript: pubScript, dartBinary: dartBinary);
_Viewer.addBackViewerCode();
- if (serve) {
+ if (compile || serve) {
result.then((success) {
if (success) {
- _Viewer._cloneAndServe();
+ _Viewer._clone();
Emily Fortuna 2014/02/13 00:27:56 it's a mini function, but let's pull out lines 136
dgrove 2014/02/13 00:58:41 Done.
+ _Viewer._compile();
+ if (serve) {
+ _Viewer._runServer();
+ }
}
});
- }
- } else if (serve) {
- _Viewer._cloneAndServe();
+ }
+ } else if (compile || serve) {
+ _Viewer._clone();
+ _Viewer._compile();
+ if (serve) {
+ _Viewer._runServer();
+ }
}
return result;
}
@@ -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() {
- 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');
}
}
« pkg/docgen/bin/docgen.dart ('K') | « pkg/docgen/bin/docgen.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698