| 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 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1495 | 1495 |
| 1496 /// Given a mirror, returns its qualified name, but following the conventions | 1496 /// Given a mirror, returns its qualified name, but following the conventions |
| 1497 /// we're using in Dartdoc, which is that library names with dots in them | 1497 /// we're using in Dartdoc, which is that library names with dots in them |
| 1498 /// have them replaced with hyphens. | 1498 /// have them replaced with hyphens. |
| 1499 String docName(DeclarationMirror m) { | 1499 String docName(DeclarationMirror m) { |
| 1500 if (m is LibraryMirror) { | 1500 if (m is LibraryMirror) { |
| 1501 return m.qualifiedName.replaceAll('.','-'); | 1501 return m.qualifiedName.replaceAll('.','-'); |
| 1502 } | 1502 } |
| 1503 var owner = m.owner; | 1503 var owner = m.owner; |
| 1504 if (owner == null) return m.qualifiedName; | 1504 if (owner == null) return m.qualifiedName; |
| 1505 // For the unnamed constructor we just return the class name. | 1505 var simpleName = m.simpleName; |
| 1506 if (m.simpleName == '') return docName(owner); | 1506 if (m is MethodMirror && m.isConstructor) { |
| 1507 return docName(owner) + '.' + m.simpleName; | 1507 // We name constructors specially -- including the class name again and a |
| 1508 // "-" to separate the constructor from its name (if any). |
| 1509 simpleName = '${owner.simpleName}-$simpleName'; |
| 1510 } |
| 1511 return docName(owner) + '.' + simpleName; |
| 1508 } | 1512 } |
| 1509 | 1513 |
| 1510 /// Remove statics from the map of inherited items before adding them. | 1514 /// Remove statics from the map of inherited items before adding them. |
| 1511 Map _filterStatics(Map items) { | 1515 Map _filterStatics(Map items) { |
| 1512 var result = {}; | 1516 var result = {}; |
| 1513 items.forEach((name, item) { | 1517 items.forEach((name, item) { |
| 1514 if (!item.isStatic) { | 1518 if (!item.isStatic) { |
| 1515 result[name] = item; | 1519 result[name] = item; |
| 1516 } | 1520 } |
| 1517 }); | 1521 }); |
| 1518 return result; | 1522 return result; |
| 1519 } | 1523 } |
| OLD | NEW |