OLD | NEW |
---|---|
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 * To generate docs for a library, run this script with the path to an | 6 * To generate docs for a library, run this script with the path to an |
7 * entrypoint .dart file, like: | 7 * entrypoint .dart file, like: |
8 * | 8 * |
9 * $ dart dartdoc.dart foo.dart | 9 * $ dart dartdoc.dart foo.dart |
10 * | 10 * |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 */ | 48 */ |
49 final MODE_LIVE_NAV = 1; | 49 final MODE_LIVE_NAV = 1; |
50 | 50 |
51 /** | 51 /** |
52 * Run this from the `lib/dartdoc` directory. | 52 * Run this from the `lib/dartdoc` directory. |
53 */ | 53 */ |
54 void main() { | 54 void main() { |
55 final args = new Options().arguments; | 55 final args = new Options().arguments; |
56 | 56 |
57 // Parse the dartdoc options. | 57 // Parse the dartdoc options. |
58 bool includeSource; | 58 bool includeSource; |
Jennifer Messerly
2012/06/04 17:47:01
This comment is on the original code, but bools sh
kevmoo-old
2012/06/04 17:51:40
Oh I thought about that...but I kept w/ the existi
| |
59 int mode; | 59 int mode; |
60 String outputDir; | 60 String outputDir; |
61 bool generateAppCache; | 61 bool generateAppCache; |
62 bool omitGenerationTime; | |
Jennifer Messerly
2012/06/04 17:47:01
I almost wonder if this should be showGenerationTi
kevmoo-old
2012/06/04 17:51:40
Easy to change this to a positive value, that defa
| |
62 | 63 |
63 for (int i = 0; i < args.length - 1; i++) { | 64 for (int i = 0; i < args.length - 1; i++) { |
64 final arg = args[i]; | 65 final arg = args[i]; |
65 | 66 |
66 switch (arg) { | 67 switch (arg) { |
67 case '--no-code': | 68 case '--no-code': |
68 includeSource = false; | 69 includeSource = false; |
69 break; | 70 break; |
70 | 71 |
71 case '--mode=static': | 72 case '--mode=static': |
72 mode = MODE_STATIC; | 73 mode = MODE_STATIC; |
73 break; | 74 break; |
74 | 75 |
75 case '--mode=live-nav': | 76 case '--mode=live-nav': |
76 mode = MODE_LIVE_NAV; | 77 mode = MODE_LIVE_NAV; |
77 break; | 78 break; |
78 | 79 |
79 case '--generate-app-cache': | 80 case '--generate-app-cache': |
80 case '--generate-app-cache=true': | 81 case '--generate-app-cache=true': |
81 generateAppCache = true; | 82 generateAppCache = true; |
82 break; | 83 break; |
83 | 84 |
85 case '--omit-generation-time': | |
86 omitGenerationTime = true; | |
87 break; | |
88 | |
84 default: | 89 default: |
85 if (arg.startsWith('--out=')) { | 90 if (arg.startsWith('--out=')) { |
86 outputDir = arg.substring('--out='.length); | 91 outputDir = arg.substring('--out='.length); |
87 } else { | 92 } else { |
88 print('Unknown option: $arg'); | 93 print('Unknown option: $arg'); |
89 return; | 94 return; |
90 } | 95 } |
91 break; | 96 break; |
92 } | 97 } |
93 } | 98 } |
(...skipping 12 matching lines...) Expand all Loading... | |
106 | 111 |
107 parseOptions(frogPath, ['', '', '--libdir=$libDir'], files); | 112 parseOptions(frogPath, ['', '', '--libdir=$libDir'], files); |
108 initializeWorld(files); | 113 initializeWorld(files); |
109 | 114 |
110 final dartdoc = new Dartdoc(); | 115 final dartdoc = new Dartdoc(); |
111 | 116 |
112 if (includeSource != null) dartdoc.includeSource = includeSource; | 117 if (includeSource != null) dartdoc.includeSource = includeSource; |
113 if (mode != null) dartdoc.mode = mode; | 118 if (mode != null) dartdoc.mode = mode; |
114 if (outputDir != null) dartdoc.outputDir = outputDir; | 119 if (outputDir != null) dartdoc.outputDir = outputDir; |
115 if (generateAppCache != null) dartdoc.generateAppCache = generateAppCache; | 120 if (generateAppCache != null) dartdoc.generateAppCache = generateAppCache; |
121 if (omitGenerationTime != null) dartdoc.omitGenerationTime = omitGenerationTim e; | |
Jennifer Messerly
2012/06/04 17:47:01
We generally try to keep code at 80 cols. I'm not
kevmoo-old
2012/06/04 17:51:40
Understood. Will fix.
| |
116 | 122 |
117 cleanOutputDirectory(dartdoc.outputDir); | 123 cleanOutputDirectory(dartdoc.outputDir); |
118 | 124 |
119 // Compile the client-side code to JS. | 125 // Compile the client-side code to JS. |
120 final clientScript = (dartdoc.mode == MODE_STATIC) ? 'static' : 'live-nav'; | 126 final clientScript = (dartdoc.mode == MODE_STATIC) ? 'static' : 'live-nav'; |
121 final Future scriptCompiled = compileScript(compilerPath, | 127 final Future scriptCompiled = compileScript(compilerPath, |
122 '$scriptDir/client-$clientScript.dart', | 128 '$scriptDir/client-$clientScript.dart', |
123 '${dartdoc.outputDir}/client-$clientScript.js'); | 129 '${dartdoc.outputDir}/client-$clientScript.js'); |
124 | 130 |
125 final Future filesCopied = copyFiles('$scriptDir/static', dartdoc.outputDir); | 131 final Future filesCopied = copyFiles('$scriptDir/static', dartdoc.outputDir); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 /** | 254 /** |
249 * The Google Custom Search ID that should be used for the search box. If | 255 * The Google Custom Search ID that should be used for the search box. If |
250 * this is `null` then no search box will be shown. | 256 * this is `null` then no search box will be shown. |
251 */ | 257 */ |
252 String searchEngineId = null; | 258 String searchEngineId = null; |
253 | 259 |
254 /* The URL that the embedded search results should be displayed on. */ | 260 /* The URL that the embedded search results should be displayed on. */ |
255 String searchResultsUrl = 'results.html'; | 261 String searchResultsUrl = 'results.html'; |
256 | 262 |
257 /** Set this to add footer text to each generated page. */ | 263 /** Set this to add footer text to each generated page. */ |
258 String footerText = ''; | 264 String footerText = null; |
259 | 265 |
260 /** Set this to add content before the footer */ | 266 /** Set this to add content before the footer */ |
261 String preFooterText = ''; | 267 String preFooterText = ''; |
262 | 268 |
269 /** Set this to omit generation timestamp from output */ | |
270 bool omitGenerationTime = false; | |
271 | |
263 /** | 272 /** |
264 * From exposes the set of libraries in `world.libraries`. That maps library | 273 * From exposes the set of libraries in `world.libraries`. That maps library |
265 * *keys* to [Library] objects. The keys are *not* exactly the same as their | 274 * *keys* to [Library] objects. The keys are *not* exactly the same as their |
266 * names. This means if we order by key, we won't actually have them sorted | 275 * names. This means if we order by key, we won't actually have them sorted |
267 * correctly. This list contains the libraries in correct order by their | 276 * correctly. This list contains the libraries in correct order by their |
268 * *name*. | 277 * *name*. |
269 */ | 278 */ |
270 List<Library> _sortedLibraries; | 279 List<Library> _sortedLibraries; |
271 | 280 |
272 CommentMap _comments; | 281 CommentMap _comments; |
(...skipping 22 matching lines...) Expand all Loading... | |
295 // Patch in support for [:...:]-style code to the markdown parser. | 304 // Patch in support for [:...:]-style code to the markdown parser. |
296 // TODO(rnystrom): Markdown already has syntax for this. Phase this out? | 305 // TODO(rnystrom): Markdown already has syntax for this. Phase this out? |
297 md.InlineParser.syntaxes.insertRange(0, 1, | 306 md.InlineParser.syntaxes.insertRange(0, 1, |
298 new md.CodeSyntax(@'\[\:((?:.|\n)*?)\:\]')); | 307 new md.CodeSyntax(@'\[\:((?:.|\n)*?)\:\]')); |
299 | 308 |
300 md.setImplicitLinkResolver((name) => resolveNameReference(name, | 309 md.setImplicitLinkResolver((name) => resolveNameReference(name, |
301 library: _currentLibrary, type: _currentType, | 310 library: _currentLibrary, type: _currentType, |
302 member: _currentMember)); | 311 member: _currentMember)); |
303 } | 312 } |
304 | 313 |
314 String get footerContent(){ | |
315 var footerItems = []; | |
316 if(!omitGenerationTime) { | |
317 footerItems.add("This page generated at ${new Date.now()}"); | |
318 } | |
319 if(footerText != null) { | |
320 footerItems.add(footerText); | |
321 } | |
322 var content = ''; | |
323 for (int i = 0; i < footerItems.length; i++) { | |
324 if(i > 0){ | |
325 content = content.concat('\n'); | |
326 } | |
327 content = content.concat('<div>${footerItems[i]}</div>'); | |
328 } | |
329 return content; | |
330 } | |
331 | |
305 void document([String entrypoint]) { | 332 void document([String entrypoint]) { |
306 var oldDietParse = options.dietParse; | 333 var oldDietParse = options.dietParse; |
307 try { | 334 try { |
308 options.dietParse = true; | 335 options.dietParse = true; |
309 | 336 |
310 // If we have an entrypoint, process it. Otherwise, just use whatever | 337 // If we have an entrypoint, process it. Otherwise, just use whatever |
311 // libraries have been previously loaded by the calling code. | 338 // libraries have been previously loaded by the calling code. |
312 if (entrypoint != null) { | 339 if (entrypoint != null) { |
313 world.processDartScript(entrypoint); | 340 world.processDartScript(entrypoint); |
314 } | 341 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
455 } | 482 } |
456 | 483 |
457 void writeFooter() { | 484 void writeFooter() { |
458 writeln( | 485 writeln( |
459 ''' | 486 ''' |
460 </div> | 487 </div> |
461 <div class="clear"></div> | 488 <div class="clear"></div> |
462 </div> | 489 </div> |
463 ${preFooterText} | 490 ${preFooterText} |
464 <div class="footer"> | 491 <div class="footer"> |
465 <p>This page generated at ${new Date.now()}</p> | 492 $footerContent |
466 <div>$footerText</div> | |
467 </div> | 493 </div> |
468 <script async src="${relativePath('$clientScript.js')}"></script> | 494 <script async src="${relativePath('$clientScript.js')}"></script> |
469 </body></html> | 495 </body></html> |
470 '''); | 496 '''); |
471 } | 497 } |
472 | 498 |
473 void docIndex() { | 499 void docIndex() { |
474 startFile('index.html'); | 500 startFile('index.html'); |
475 | 501 |
476 writeHeader(mainTitle, []); | 502 writeHeader(mainTitle, []); |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1344 if (filename.endsWith('appcache.manifest')) { | 1370 if (filename.endsWith('appcache.manifest')) { |
1345 return; | 1371 return; |
1346 } | 1372 } |
1347 var relativePath = filename.substring(pathPrefixLength + 1); | 1373 var relativePath = filename.substring(pathPrefixLength + 1); |
1348 write("$relativePath\n"); | 1374 write("$relativePath\n"); |
1349 }; | 1375 }; |
1350 toCache.onDone = (done) => endFile(); | 1376 toCache.onDone = (done) => endFile(); |
1351 toCache.list(recursive: true); | 1377 toCache.list(recursive: true); |
1352 } | 1378 } |
1353 } | 1379 } |
OLD | NEW |