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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 world.getOrAddLibrary('dart:html'); | 102 world.getOrAddLibrary('dart:html'); |
| 103 world.getOrAddLibrary('dart:io'); | 103 world.getOrAddLibrary('dart:io'); |
| 104 world.getOrAddLibrary('dart:isolate'); | 104 world.getOrAddLibrary('dart:isolate'); |
| 105 world.getOrAddLibrary('dart:uri'); | 105 world.getOrAddLibrary('dart:uri'); |
| 106 world.getOrAddLibrary('dart:utf'); | 106 world.getOrAddLibrary('dart:utf'); |
| 107 world.process(); | 107 world.process(); |
| 108 | 108 |
| 109 print('Generating docs...'); | 109 print('Generating docs...'); |
| 110 final apidoc = new Apidoc(mdn, outputDir, mode); | 110 final apidoc = new Apidoc(mdn, outputDir, mode); |
| 111 apidoc.document(); | 111 apidoc.document(); |
| 112 | |
| 113 print('Building App Cache manifest'); | |
| 114 apidoc.generateAppCacheManifest(); | |
| 112 } | 115 } |
| 113 | 116 |
| 114 class Apidoc extends doc.Dartdoc { | 117 class Apidoc extends doc.Dartdoc { |
| 115 /** Big ball of JSON containing the scraped MDN documentation. */ | 118 /** Big ball of JSON containing the scraped MDN documentation. */ |
| 116 final Map mdn; | 119 final Map mdn; |
| 117 | 120 |
| 118 static final disqusShortname = 'dartapidocs'; | 121 static final disqusShortname = 'dartapidocs'; |
| 119 | 122 |
| 120 /** | 123 /** |
| 121 * The URL to the page on MDN that content was pulled from for the current | 124 * The URL to the page on MDN that content was pulled from for the current |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 (function() { | 169 (function() { |
| 167 var dsq = document.createElement("script"); dsq.type = "text/jav ascript"; dsq.async = true; | 170 var dsq = document.createElement("script"); dsq.type = "text/jav ascript"; dsq.async = true; |
| 168 dsq.src = "http://" + disqus_shortname + ".disqus.com/embed.js"; | 171 dsq.src = "http://" + disqus_shortname + ".disqus.com/embed.js"; |
| 169 (document.getElementsByTagName("head")[0] || document.getElement sByTagName("body")[0]).appendChild(dsq); | 172 (document.getElementsByTagName("head")[0] || document.getElement sByTagName("body")[0]).appendChild(dsq); |
| 170 })(); | 173 })(); |
| 171 </script> | 174 </script> |
| 172 <noscript>Please enable JavaScript to view the <a href="http://disqus.co m/?ref_noscript">comments powered by Disqus.</a></noscript> | 175 <noscript>Please enable JavaScript to view the <a href="http://disqus.co m/?ref_noscript">comments powered by Disqus.</a></noscript> |
| 173 </div> <!-- #comments --> | 176 </div> <!-- #comments --> |
| 174 '''; | 177 '''; |
| 175 | 178 |
| 179 htmlAttributes = 'manifest="appcache.manifest"'; | |
|
Bob Nystrom
2012/04/24 16:30:33
Is there any reason we wouldn't want dartdoc itsel
sethladd
2012/04/25 21:13:46
moved to dartdoc
| |
| 180 | |
| 176 searchEngineId = '011220921317074318178:i4mscbaxtru'; | 181 searchEngineId = '011220921317074318178:i4mscbaxtru'; |
| 177 searchResultsUrl = 'http://www.dartlang.org/search.html'; | 182 searchResultsUrl = 'http://www.dartlang.org/search.html'; |
| 178 } | 183 } |
| 179 | 184 |
| 180 void writeHeadContents(String title) { | 185 void writeHeadContents(String title) { |
| 181 super.writeHeadContents(title); | 186 super.writeHeadContents(title); |
| 182 | 187 |
| 183 // Include the apidoc-specific CSS. | 188 // Include the apidoc-specific CSS. |
| 184 // TODO(rnystrom): Use our CSS pre-processor to combine these. | 189 // TODO(rnystrom): Use our CSS pre-processor to combine these. |
| 185 writeln( | 190 writeln( |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 var domTypesText = doc.joinWithCommas(map(domTypes, typeReference)); | 493 var domTypesText = doc.joinWithCommas(map(domTypes, typeReference)); |
| 489 return | 494 return |
| 490 ''' | 495 ''' |
| 491 <p class="correspond">This corresponds to $domTypesText in the | 496 <p class="correspond">This corresponds to $domTypesText in the |
| 492 ${a("dom.html", "dart:dom")} library.</p> | 497 ${a("dom.html", "dart:dom")} library.</p> |
| 493 '''; | 498 '''; |
| 494 } | 499 } |
| 495 | 500 |
| 496 return ''; | 501 return ''; |
| 497 } | 502 } |
| 503 | |
| 504 generateAppCacheManifest() { | |
| 505 var manifestFile = new File('docs/appcache.manifest'); | |
|
Bob Nystrom
2012/04/24 16:30:33
The Dartdoc class has a more pleasant API for writ
sethladd
2012/04/25 21:13:46
current way works, will leave for now.
| |
| 506 var writer = manifestFile.openOutputStream(FileMode.WRITE); | |
| 507 writer.writeString("CACHE MANIFEST\n\n"); | |
| 508 writer.writeString("# VERSION: ${new Date.now()}\n\n"); | |
| 509 writer.writeString("NETWORK:\n*\n\n"); | |
| 510 writer.writeString("CACHE:\n"); | |
| 511 var toCache = new Directory(outputDir); | |
| 512 var pathPrefix = new File(outputDir).fullPathSync(); | |
| 513 var pathPrefixLength = pathPrefix.length; | |
| 514 toCache.list(recursive: true); | |
| 515 toCache.onFile = (filename) { | |
| 516 var relativePath = filename.substring(pathPrefixLength+1); | |
|
Bob Nystrom
2012/04/24 16:30:33
Spaces around +
sethladd
2012/04/25 21:13:46
Done.
| |
| 517 writer.writeString("$relativePath\n"); | |
| 518 }; | |
| 519 toCache.onDone = (done) => writer.close(); | |
|
Bob Nystrom
2012/04/24 16:30:33
Ugh, async. I wonder if at some point, Dartdoc wil
sethladd
2012/04/25 21:13:46
See the added Futures.
| |
| 520 } | |
| 498 } | 521 } |
| OLD | NEW |