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

Side by Side Diff: utils/apidoc/apidoc.dart

Issue 10201012: add appcache generation to apidocs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: use a specific analytics num Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/dartdoc/dartdoc.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /** 5 /**
6 * This generates the reference documentation for the core libraries that come 6 * This generates the reference documentation for the core libraries that come
7 * with dart. It is built on top of dartdoc, which is a general-purpose library 7 * with dart. It is built on top of dartdoc, which is a general-purpose library
8 * for generating docs from any Dart code. This library extends that to include 8 * for generating docs from any Dart code. This library extends that to include
9 * additional information and styling specific to our standard library. 9 * additional information and styling specific to our standard library.
10 * 10 *
(...skipping 16 matching lines...) Expand all
27 HtmlDiff _diff; 27 HtmlDiff _diff;
28 28
29 final GET_PREFIX = 'get:'; 29 final GET_PREFIX = 'get:';
30 30
31 void main() { 31 void main() {
32 final args = new Options().arguments; 32 final args = new Options().arguments;
33 33
34 int mode = doc.MODE_STATIC; 34 int mode = doc.MODE_STATIC;
35 String outputDir = 'docs'; 35 String outputDir = 'docs';
36 String compilerPath; 36 String compilerPath;
37 bool generateAppCache = true;
37 38
38 // Parse the command-line arguments. 39 // Parse the command-line arguments.
39 for (int i = 0; i < args.length; i++) { 40 for (int i = 0; i < args.length; i++) {
40 final arg = args[i]; 41 final arg = args[i];
41 42
42 switch (arg) { 43 switch (arg) {
43 case '--mode=static': 44 case '--mode=static':
44 mode = doc.MODE_STATIC; 45 mode = doc.MODE_STATIC;
45 break; 46 break;
46 47
47 case '--mode=live-nav': 48 case '--mode=live-nav':
48 mode = doc.MODE_LIVE_NAV; 49 mode = doc.MODE_LIVE_NAV;
49 break; 50 break;
50 51
52 case '--generate-app-cache=false':
53 generateAppCache = false;
54 break;
55
51 default: 56 default:
52 if (arg.startsWith('--out=')) { 57 if (arg.startsWith('--out=')) {
53 outputDir = arg.substring('--out='.length); 58 outputDir = arg.substring('--out='.length);
54 } else if (arg.startsWith('--compiler=')) { 59 } else if (arg.startsWith('--compiler=')) {
55 compilerPath = arg.substring('--compiler='.length); 60 compilerPath = arg.substring('--compiler='.length);
56 } else { 61 } else {
57 print('Unknown option: $arg'); 62 print('Unknown option: $arg');
58 return; 63 return;
59 } 64 }
60 break; 65 break;
61 } 66 }
62 } 67 }
63 68
64 final frogPath = joinPaths(doc.scriptDir, '../../frog/'); 69 final frogPath = joinPaths(doc.scriptDir, '../../frog/');
65 final libDir = joinPaths(frogPath, 'lib'); 70 final libDir = joinPaths(frogPath, 'lib');
66 71
67 if (compilerPath === null) { 72 if (compilerPath === null) {
68 compilerPath = joinPaths(frogPath, 'frog.py'); 73 compilerPath = joinPaths(frogPath, 'frog.py');
69 } 74 }
70 75
71 doc.cleanOutputDirectory(outputDir); 76 doc.cleanOutputDirectory(outputDir);
72 77
73 // Compile the client-side code to JS. 78 // Compile the client-side code to JS.
74 // TODO(bob): Right path. 79 // TODO(bob): Right path.
75 80
76 final clientScript = (mode == doc.MODE_STATIC) ? 81 final clientScript = (mode == doc.MODE_STATIC) ?
77 'static' : 'live-nav'; 82 'static' : 'live-nav';
78 doc.compileScript(compilerPath, libDir, 83 final Future scriptCompiled = doc.compileScript(compilerPath, libDir,
79 '${doc.scriptDir}/../../lib/dartdoc/client-$clientScript.dart', 84 '${doc.scriptDir}/../../lib/dartdoc/client-$clientScript.dart',
80 '${outputDir}/client-$clientScript.js'); 85 '${outputDir}/client-$clientScript.js');
81 86
82 // TODO(rnystrom): Use platform-specific path separator. 87 // TODO(rnystrom): Use platform-specific path separator.
83 // The basic dartdoc-provided static content. 88 // The basic dartdoc-provided static content.
84 doc.copyFiles('${doc.scriptDir}/../../lib/dartdoc/static', outputDir); 89 final Future copiedStatic = doc.copyFiles(
90 '${doc.scriptDir}/../../lib/dartdoc/static', outputDir);
85 91
86 // The apidoc-specific static content. 92 // The apidoc-specific static content.
87 doc.copyFiles('${doc.scriptDir}/static', outputDir); 93 final Future copiedApiDocStatic = doc.copyFiles('${doc.scriptDir}/static',
94 outputDir);
88 95
89 var files = new VMFileSystem(); 96 var files = new VMFileSystem();
90 parseOptions(frogPath, ['', '', '--libdir=$frogPath/lib'], files); 97 parseOptions(frogPath, ['', '', '--libdir=$frogPath/lib'], files);
91 initializeWorld(files); 98 initializeWorld(files);
92 99
93 print('Parsing MDN data...'); 100 print('Parsing MDN data...');
94 final mdnFile = new File('${doc.scriptDir}/mdn/database.json'); 101 final mdnFile = new File('${doc.scriptDir}/mdn/database.json');
95 final mdn = JSON.parse(mdnFile.readAsTextSync()); 102 final mdn = JSON.parse(mdnFile.readAsTextSync());
96 103
97 print('Cross-referencing dart:dom and dart:html...'); 104 print('Cross-referencing dart:dom and dart:html...');
98 HtmlDiff.initialize(); 105 HtmlDiff.initialize();
99 _diff = new HtmlDiff(printWarnings:false); 106 _diff = new HtmlDiff(printWarnings:false);
100 _diff.run(); 107 _diff.run();
101 world.reset(); 108 world.reset();
102 109
103 // Add all of the core libraries. 110 // Add all of the core libraries.
104 world.getOrAddLibrary('dart:core'); 111 world.getOrAddLibrary('dart:core');
105 world.getOrAddLibrary('dart:coreimpl'); 112 world.getOrAddLibrary('dart:coreimpl');
106 world.getOrAddLibrary('dart:json'); 113 world.getOrAddLibrary('dart:json');
107 world.getOrAddLibrary('dart:dom'); 114 world.getOrAddLibrary('dart:dom');
108 world.getOrAddLibrary('dart:html'); 115 world.getOrAddLibrary('dart:html');
109 world.getOrAddLibrary('dart:io'); 116 world.getOrAddLibrary('dart:io');
110 world.getOrAddLibrary('dart:isolate'); 117 world.getOrAddLibrary('dart:isolate');
111 world.getOrAddLibrary('dart:uri'); 118 world.getOrAddLibrary('dart:uri');
112 world.getOrAddLibrary('dart:utf'); 119 world.getOrAddLibrary('dart:utf');
113 world.process(); 120 world.process();
114 121
115 print('Generating docs...'); 122 print('Generating docs...');
116 final apidoc = new Apidoc(mdn, outputDir, mode); 123 final apidoc = new Apidoc(mdn, outputDir, mode, generateAppCache);
117 apidoc.document(); 124
125 Futures.wait([scriptCompiled, copiedStatic, copiedApiDocStatic]).then((_) {
126 apidoc.document();
127 });
118 } 128 }
119 129
120 class Apidoc extends doc.Dartdoc { 130 class Apidoc extends doc.Dartdoc {
121 /** Big ball of JSON containing the scraped MDN documentation. */ 131 /** Big ball of JSON containing the scraped MDN documentation. */
122 final Map mdn; 132 final Map mdn;
123 133
124 static final disqusShortname = 'dartapidocs'; 134 static final disqusShortname = 'dartapidocs';
125 135
126 /** 136 /**
127 * The URL to the page on MDN that content was pulled from for the current 137 * The URL to the page on MDN that content was pulled from for the current
128 * type being documented. Will be `null` if the type doesn't use any MDN 138 * type being documented. Will be `null` if the type doesn't use any MDN
129 * content. 139 * content.
130 */ 140 */
131 String mdnUrl; 141 String mdnUrl;
132 142
133 Apidoc(this.mdn, String outputDir, int mode) { 143 Apidoc(this.mdn, String outputDir, int mode, bool generateAppCache) {
134 this.outputDir = outputDir; 144 this.outputDir = outputDir;
135 this.mode = mode; 145 this.mode = mode;
146 this.generateAppCache = generateAppCache;
136 147
137 mainTitle = 'Dart API Reference'; 148 mainTitle = 'Dart API Reference';
138 mainUrl = 'http://dartlang.org'; 149 mainUrl = 'http://dartlang.org';
139 150
140 final note = 'http://code.google.com/policies.html#restrictions'; 151 final note = 'http://code.google.com/policies.html#restrictions';
141 final cca = 'http://creativecommons.org/licenses/by/3.0/'; 152 final cca = 'http://creativecommons.org/licenses/by/3.0/';
142 final bsd = 'http://code.google.com/google_bsd_license.html'; 153 final bsd = 'http://code.google.com/google_bsd_license.html';
143 final tos = 'http://www.dartlang.org/tos.html'; 154 final tos = 'http://www.dartlang.org/tos.html';
144 final privacy = 'http://www.google.com/intl/en/privacy/privacy-policy.html'; 155 final privacy = 'http://www.google.com/intl/en/privacy/privacy-policy.html';
145 156
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 ''' 203 '''
193 <link rel="stylesheet" type="text/css" 204 <link rel="stylesheet" type="text/css"
194 href="${relativePath('apidoc-styles.css')}" /> 205 href="${relativePath('apidoc-styles.css')}" />
195 '''); 206 ''');
196 207
197 // Add the analytics code. 208 // Add the analytics code.
198 writeln( 209 writeln(
199 ''' 210 '''
200 <script type="text/javascript"> 211 <script type="text/javascript">
201 var _gaq = _gaq || []; 212 var _gaq = _gaq || [];
202 _gaq.push(["_setAccount", "UA-26406144-4"]); 213 _gaq.push(["_setAccount", "UA-26406144-9"]);
203 _gaq.push(["_setDomainName", "dartlang.org"]);
204 _gaq.push(["_trackPageview"]); 214 _gaq.push(["_trackPageview"]);
205 215
206 (function() { 216 (function() {
207 var ga = document.createElement("script"); 217 var ga = document.createElement("script");
208 ga.type = "text/javascript"; ga.async = true; 218 ga.type = "text/javascript"; ga.async = true;
209 ga.src = ("https:" == document.location.protocol ? 219 ga.src = ("https:" == document.location.protocol ?
210 "https://ssl" : "http://www") + ".google-analytics.com/ga.js"; 220 "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
211 var s = document.getElementsByTagName("script")[0]; 221 var s = document.getElementsByTagName("script")[0];
212 s.parentNode.insertBefore(ga, s); 222 s.parentNode.insertBefore(ga, s);
213 })(); 223 })();
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 var domTypesText = doc.joinWithCommas(map(domTypes, typeReference)); 504 var domTypesText = doc.joinWithCommas(map(domTypes, typeReference));
495 return 505 return
496 ''' 506 '''
497 <p class="correspond">This corresponds to $domTypesText in the 507 <p class="correspond">This corresponds to $domTypesText in the
498 ${a("dom.html", "dart:dom")} library.</p> 508 ${a("dom.html", "dart:dom")} library.</p>
499 '''; 509 ''';
500 } 510 }
501 511
502 return ''; 512 return '';
503 } 513 }
514
504 } 515 }
OLDNEW
« no previous file with comments | « lib/dartdoc/dartdoc.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698