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 10 matching lines...) Expand all Loading... | |
21 #import('../../frog/file_system.dart'); | 21 #import('../../frog/file_system.dart'); |
22 #import('../../lib/dartdoc/dartdoc.dart', prefix: 'doc'); | 22 #import('../../lib/dartdoc/dartdoc.dart', prefix: 'doc'); |
23 | 23 |
24 HtmlDiff _diff; | 24 HtmlDiff _diff; |
25 | 25 |
26 final GET_PREFIX = 'get:'; | 26 final GET_PREFIX = 'get:'; |
27 | 27 |
28 void main() { | 28 void main() { |
29 final args = new Options().arguments; | 29 final args = new Options().arguments; |
30 | 30 |
31 int mode = doc.Dartdoc.MODE_STATIC; | |
31 var outputDir = 'docs'; | 32 var outputDir = 'docs'; |
32 | 33 |
33 // Use the output directory if provided. | 34 // Use the output directory if provided. |
35 /* | |
34 if (args.length > 1) { | 36 if (args.length > 1) { |
35 print('Usage: apidoc [--out=<output directory>]'); | 37 print('Usage: apidoc [--out=<output directory>]'); |
36 return; | 38 return; |
37 } else if (args.length == 1) { | 39 } else if (args.length == 1) { |
38 final arg = args[0]; | 40 final arg = args[0]; |
39 if (arg.startsWith('--out=')) { | 41 if (arg.startsWith('--out=')) { |
40 outputDir = arg.substring('--out='.length); | 42 outputDir = arg.substring('--out='.length); |
41 } else { | 43 } else { |
42 print('Unknown option: $arg'); | 44 print('Unknown option: $arg'); |
43 return; | 45 return; |
44 } | 46 } |
45 } | 47 } |
48 */ | |
49 | |
50 for (int i = 0; i < args.length - 1; i++) { | |
51 final arg = args[i]; | |
52 | |
53 switch (arg) { | |
54 case '--mode=static': | |
55 mode = doc.Dartdoc.MODE_STATIC; | |
56 break; | |
57 | |
58 case '--mode=live-nav': | |
59 mode = doc.Dartdoc.MODE_LIVE_NAV; | |
60 break; | |
61 | |
62 default: | |
63 if (arg.startsWith('--out=')) { | |
64 outputDir = arg.substring('--out='.length); | |
65 } else { | |
66 print('Unknown option: $arg'); | |
67 return; | |
68 } | |
69 break; | |
70 } | |
71 } | |
46 | 72 |
47 final frogPath = joinPaths(doc.scriptDir, '../../frog/'); | 73 final frogPath = joinPaths(doc.scriptDir, '../../frog/'); |
74 final compilerPath = joinPaths(frogPath, 'minfrog'); | |
75 final libDir = joinPaths(frogPath, 'lib'); | |
48 | 76 |
49 doc.cleanOutputDirectory(outputDir); | 77 doc.cleanOutputDirectory(outputDir); |
50 | 78 |
51 // Compile the client-side code to JS. | 79 // Compile the client-side code to JS. |
52 // TODO(bob): Right path. | 80 // TODO(bob): Right path. |
53 doc.compileScript(frogPath, | 81 |
54 '${doc.scriptDir}/../../lib/dartdoc/client-live-nav.dart', | 82 final clientScript = (mode == doc.Dartdoc.MODE_STATIC) ? 'static' : 'live-nav' ; |
Bob Nystrom
2012/03/28 20:01:21
Long line.
sethladd
2012/03/28 21:52:17
Done.
| |
55 '${outputDir}/client-live-nav.js'); | 83 doc.compileScript(compilerPath, libDir, |
84 '${doc.scriptDir}/../../lib/dartdoc/client-$clientScript.dart', | |
85 '${outputDir}/client-$clientScript.js'); | |
56 | 86 |
57 // TODO(rnystrom): Use platform-specific path separator. | 87 // TODO(rnystrom): Use platform-specific path separator. |
58 // The basic dartdoc-provided static content. | 88 // The basic dartdoc-provided static content. |
59 doc.copyFiles('${doc.scriptDir}/../../lib/dartdoc/static', outputDir); | 89 doc.copyFiles('${doc.scriptDir}/../../lib/dartdoc/static', outputDir); |
60 | 90 |
61 // The apidoc-specific static content. | 91 // The apidoc-specific static content. |
62 doc.copyFiles('${doc.scriptDir}/static', outputDir); | 92 doc.copyFiles('${doc.scriptDir}/static', outputDir); |
63 | 93 |
64 var files = new VMFileSystem(); | 94 var files = new VMFileSystem(); |
65 parseOptions(frogPath, ['', '', '--libdir=$frogPath/lib'], files); | 95 parseOptions(frogPath, ['', '', '--libdir=$frogPath/lib'], files); |
(...skipping 15 matching lines...) Expand all Loading... | |
81 world.getOrAddLibrary('dart:dom'); | 111 world.getOrAddLibrary('dart:dom'); |
82 world.getOrAddLibrary('dart:html'); | 112 world.getOrAddLibrary('dart:html'); |
83 world.getOrAddLibrary('dart:io'); | 113 world.getOrAddLibrary('dart:io'); |
84 world.getOrAddLibrary('dart:isolate'); | 114 world.getOrAddLibrary('dart:isolate'); |
85 world.getOrAddLibrary('dart:uri'); | 115 world.getOrAddLibrary('dart:uri'); |
86 world.getOrAddLibrary('dart:utf'); | 116 world.getOrAddLibrary('dart:utf'); |
87 world.process(); | 117 world.process(); |
88 | 118 |
89 print('Generating docs...'); | 119 print('Generating docs...'); |
90 final apidoc = new Apidoc(mdn, outputDir); | 120 final apidoc = new Apidoc(mdn, outputDir); |
121 if (mode != null) apidoc.mode = mode; | |
Bob Nystrom
2012/03/28 20:01:21
Sicne we pass in the output directory, how about p
sethladd
2012/03/29 00:15:28
Done.
| |
91 apidoc.document(); | 122 apidoc.document(); |
92 } | 123 } |
93 | 124 |
94 class Apidoc extends doc.Dartdoc { | 125 class Apidoc extends doc.Dartdoc { |
95 /** Big ball of JSON containing the scraped MDN documentation. */ | 126 /** Big ball of JSON containing the scraped MDN documentation. */ |
96 final Map mdn; | 127 final Map mdn; |
97 | 128 |
129 final String disqusShortname = 'dartapidocs'; | |
Bob Nystrom
2012/03/28 20:01:21
Ditch the type annotation since it's obvious from
sethladd
2012/03/28 21:52:17
Done.
| |
130 | |
98 /** | 131 /** |
99 * The URL to the page on MDN that content was pulled from for the current | 132 * The URL to the page on MDN that content was pulled from for the current |
100 * type being documented. Will be `null` if the type doesn't use any MDN | 133 * type being documented. Will be `null` if the type doesn't use any MDN |
101 * content. | 134 * content. |
102 */ | 135 */ |
103 String mdnUrl; | 136 String mdnUrl; |
104 | 137 |
105 Apidoc(this.mdn, String outputDir) { | 138 Apidoc(this.mdn, String outputDir) { |
106 this.outputDir = outputDir; | 139 this.outputDir = outputDir; |
107 | 140 |
108 mainTitle = 'Dart API Reference'; | 141 mainTitle = 'Dart API Reference'; |
109 mainUrl = 'http://dartlang.org'; | 142 mainUrl = 'http://dartlang.org'; |
110 | 143 |
111 final note = 'http://code.google.com/policies.html#restrictions'; | 144 final note = 'http://code.google.com/policies.html#restrictions'; |
112 final cca = 'http://creativecommons.org/licenses/by/3.0/'; | 145 final cca = 'http://creativecommons.org/licenses/by/3.0/'; |
113 final bsd = 'http://code.google.com/google_bsd_license.html'; | 146 final bsd = 'http://code.google.com/google_bsd_license.html'; |
114 final tos = 'http://www.dartlang.org/tos.html'; | 147 final tos = 'http://www.dartlang.org/tos.html'; |
115 final privacy = 'http://www.google.com/intl/en/privacy/privacy-policy.html'; | 148 final privacy = 'http://www.google.com/intl/en/privacy/privacy-policy.html'; |
116 | 149 |
117 footerText = | 150 footerText = |
118 ''' | 151 ''' |
119 <p>Except as otherwise <a href="$note">noted</a>, the content of this | 152 <p>Except as otherwise <a href="$note">noted</a>, the content of this |
120 page is licensed under the <a href="$cca">Creative Commons Attribution | 153 page is licensed under the <a href="$cca">Creative Commons Attribution |
121 3.0 License</a>, and code samples are licensed under the | 154 3.0 License</a>, and code samples are licensed under the |
122 <a href="$bsd">BSD License</a>.</p> | 155 <a href="$bsd">BSD License</a>.</p> |
123 <p><a href="$tos">Terms of Service</a> | | 156 <p><a href="$tos">Terms of Service</a> | |
124 <a href="$privacy">Privacy Policy</a></p> | 157 <a href="$privacy">Privacy Policy</a></p> |
125 '''; | 158 '''; |
126 | 159 |
160 preFooterText = | |
161 ''' | |
162 <div id="comments"> | |
163 <div id="disqus_thread"></div> | |
164 <script type="text/javascript"> | |
165 /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAG E * * */ | |
166 var disqus_shortname = "$disqusShortname"; // required: replace exam ple with your forum shortname | |
167 | |
168 /* * * DON\'T EDIT BELOW THIS LINE * * */ | |
169 (function() { | |
170 var dsq = document.createElement("script"); dsq.type = "text/jav ascript"; dsq.async = true; | |
171 dsq.src = "http://" + disqus_shortname + ".disqus.com/embed.js"; | |
172 (document.getElementsByTagName("head")[0] || document.getElement sByTagName("body")[0]).appendChild(dsq); | |
173 })(); | |
174 </script> | |
175 <noscript>Please enable JavaScript to view the <a href="http://disqus.co m/?ref_noscript">comments powered by Disqus.</a></noscript> | |
176 </div> <!-- #comments --> | |
177 '''; | |
178 | |
127 searchEngineId = '011220921317074318178:i4mscbaxtru'; | 179 searchEngineId = '011220921317074318178:i4mscbaxtru'; |
128 searchResultsUrl = 'http://www.dartlang.org/search.html'; | 180 searchResultsUrl = 'http://www.dartlang.org/search.html'; |
129 } | 181 } |
130 | 182 |
131 void writeHeadContents(String title) { | 183 void writeHeadContents(String title) { |
132 super.writeHeadContents(title); | 184 super.writeHeadContents(title); |
133 | 185 |
134 // Include the apidoc-specific CSS. | 186 // Include the apidoc-specific CSS. |
135 // TODO(rnystrom): Use our CSS pre-processor to combine these. | 187 // TODO(rnystrom): Use our CSS pre-processor to combine these. |
136 writeln( | 188 writeln( |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
434 return | 486 return |
435 ''' | 487 ''' |
436 <p class="correspond">This corresponds to $domTypesText in the | 488 <p class="correspond">This corresponds to $domTypesText in the |
437 ${a("dom.html", "dart:dom")} library.</p> | 489 ${a("dom.html", "dart:dom")} library.</p> |
438 '''; | 490 '''; |
439 } | 491 } |
440 | 492 |
441 return ''; | 493 return ''; |
442 } | 494 } |
443 } | 495 } |
OLD | NEW |