Chromium Code Reviews| 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 * 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 Loading... | |
| 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 Future scriptCompiled = doc.compileScript(compilerPath, libDir, |
|
Bob Nystrom
2012/04/25 21:43:15
"final"
sethladd
2012/04/25 23:13:28
Done.
| |
| 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 Future copiedStatic = doc.copyFiles('${doc.scriptDir}/../../lib/dartdoc/static ', outputDir); |
|
Bob Nystrom
2012/04/25 21:43:15
Long line.
sethladd
2012/04/25 23:13:28
Done.
| |
| 85 | 90 |
| 86 // The apidoc-specific static content. | 91 // The apidoc-specific static content. |
| 87 doc.copyFiles('${doc.scriptDir}/static', outputDir); | 92 Future copiedApiDocStatic = doc.copyFiles('${doc.scriptDir}/static', outputDir ); |
|
Bob Nystrom
2012/04/25 21:43:15
Here too.
sethladd
2012/04/25 23:13:28
Done.
| |
| 88 | 93 |
| 89 var files = new VMFileSystem(); | 94 var files = new VMFileSystem(); |
| 90 parseOptions(frogPath, ['', '', '--libdir=$frogPath/lib'], files); | 95 parseOptions(frogPath, ['', '', '--libdir=$frogPath/lib'], files); |
| 91 initializeWorld(files); | 96 initializeWorld(files); |
| 92 | 97 |
| 93 print('Parsing MDN data...'); | 98 print('Parsing MDN data...'); |
| 94 final mdnFile = new File('${doc.scriptDir}/mdn/database.json'); | 99 final mdnFile = new File('${doc.scriptDir}/mdn/database.json'); |
| 95 final mdn = JSON.parse(mdnFile.readAsTextSync()); | 100 final mdn = JSON.parse(mdnFile.readAsTextSync()); |
| 96 | 101 |
| 97 print('Cross-referencing dart:dom and dart:html...'); | 102 print('Cross-referencing dart:dom and dart:html...'); |
| 98 HtmlDiff.initialize(); | 103 HtmlDiff.initialize(); |
| 99 _diff = new HtmlDiff(printWarnings:false); | 104 _diff = new HtmlDiff(printWarnings:false); |
| 100 _diff.run(); | 105 _diff.run(); |
| 101 world.reset(); | 106 world.reset(); |
| 102 | 107 |
| 103 // Add all of the core libraries. | 108 // Add all of the core libraries. |
| 104 world.getOrAddLibrary('dart:core'); | 109 world.getOrAddLibrary('dart:core'); |
| 105 world.getOrAddLibrary('dart:coreimpl'); | 110 world.getOrAddLibrary('dart:coreimpl'); |
| 106 world.getOrAddLibrary('dart:json'); | 111 world.getOrAddLibrary('dart:json'); |
| 107 world.getOrAddLibrary('dart:dom'); | 112 world.getOrAddLibrary('dart:dom'); |
| 108 world.getOrAddLibrary('dart:html'); | 113 world.getOrAddLibrary('dart:html'); |
| 109 world.getOrAddLibrary('dart:io'); | 114 world.getOrAddLibrary('dart:io'); |
| 110 world.getOrAddLibrary('dart:isolate'); | 115 world.getOrAddLibrary('dart:isolate'); |
| 111 world.getOrAddLibrary('dart:uri'); | 116 world.getOrAddLibrary('dart:uri'); |
| 112 world.getOrAddLibrary('dart:utf'); | 117 world.getOrAddLibrary('dart:utf'); |
| 113 world.process(); | 118 world.process(); |
| 114 | 119 |
| 115 print('Generating docs...'); | 120 print('Generating docs...'); |
| 116 final apidoc = new Apidoc(mdn, outputDir, mode); | 121 final apidoc = new Apidoc(mdn, outputDir, mode, generateAppCache); |
| 117 apidoc.document(); | 122 |
| 123 // hackish: all I really need to do is run app cache when these | |
| 124 // futures are done, but app cache generation is inside document() | |
|
Bob Nystrom
2012/04/25 21:43:15
Why not just have generateAppCache be a separate m
sethladd
2012/04/25 23:13:28
class Dartdoc still needs the generateAppCache boo
Bob Nystrom
2012/04/25 23:27:50
Ah, OK.
| |
| 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 494 var domTypesText = doc.joinWithCommas(map(domTypes, typeReference)); | 505 var domTypesText = doc.joinWithCommas(map(domTypes, typeReference)); |
| 495 return | 506 return |
| 496 ''' | 507 ''' |
| 497 <p class="correspond">This corresponds to $domTypesText in the | 508 <p class="correspond">This corresponds to $domTypesText in the |
| 498 ${a("dom.html", "dart:dom")} library.</p> | 509 ${a("dom.html", "dart:dom")} library.</p> |
| 499 '''; | 510 '''; |
| 500 } | 511 } |
| 501 | 512 |
| 502 return ''; | 513 return ''; |
| 503 } | 514 } |
| 515 | |
| 504 } | 516 } |
| OLD | NEW |