| 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 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1456 } | 1456 } |
| 1457 } | 1457 } |
| 1458 | 1458 |
| 1459 DocComment createDocComment(String text, [ClassMirror inheritedFrom]) => | 1459 DocComment createDocComment(String text, [ClassMirror inheritedFrom]) => |
| 1460 new DocComment(text, inheritedFrom); | 1460 new DocComment(text, inheritedFrom); |
| 1461 | 1461 |
| 1462 | 1462 |
| 1463 /** Get the doc comment associated with the given library. */ | 1463 /** Get the doc comment associated with the given library. */ |
| 1464 DocComment getLibraryComment(LibraryMirror library) { | 1464 DocComment getLibraryComment(LibraryMirror library) { |
| 1465 // Look for a comment for the entire library. | 1465 // Look for a comment for the entire library. |
| 1466 final comment = _comments.findLibrary(library.location.source); | 1466 final comment = _comments.findLibrary(library.location); |
| 1467 if (comment == null) return null; | 1467 if (comment == null) return null; |
| 1468 return createDocComment(comment); | 1468 return createDocComment(comment); |
| 1469 } | 1469 } |
| 1470 | 1470 |
| 1471 /** Get the doc comment associated with the given type. */ | 1471 /** Get the doc comment associated with the given type. */ |
| 1472 DocComment getTypeComment(TypeMirror type) { | 1472 DocComment getTypeComment(TypeMirror type) { |
| 1473 String comment = _comments.find(type.location); | 1473 String comment = _comments.find(type.location); |
| 1474 if (comment == null) return null; | 1474 if (comment == null) return null; |
| 1475 return createDocComment(comment); | 1475 return createDocComment(comment); |
| 1476 } | 1476 } |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1691 } | 1691 } |
| 1692 | 1692 |
| 1693 // Regular type. | 1693 // Regular type. |
| 1694 return type.simpleName; | 1694 return type.simpleName; |
| 1695 } | 1695 } |
| 1696 | 1696 |
| 1697 /** | 1697 /** |
| 1698 * Remove leading indentation to line up with first line. | 1698 * Remove leading indentation to line up with first line. |
| 1699 */ | 1699 */ |
| 1700 unindentCode(SourceLocation span) { | 1700 unindentCode(SourceLocation span) { |
| 1701 final column = getLocationColumn(span); | 1701 final column = span.column; |
| 1702 final lines = span.text.split('\n'); | 1702 final lines = span.text.split('\n'); |
| 1703 // TODO(rnystrom): Dirty hack. | 1703 // TODO(rnystrom): Dirty hack. |
| 1704 for (var i = 1; i < lines.length; i++) { | 1704 for (var i = 1; i < lines.length; i++) { |
| 1705 lines[i] = unindent(lines[i], column); | 1705 lines[i] = unindent(lines[i], column); |
| 1706 } | 1706 } |
| 1707 | 1707 |
| 1708 final code = Strings.join(lines, '\n'); | 1708 final code = Strings.join(lines, '\n'); |
| 1709 return code; | 1709 return code; |
| 1710 } | 1710 } |
| 1711 | 1711 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1867 final ClassMirror inheritedFrom; | 1867 final ClassMirror inheritedFrom; |
| 1868 | 1868 |
| 1869 DocComment(this.text, [this.inheritedFrom = null]) { | 1869 DocComment(this.text, [this.inheritedFrom = null]) { |
| 1870 assert(text != null && !text.trim().isEmpty); | 1870 assert(text != null && !text.trim().isEmpty); |
| 1871 } | 1871 } |
| 1872 | 1872 |
| 1873 String get html => md.markdownToHtml(text); | 1873 String get html => md.markdownToHtml(text); |
| 1874 | 1874 |
| 1875 String toString() => text; | 1875 String toString() => text; |
| 1876 } | 1876 } |
| OLD | NEW |