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

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

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 | « tools/testing/dart/test_runner.dart ('k') | utils/apidoc/mdn/extract.dart » ('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 *
11 * Usage: 11 * Usage:
12 * 12 *
13 * $ dart apidoc.dart [--out=<output directory>] 13 * $ dart apidoc.dart [--out=<output directory>]
14 */ 14 */
15 library apidoc; 15 library apidoc;
16 16
17 import 'dart:async';
17 import 'dart:io'; 18 import 'dart:io';
18 import 'dart:json'; 19 import 'dart:json' as json;
19 import 'html_diff.dart'; 20 import 'html_diff.dart';
20 // TODO(rnystrom): Use "package:" URL (#4968). 21 // TODO(rnystrom): Use "package:" URL (#4968).
21 import '../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart'; 22 import '../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart';
22 import '../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dar t'; 23 import '../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dar t';
23 import '../../sdk/lib/_internal/dartdoc/lib/dartdoc.dart' as doc; 24 import '../../sdk/lib/_internal/dartdoc/lib/dartdoc.dart' as doc;
24 import '../../sdk/lib/_internal/libraries.dart'; 25 import '../../sdk/lib/_internal/libraries.dart';
25 26
26 HtmlDiff _diff; 27 HtmlDiff _diff;
27 28
28 void main() { 29 void main() {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 doc.scriptDir.append('../../sdk/lib/_internal/dartdoc/static'), 81 doc.scriptDir.append('../../sdk/lib/_internal/dartdoc/static'),
81 outputDir); 82 outputDir);
82 83
83 // The apidoc-specific static content. 84 // The apidoc-specific static content.
84 final copiedApiDocStatic = doc.copyDirectory( 85 final copiedApiDocStatic = doc.copyDirectory(
85 doc.scriptDir.append('static'), 86 doc.scriptDir.append('static'),
86 outputDir); 87 outputDir);
87 88
88 print('Parsing MDN data...'); 89 print('Parsing MDN data...');
89 final mdnFile = new File.fromPath(doc.scriptDir.append('mdn/database.json')); 90 final mdnFile = new File.fromPath(doc.scriptDir.append('mdn/database.json'));
90 final mdn = JSON.parse(mdnFile.readAsStringSync()); 91 final mdn = json.parse(mdnFile.readAsStringSync());
91 92
92 print('Cross-referencing dart:html...'); 93 print('Cross-referencing dart:html...');
93 HtmlDiff.initialize(libPath); 94 HtmlDiff.initialize(libPath);
94 _diff = new HtmlDiff(printWarnings:false); 95 _diff = new HtmlDiff(printWarnings:false);
95 _diff.run(); 96 _diff.run();
96 97
97 // Process handwritten HTML documentation. 98 // Process handwritten HTML documentation.
98 print('Processing handwritten HTML documentation...'); 99 print('Processing handwritten HTML documentation...');
99 final htmldoc = new Htmldoc(); 100 final htmldoc = new Htmldoc();
100 htmldoc.includeApi = true; 101 htmldoc.includeApi = true;
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 // If it's an HTML type, try to map it to a base DOM type so we can find 478 // If it's an HTML type, try to map it to a base DOM type so we can find
478 // the MDN docs. 479 // the MDN docs.
479 final domTypes = _diff.htmlTypesToDom[type.qualifiedName]; 480 final domTypes = _diff.htmlTypesToDom[type.qualifiedName];
480 481
481 // Couldn't find a DOM type. 482 // Couldn't find a DOM type.
482 if ((domTypes == null) || (domTypes.length != 1)) return null; 483 if ((domTypes == null) || (domTypes.length != 1)) return null;
483 484
484 // Use the corresponding DOM type when searching MDN. 485 // Use the corresponding DOM type when searching MDN.
485 // TODO(rnystrom): Shame there isn't a simpler way to get the one item 486 // TODO(rnystrom): Shame there isn't a simpler way to get the one item
486 // out of a singleton Set. 487 // out of a singleton Set.
487 typeString = domTypes.iterator().next(); 488 // TODO(floitsch): switch to domTypes.first, once that's implemented.
489 var iter = domTypes.iterator;
490 iter.moveNext();
491 typeString = iter.current;
488 } else { 492 } else {
489 // Not a DOM type. 493 // Not a DOM type.
490 return null; 494 return null;
491 } 495 }
492 496
493 final mdnType = mdn[typeString]; 497 final mdnType = mdn[typeString];
494 if (mdnType == null) return null; 498 if (mdnType == null) return null;
495 if (mdnType['skipped'] != null) return null; 499 if (mdnType['skipped'] != null) return null;
496 if (mdnType['summary'] == null) return null; 500 if (mdnType['summary'] == null) return null;
497 if (mdnType['summary'].trim().isEmpty) return null; 501 if (mdnType['summary'].trim().isEmpty) return null;
(...skipping 13 matching lines...) Expand all
511 // If it's an HTML type, try to map it to a DOM type name so we can find 515 // If it's an HTML type, try to map it to a DOM type name so we can find
512 // the MDN docs. 516 // the MDN docs.
513 final domMembers = _diff.htmlToDom[member.qualifiedName]; 517 final domMembers = _diff.htmlToDom[member.qualifiedName];
514 518
515 // Couldn't find a DOM type. 519 // Couldn't find a DOM type.
516 if ((domMembers == null) || (domMembers.length != 1)) return null; 520 if ((domMembers == null) || (domMembers.length != 1)) return null;
517 521
518 // Use the corresponding DOM member when searching MDN. 522 // Use the corresponding DOM member when searching MDN.
519 // TODO(rnystrom): Shame there isn't a simpler way to get the one item 523 // TODO(rnystrom): Shame there isn't a simpler way to get the one item
520 // out of a singleton Set. 524 // out of a singleton Set.
521 memberString = domMembers.iterator().next(); 525 // TODO(floitsch): switch to domTypes.first, once that's implemented.
526 var iter = domMembers.iterator;
527 iter.moveNext();
528 memberString = iter.current;
522 } else { 529 } else {
523 // Not a DOM type. 530 // Not a DOM type.
524 return null; 531 return null;
525 } 532 }
526 533
527 // Ignore top-level functions. 534 // Ignore top-level functions.
528 if (member.isTopLevel) return null; 535 if (member.isTopLevel) return null;
529 536
530 var mdnMember = null; 537 var mdnMember = null;
531 var mdnType = null; 538 var mdnType = null;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 return ''' 589 return '''
583 <div class="mdn"> 590 <div class="mdn">
584 $mdnComment 591 $mdnComment
585 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div> 592 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div>
586 </div> 593 </div>
587 '''; 594 ''';
588 } 595 }
589 596
590 String toString() => mdnComment; 597 String toString() => mdnComment;
591 } 598 }
OLDNEW
« no previous file with comments | « tools/testing/dart/test_runner.dart ('k') | utils/apidoc/mdn/extract.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698