| OLD | NEW |
| 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 * To generate docs for a library, run this script with the path to an | 6 * To generate docs for a library, run this script with the path to an |
| 7 * entrypoint .dart file, like: | 7 * entrypoint .dart file, like: |
| 8 * | 8 * |
| 9 * $ dart dartdoc.dart foo.dart | 9 * $ dart dartdoc.dart foo.dart |
| 10 * | 10 * |
| (...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1447 } | 1447 } |
| 1448 } | 1448 } |
| 1449 | 1449 |
| 1450 DocComment createDocComment(String text, [ClassMirror inheritedFrom]) => | 1450 DocComment createDocComment(String text, [ClassMirror inheritedFrom]) => |
| 1451 new DocComment(text, inheritedFrom); | 1451 new DocComment(text, inheritedFrom); |
| 1452 | 1452 |
| 1453 | 1453 |
| 1454 /** Get the doc comment associated with the given library. */ | 1454 /** Get the doc comment associated with the given library. */ |
| 1455 DocComment getLibraryComment(LibraryMirror library) { | 1455 DocComment getLibraryComment(LibraryMirror library) { |
| 1456 // Look for a comment for the entire library. | 1456 // Look for a comment for the entire library. |
| 1457 final comment = _comments.findLibrary(library.location.source); | 1457 final comment = _comments.findLibrary(library.location); |
| 1458 if (comment == null) return null; | 1458 if (comment == null) return null; |
| 1459 return createDocComment(comment); | 1459 return createDocComment(comment); |
| 1460 } | 1460 } |
| 1461 | 1461 |
| 1462 /** Get the doc comment associated with the given type. */ | 1462 /** Get the doc comment associated with the given type. */ |
| 1463 DocComment getTypeComment(TypeMirror type) { | 1463 DocComment getTypeComment(TypeMirror type) { |
| 1464 String comment = _comments.find(type.location); | 1464 String comment = _comments.find(type.location); |
| 1465 if (comment == null) return null; | 1465 if (comment == null) return null; |
| 1466 return createDocComment(comment); | 1466 return createDocComment(comment); |
| 1467 } | 1467 } |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1682 } | 1682 } |
| 1683 | 1683 |
| 1684 // Regular type. | 1684 // Regular type. |
| 1685 return type.simpleName; | 1685 return type.simpleName; |
| 1686 } | 1686 } |
| 1687 | 1687 |
| 1688 /** | 1688 /** |
| 1689 * Remove leading indentation to line up with first line. | 1689 * Remove leading indentation to line up with first line. |
| 1690 */ | 1690 */ |
| 1691 unindentCode(SourceLocation span) { | 1691 unindentCode(SourceLocation span) { |
| 1692 final column = getLocationColumn(span); | 1692 final column = span.column; |
| 1693 final lines = span.text.split('\n'); | 1693 final lines = span.text.split('\n'); |
| 1694 // TODO(rnystrom): Dirty hack. | 1694 // TODO(rnystrom): Dirty hack. |
| 1695 for (var i = 1; i < lines.length; i++) { | 1695 for (var i = 1; i < lines.length; i++) { |
| 1696 lines[i] = unindent(lines[i], column); | 1696 lines[i] = unindent(lines[i], column); |
| 1697 } | 1697 } |
| 1698 | 1698 |
| 1699 final code = Strings.join(lines, '\n'); | 1699 final code = Strings.join(lines, '\n'); |
| 1700 return code; | 1700 return code; |
| 1701 } | 1701 } |
| 1702 | 1702 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1857 final ClassMirror inheritedFrom; | 1857 final ClassMirror inheritedFrom; |
| 1858 | 1858 |
| 1859 DocComment(this.text, [this.inheritedFrom = null]) { | 1859 DocComment(this.text, [this.inheritedFrom = null]) { |
| 1860 assert(text != null && !text.trim().isEmpty); | 1860 assert(text != null && !text.trim().isEmpty); |
| 1861 } | 1861 } |
| 1862 | 1862 |
| 1863 String get html => md.markdownToHtml(text); | 1863 String get html => md.markdownToHtml(text); |
| 1864 | 1864 |
| 1865 String toString() => text; | 1865 String toString() => text; |
| 1866 } | 1866 } |
| OLD | NEW |