| OLD | NEW |
| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 if (library != null) { | 152 if (library != null) { |
| 153 library.packageName = packageName; | 153 library.packageName = packageName; |
| 154 // If we are the main library in a package, associate the package readme | 154 // If we are the main library in a package, associate the package readme |
| 155 // with us. | 155 // with us. |
| 156 // TODO(alanknight): We can't really rely on all packages having a library | 156 // TODO(alanknight): We can't really rely on all packages having a library |
| 157 // that matches the package name. Need a better way to store this. | 157 // that matches the package name. Need a better way to store this. |
| 158 if (library.packageName == library.name) { | 158 if (library.packageName == library.name) { |
| 159 library.packageIntro = _packageIntro(rootdir); | 159 library.packageIntro = _packageIntro(rootdir); |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 return packageName + '/'; | 162 return packageName; |
| 163 } | 163 } |
| 164 | 164 |
| 165 String _packageIntro(packageDir) { | 165 String _packageIntro(packageDir) { |
| 166 var dir = new Directory(packageDir); | 166 var dir = new Directory(packageDir); |
| 167 var files = dir.listSync(); | 167 var files = dir.listSync(); |
| 168 var readmes = files.where((FileSystemEntity each) => (each is File && | 168 var readmes = files.where((FileSystemEntity each) => (each is File && |
| 169 each.path.substring(packageDir.length + 1, each.path.length) | 169 each.path.substring(packageDir.length + 1, each.path.length) |
| 170 .startsWith('README'))).toList(); | 170 .startsWith('README'))).toList(); |
| 171 if (readmes.isEmpty) return ''; | 171 if (readmes.isEmpty) return ''; |
| 172 // If there are multiples, pick the shortest name. | 172 // If there are multiples, pick the shortest name. |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 String _htmlMdn(String content, String url) { | 539 String _htmlMdn(String content, String url) { |
| 540 return '<div class="mdn">' + content.trim() + '<p class="mdn-note">' | 540 return '<div class="mdn">' + content.trim() + '<p class="mdn-note">' |
| 541 '<a href="' + url.trim() + '">from Mdn</a></p></div>'; | 541 '<a href="' + url.trim() + '">from Mdn</a></p></div>'; |
| 542 } | 542 } |
| 543 | 543 |
| 544 /// Look for the specified name starting with the current member, and | 544 /// Look for the specified name starting with the current member, and |
| 545 /// progressively working outward to the current library scope. | 545 /// progressively working outward to the current library scope. |
| 546 String findElementInScope(String name, LibraryMirror currentLibrary, | 546 String findElementInScope(String name, LibraryMirror currentLibrary, |
| 547 ClassMirror currentClass, MemberMirror currentMember) { | 547 ClassMirror currentClass, MemberMirror currentMember) { |
| 548 var packagePrefix = _findPackage(currentLibrary); | 548 var packagePrefix = _findPackage(currentLibrary); |
| 549 if (packagePrefix != '') packagePrefix += '/'; |
| 549 | 550 |
| 550 determineLookupFunc(name) => name.contains('.') ? | 551 determineLookupFunc(name) => name.contains('.') ? |
| 551 dart2js_util.lookupQualifiedInScope : | 552 dart2js_util.lookupQualifiedInScope : |
| 552 (mirror, name) => mirror.lookupInScope(name); | 553 (mirror, name) => mirror.lookupInScope(name); |
| 553 var lookupFunc = determineLookupFunc(name); | 554 var lookupFunc = determineLookupFunc(name); |
| 554 | 555 |
| 555 var memberScope = currentMember == null ? | 556 var memberScope = currentMember == null ? |
| 556 null : lookupFunc(currentMember, name); | 557 null : lookupFunc(currentMember, name); |
| 557 if (memberScope != null) return packagePrefix + docName(memberScope); | 558 if (memberScope != null) return packagePrefix + docName(memberScope); |
| 558 | 559 |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1392 /// Remove statics from the map of inherited items before adding them. | 1393 /// Remove statics from the map of inherited items before adding them. |
| 1393 Map _filterStatics(Map items) { | 1394 Map _filterStatics(Map items) { |
| 1394 var result = {}; | 1395 var result = {}; |
| 1395 items.forEach((name, item) { | 1396 items.forEach((name, item) { |
| 1396 if (!item.isStatic) { | 1397 if (!item.isStatic) { |
| 1397 result[name] = item; | 1398 result[name] = item; |
| 1398 } | 1399 } |
| 1399 }); | 1400 }); |
| 1400 return result; | 1401 return result; |
| 1401 } | 1402 } |
| OLD | NEW |