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

Side by Side Diff: pkg/docgen/lib/docgen.dart

Issue 60733011: Fixing some more resolving issues with super classes in docgen. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 | « no previous file | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 /// **docgen** is a tool for creating machine readable representations of Dart 5 /// **docgen** is a tool for creating machine readable representations of Dart
6 /// code metadata, including: classes, members, comments and annotations. 6 /// code metadata, including: classes, members, comments and annotations.
7 /// 7 ///
8 /// docgen is run on a `.dart` file or a directory containing `.dart` files. 8 /// docgen is run on a `.dart` file or a directory containing `.dart` files.
9 /// 9 ///
10 /// $ dart docgen.dart [OPTIONS] [FILE/DIR] 10 /// $ dart docgen.dart [OPTIONS] [FILE/DIR]
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 var previousIndex = 373 var previousIndex =
374 JSON.decode(new File('docs/index.json').readAsStringSync()); 374 JSON.decode(new File('docs/index.json').readAsStringSync());
375 index.addAll(previousIndex); 375 index.addAll(previousIndex);
376 } 376 }
377 _writeToFile(JSON.encode(index), 'index.json'); 377 _writeToFile(JSON.encode(index), 'index.json');
378 } 378 }
379 379
380 Library generateLibrary(dart2js.Dart2JsLibraryMirror library) { 380 Library generateLibrary(dart2js.Dart2JsLibraryMirror library) {
381 _currentLibrary = library; 381 _currentLibrary = library;
382 var result = new Library(docName(library), _commentToHtml(library), 382 var result = new Library(docName(library), _commentToHtml(library),
383 _classes(library.classes),
384 _methods(library.functions),
383 _variables(library.variables), 385 _variables(library.variables),
384 _methods(library.functions), 386 _isHidden(library));
385 _classes(library.classes), _isHidden(library));
386 _findPackage(result, library); 387 _findPackage(result, library);
387 logger.fine('Generated library for ${result.name}'); 388 logger.fine('Generated library for ${result.name}');
388 return result; 389 return result;
389 } 390 }
390 391
391 void _writeIndexableToFile(Indexable result, bool outputToYaml) { 392 void _writeIndexableToFile(Indexable result, bool outputToYaml) {
392 var outputFile = result.fileName; 393 var outputFile = result.fileName;
393 var output; 394 var output;
394 if (outputToYaml) { 395 if (outputToYaml) {
395 output = getYamlString(result.toMap()); 396 output = getYamlString(result.toMap());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 .where((e) => e != null) 447 .where((e) => e != null)
447 .toList(); 448 .toList();
448 if (!skippedAnnotations.contains(docName(annotation.type))) { 449 if (!skippedAnnotations.contains(docName(annotation.type))) {
449 annotations.add(new Annotation(docName(annotation.type), 450 annotations.add(new Annotation(docName(annotation.type),
450 parameterList)); 451 parameterList));
451 } 452 }
452 }); 453 });
453 return annotations; 454 return annotations;
454 } 455 }
455 456
457 /// Update the global pointers to the current mirror to the particular mirror
458 /// we're documenting.
459 void _updateCurrentMirror(DeclarationMirror mirror) {
460 if (mirror is LibraryMirror) {
461 _currentLibrary = mirror;
462 } else if (mirror is ClassMirror) {
463 _currentClass = mirror;
464 } else if (mirror is MethodMirror) {
465 _currentMember = mirror;
466 }
467 }
468
456 /// Returns any documentation comments associated with a mirror with 469 /// Returns any documentation comments associated with a mirror with
457 /// simple markdown converted to html. 470 /// simple markdown converted to html.
458 String _commentToHtml(DeclarationMirror mirror) { 471 String _commentToHtml(DeclarationMirror mirror) {
459 String commentText; 472 String commentText;
473 _updateCurrentMirror(mirror);
460 mirror.metadata.forEach((metadata) { 474 mirror.metadata.forEach((metadata) {
461 if (metadata is CommentInstanceMirror) { 475 if (metadata is CommentInstanceMirror) {
462 CommentInstanceMirror comment = metadata; 476 CommentInstanceMirror comment = metadata;
463 if (comment.isDocComment) { 477 if (comment.isDocComment) {
464 if (commentText == null) { 478 if (commentText == null) {
465 commentText = comment.trimmedText; 479 commentText = comment.trimmedText;
466 } else { 480 } else {
467 commentText = '$commentText\n${comment.trimmedText}'; 481 commentText = '$commentText\n${comment.trimmedText}';
468 } 482 }
469 } 483 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 ClassMirror currentClass, MemberMirror currentMember) { 541 ClassMirror currentClass, MemberMirror currentMember) {
528 determineLookupFunc(name) => name.contains('.') ? 542 determineLookupFunc(name) => name.contains('.') ?
529 dart2js_util.lookupQualifiedInScope : 543 dart2js_util.lookupQualifiedInScope :
530 (mirror, name) => mirror.lookupInScope(name); 544 (mirror, name) => mirror.lookupInScope(name);
531 var lookupFunc = determineLookupFunc(name); 545 var lookupFunc = determineLookupFunc(name);
532 546
533 var memberScope = currentMember == null ? 547 var memberScope = currentMember == null ?
534 null : lookupFunc(currentMember, name); 548 null : lookupFunc(currentMember, name);
535 if (memberScope != null) return docName(memberScope); 549 if (memberScope != null) return docName(memberScope);
536 550
537 var classScope = currentClass == null ? 551 var classScope = currentClass;
538 null : lookupFunc(currentClass, name); 552 while (classScope != null) {
539 if (classScope != null) return docName(classScope); 553 var classFunc = lookupFunc(currentClass, name);
554 if (classFunc != null) return docName(classFunc);
555 classScope = classScope.superclass;
556 }
540 557
541 var libraryScope = currentLibrary == null ? 558 var libraryScope = currentLibrary == null ?
542 null : lookupFunc(currentLibrary, name); 559 null : lookupFunc(currentLibrary, name);
543 if (libraryScope != null) return docName(libraryScope); 560 if (libraryScope != null) return docName(libraryScope);
544 561
545 // Look in the dart core library scope. 562 // Look in the dart core library scope.
546 var coreScope = _coreLibrary == null? null : lookupFunc(_coreLibrary, name); 563 var coreScope = _coreLibrary == null? null : lookupFunc(_coreLibrary, name);
547 if (coreScope != null) return docName(_coreLibrary); 564 if (coreScope != null) return docName(_coreLibrary);
548 565
549 // If it's a reference that starts with a another library name, then it 566 // If it's a reference that starts with a another library name, then it
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 868
852 Map get previewMap { 869 Map get previewMap {
853 var basic = super.previewMap; 870 var basic = super.previewMap;
854 basic['packageName'] = packageName; 871 basic['packageName'] = packageName;
855 if (packageIntro != null) { 872 if (packageIntro != null) {
856 basic['packageIntro'] = packageIntro; 873 basic['packageIntro'] = packageIntro;
857 } 874 }
858 return basic; 875 return basic;
859 } 876 }
860 877
861 Library(String name, String comment, this.variables, 878 Library(String name, String comment, this.classes, this.functions,
862 this.functions, this.classes, bool isPrivate) : super(name, comment, 879 this.variables, bool isPrivate) : super(name, comment,
863 isPrivate, ""); 880 isPrivate, "");
864 881
865 /// Generates a map describing the [Library] object. 882 /// Generates a map describing the [Library] object.
866 Map toMap() => { 883 Map toMap() => {
867 'name': name, 884 'name': name,
868 'qualifiedName': qualifiedName, 885 'qualifiedName': qualifiedName,
869 'comment': comment, 886 'comment': comment,
870 'variables': recurseMap(variables), 887 'variables': recurseMap(variables),
871 'functions': functions.toMap(), 888 'functions': functions.toMap(),
872 'classes': classes.toMap(), 889 'classes': classes.toMap(),
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 /// Remove statics from the map of inherited items before adding them. 1384 /// Remove statics from the map of inherited items before adding them.
1368 Map _filterStatics(Map items) { 1385 Map _filterStatics(Map items) {
1369 var result = {}; 1386 var result = {};
1370 items.forEach((name, item) { 1387 items.forEach((name, item) {
1371 if (!item.isStatic) { 1388 if (!item.isStatic) {
1372 result[name] = item; 1389 result[name] = item;
1373 } 1390 }
1374 }); 1391 });
1375 return result; 1392 return result;
1376 } 1393 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698