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

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

Issue 9705088: Generate API docs during build. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« dart.gyp ('K') | « utils/apidoc/apidoc ('k') | no next file » | 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 * Generates the complete set of corelib reference documentation. 6 * Generates the complete set of corelib reference documentation.
7 */ 7 */
8 #library('apidoc'); 8 #library('apidoc');
9 9
10 #import('dart:json'); 10 #import('dart:json');
11 #import('html_diff.dart'); 11 #import('html_diff.dart');
12 #import('../../frog/lang.dart'); 12 #import('../../frog/lang.dart');
13 #import('../../frog/file_system_vm.dart'); 13 #import('../../frog/file_system_vm.dart');
14 #import('../../frog/file_system.dart'); 14 #import('../../frog/file_system.dart');
15 #import('../../lib/dartdoc/dartdoc.dart', prefix: 'doc'); 15 #import('../../lib/dartdoc/dartdoc.dart', prefix: 'doc');
16 16
17 HtmlDiff _diff; 17 HtmlDiff _diff;
18 18
19 final GET_PREFIX = 'get:'; 19 final GET_PREFIX = 'get:';
20 20
21 void main() { 21 void main() {
22 final args = new Options().arguments;
23
24 var outputDir = 'docs';
25
26 // Use the output directory if provided.
27 if (args.length > 1) {
28 print('Usage: apidoc [--out=<output directory>]');
29 return;
30 } else if (args.length == 1) {
31 final arg = args[0];
32 if (arg.startsWith('--out=')) {
33 outputDir = arg.substring('--out='.length);
34 } else {
35 print('Unknown option: $arg');
36 return;
37 }
38 }
39
40 doc.cleanOutputDirectory(outputDir);
41
42 // TODO(rnystrom): Use platform-specific path separator.
43 // The basic dartdoc-provided static content.
44 doc.copyFiles('${doc.scriptDir}/../../lib/dartdoc/static', outputDir);
45
46 // The apidoc-specific static content.
47 doc.copyFiles('${doc.scriptDir}/static', outputDir);
48
22 var files = new VMFileSystem(); 49 var files = new VMFileSystem();
23 parseOptions('../../frog', ['', '', '--libdir=../../frog/lib'], files); 50 parseOptions('../../frog', ['', '', '--libdir=../../frog/lib'], files);
24 initializeWorld(files); 51 initializeWorld(files);
25 52
26 print('Parsing MDN data...'); 53 print('Parsing MDN data...');
27 final mdn = JSON.parse(files.readAll('mdn/database.json')); 54 final mdn = JSON.parse(files.readAll('mdn/database.json'));
28 55
29 print('Cross-referencing dart:dom and dart:html...'); 56 print('Cross-referencing dart:dom and dart:html...');
30 HtmlDiff.initialize(); 57 HtmlDiff.initialize();
31 _diff = new HtmlDiff(); 58 _diff = new HtmlDiff();
32 _diff.run(); 59 _diff.run();
33 world.reset(); 60 world.reset();
34 61
35 // TODO(rnystrom): Cram in the the IO libraries. This is hackish right now. 62 // TODO(rnystrom): Cram in the the IO libraries. This is hackish right now.
36 // We should probably move corelib stuff completely out of dartdoc and have it 63 // We should probably move corelib stuff completely out of dartdoc and have it
37 // all here. 64 // all here.
38 world.getOrAddLibrary('dart:io'); 65 world.getOrAddLibrary('dart:io');
39 66
40 print('Generating docs...'); 67 print('Generating docs...');
41 final apidoc = new Apidoc(mdn); 68 final apidoc = new Apidoc(mdn, outputDir);
42 apidoc.document('html'); 69 apidoc.document('html');
43 } 70 }
44 71
45 class Apidoc extends doc.Dartdoc { 72 class Apidoc extends doc.Dartdoc {
46 /** Big ball of JSON containing the scraped MDN documentation. */ 73 /** Big ball of JSON containing the scraped MDN documentation. */
47 final Map mdn; 74 final Map mdn;
48 75
49 /** 76 /**
50 * The URL to the page on MDN that content was pulled from for the current 77 * The URL to the page on MDN that content was pulled from for the current
51 * type being documented. Will be `null` if the type doesn't use any MDN 78 * type being documented. Will be `null` if the type doesn't use any MDN
52 * content. 79 * content.
53 */ 80 */
54 String mdnUrl; 81 String mdnUrl;
55 82
56 Apidoc(this.mdn) { 83 Apidoc(this.mdn, String outputDir) {
84 this.outputDir = outputDir;
85
57 mainTitle = 'Dart API Reference'; 86 mainTitle = 'Dart API Reference';
58 mainUrl = 'http://dartlang.org'; 87 mainUrl = 'http://dartlang.org';
59 88
60 final note = 'http://code.google.com/policies.html#restrictions'; 89 final note = 'http://code.google.com/policies.html#restrictions';
61 final cca = 'http://creativecommons.org/licenses/by/3.0/'; 90 final cca = 'http://creativecommons.org/licenses/by/3.0/';
62 final bsd = 'http://code.google.com/google_bsd_license.html'; 91 final bsd = 'http://code.google.com/google_bsd_license.html';
63 final tos = 'http://www.dartlang.org/tos.html'; 92 final tos = 'http://www.dartlang.org/tos.html';
64 final privacy = 'http://www.google.com/intl/en/privacy/privacy-policy.html'; 93 final privacy = 'http://www.google.com/intl/en/privacy/privacy-policy.html';
65 94
66 footerText = 95 footerText =
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 return 412 return
384 ''' 413 '''
385 <p class="correspond">This corresponds to $domTypesText in the 414 <p class="correspond">This corresponds to $domTypesText in the
386 ${a("dom.html", "dart:dom")} library.</p> 415 ${a("dom.html", "dart:dom")} library.</p>
387 '''; 416 ''';
388 } 417 }
389 418
390 return ''; 419 return '';
391 } 420 }
392 } 421 }
OLDNEW
« dart.gyp ('K') | « utils/apidoc/apidoc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698