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

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

Issue 9844031: add disqus comments (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: tweaks from review Created 8 years, 9 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 | « utils/apidoc/README.txt ('k') | utils/apidoc/static/apidoc-styles.css » ('j') | 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 10 matching lines...) Expand all
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 /*
Bob Nystrom 2012/03/28 23:32:58 Delete this.
sethladd 2012/03/29 00:15:28 good catch, thx
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) ?
55 '${outputDir}/client-live-nav.js'); 83 'static' : 'live-nav';
84 doc.compileScript(compilerPath, libDir,
85 '${doc.scriptDir}/../../lib/dartdoc/client-$clientScript.dart',
86 '${outputDir}/client-$clientScript.js');
56 87
57 // TODO(rnystrom): Use platform-specific path separator. 88 // TODO(rnystrom): Use platform-specific path separator.
58 // The basic dartdoc-provided static content. 89 // The basic dartdoc-provided static content.
59 doc.copyFiles('${doc.scriptDir}/../../lib/dartdoc/static', outputDir); 90 doc.copyFiles('${doc.scriptDir}/../../lib/dartdoc/static', outputDir);
60 91
61 // The apidoc-specific static content. 92 // The apidoc-specific static content.
62 doc.copyFiles('${doc.scriptDir}/static', outputDir); 93 doc.copyFiles('${doc.scriptDir}/static', outputDir);
63 94
64 var files = new VMFileSystem(); 95 var files = new VMFileSystem();
65 parseOptions(frogPath, ['', '', '--libdir=$frogPath/lib'], files); 96 parseOptions(frogPath, ['', '', '--libdir=$frogPath/lib'], files);
(...skipping 15 matching lines...) Expand all
81 world.getOrAddLibrary('dart:dom'); 112 world.getOrAddLibrary('dart:dom');
82 world.getOrAddLibrary('dart:html'); 113 world.getOrAddLibrary('dart:html');
83 world.getOrAddLibrary('dart:io'); 114 world.getOrAddLibrary('dart:io');
84 world.getOrAddLibrary('dart:isolate'); 115 world.getOrAddLibrary('dart:isolate');
85 world.getOrAddLibrary('dart:uri'); 116 world.getOrAddLibrary('dart:uri');
86 world.getOrAddLibrary('dart:utf'); 117 world.getOrAddLibrary('dart:utf');
87 world.process(); 118 world.process();
88 119
89 print('Generating docs...'); 120 print('Generating docs...');
90 final apidoc = new Apidoc(mdn, outputDir); 121 final apidoc = new Apidoc(mdn, outputDir);
122 if (mode != null) apidoc.mode = mode;
91 apidoc.document(); 123 apidoc.document();
92 } 124 }
93 125
94 class Apidoc extends doc.Dartdoc { 126 class Apidoc extends doc.Dartdoc {
95 /** Big ball of JSON containing the scraped MDN documentation. */ 127 /** Big ball of JSON containing the scraped MDN documentation. */
96 final Map mdn; 128 final Map mdn;
97 129
130 static final disqusShortname = 'dartapidocs';
131
98 /** 132 /**
99 * The URL to the page on MDN that content was pulled from for the current 133 * 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 134 * type being documented. Will be `null` if the type doesn't use any MDN
101 * content. 135 * content.
102 */ 136 */
103 String mdnUrl; 137 String mdnUrl;
104 138
105 Apidoc(this.mdn, String outputDir) { 139 Apidoc(this.mdn, String outputDir) {
106 this.outputDir = outputDir; 140 this.outputDir = outputDir;
107 141
108 mainTitle = 'Dart API Reference'; 142 mainTitle = 'Dart API Reference';
109 mainUrl = 'http://dartlang.org'; 143 mainUrl = 'http://dartlang.org';
110 144
111 final note = 'http://code.google.com/policies.html#restrictions'; 145 final note = 'http://code.google.com/policies.html#restrictions';
112 final cca = 'http://creativecommons.org/licenses/by/3.0/'; 146 final cca = 'http://creativecommons.org/licenses/by/3.0/';
113 final bsd = 'http://code.google.com/google_bsd_license.html'; 147 final bsd = 'http://code.google.com/google_bsd_license.html';
114 final tos = 'http://www.dartlang.org/tos.html'; 148 final tos = 'http://www.dartlang.org/tos.html';
115 final privacy = 'http://www.google.com/intl/en/privacy/privacy-policy.html'; 149 final privacy = 'http://www.google.com/intl/en/privacy/privacy-policy.html';
116 150
117 footerText = 151 footerText =
118 ''' 152 '''
119 <p>Except as otherwise <a href="$note">noted</a>, the content of this 153 <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 154 page is licensed under the <a href="$cca">Creative Commons Attribution
121 3.0 License</a>, and code samples are licensed under the 155 3.0 License</a>, and code samples are licensed under the
122 <a href="$bsd">BSD License</a>.</p> 156 <a href="$bsd">BSD License</a>.</p>
123 <p><a href="$tos">Terms of Service</a> | 157 <p><a href="$tos">Terms of Service</a> |
124 <a href="$privacy">Privacy Policy</a></p> 158 <a href="$privacy">Privacy Policy</a></p>
125 '''; 159 ''';
126 160
161 preFooterText =
162 '''
163 <div id="comments">
164 <div id="disqus_thread"></div>
165 <script type="text/javascript">
166 /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAG E * * */
167 var disqus_shortname = "$disqusShortname"; // required: replace exam ple with your forum shortname
168
169 /* * * DON\'T EDIT BELOW THIS LINE * * */
170 (function() {
171 var dsq = document.createElement("script"); dsq.type = "text/jav ascript"; dsq.async = true;
172 dsq.src = "http://" + disqus_shortname + ".disqus.com/embed.js";
173 (document.getElementsByTagName("head")[0] || document.getElement sByTagName("body")[0]).appendChild(dsq);
174 })();
175 </script>
176 <noscript>Please enable JavaScript to view the <a href="http://disqus.co m/?ref_noscript">comments powered by Disqus.</a></noscript>
177 </div> <!-- #comments -->
178 ''';
179
127 searchEngineId = '011220921317074318178:i4mscbaxtru'; 180 searchEngineId = '011220921317074318178:i4mscbaxtru';
128 searchResultsUrl = 'http://www.dartlang.org/search.html'; 181 searchResultsUrl = 'http://www.dartlang.org/search.html';
129 } 182 }
130 183
131 void writeHeadContents(String title) { 184 void writeHeadContents(String title) {
132 super.writeHeadContents(title); 185 super.writeHeadContents(title);
133 186
134 // Include the apidoc-specific CSS. 187 // Include the apidoc-specific CSS.
135 // TODO(rnystrom): Use our CSS pre-processor to combine these. 188 // TODO(rnystrom): Use our CSS pre-processor to combine these.
136 writeln( 189 writeln(
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 return 487 return
435 ''' 488 '''
436 <p class="correspond">This corresponds to $domTypesText in the 489 <p class="correspond">This corresponds to $domTypesText in the
437 ${a("dom.html", "dart:dom")} library.</p> 490 ${a("dom.html", "dart:dom")} library.</p>
438 '''; 491 ''';
439 } 492 }
440 493
441 return ''; 494 return '';
442 } 495 }
443 } 496 }
OLDNEW
« no previous file with comments | « utils/apidoc/README.txt ('k') | utils/apidoc/static/apidoc-styles.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698