| 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 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 * Documents the source code contained within [location]. | 1458 * Documents the source code contained within [location]. |
| 1459 */ | 1459 */ |
| 1460 void docCode(SourceLocation location) { | 1460 void docCode(SourceLocation location) { |
| 1461 if (includeSource) { | 1461 if (includeSource) { |
| 1462 writeln('<pre class="source">'); | 1462 writeln('<pre class="source">'); |
| 1463 writeln(md.escapeHtml(unindentCode(location))); | 1463 writeln(md.escapeHtml(unindentCode(location))); |
| 1464 writeln('</pre>'); | 1464 writeln('</pre>'); |
| 1465 } | 1465 } |
| 1466 } | 1466 } |
| 1467 | 1467 |
| 1468 DocComment createDocComment(String text, [ClassMirror inheritedFrom]) => | |
| 1469 new DocComment(text, inheritedFrom); | |
| 1470 | |
| 1471 /** Get the doc comment associated with the given library. */ | 1468 /** Get the doc comment associated with the given library. */ |
| 1472 DocComment getLibraryComment(LibraryMirror library) => getComment(library); | 1469 DocComment getLibraryComment(LibraryMirror library) => getComment(library); |
| 1473 | 1470 |
| 1474 /** Get the doc comment associated with the given type. */ | 1471 /** Get the doc comment associated with the given type. */ |
| 1475 DocComment getTypeComment(TypeMirror type) => getComment(type); | 1472 DocComment getTypeComment(TypeMirror type) => getComment(type); |
| 1476 | 1473 |
| 1477 /** | 1474 /** |
| 1478 * Get the doc comment associated with the given member. | 1475 * Get the doc comment associated with the given member. |
| 1479 * | 1476 * |
| 1480 * If no comment was found on the member, the hierarchy is traversed to find | 1477 * If no comment was found on the member, the hierarchy is traversed to find |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1504 comment = computeComment(inheritedMember); | 1501 comment = computeComment(inheritedMember); |
| 1505 if (comment != null) { | 1502 if (comment != null) { |
| 1506 inheritedFrom = type; | 1503 inheritedFrom = type; |
| 1507 break; | 1504 break; |
| 1508 } | 1505 } |
| 1509 } | 1506 } |
| 1510 } | 1507 } |
| 1511 } | 1508 } |
| 1512 } | 1509 } |
| 1513 if (comment == null) return null; | 1510 if (comment == null) return null; |
| 1514 return createDocComment(comment, inheritedFrom); | 1511 return new DocComment(comment, inheritedFrom); |
| 1515 } | 1512 } |
| 1516 | 1513 |
| 1517 /** | 1514 /** |
| 1518 * Converts [fullPath] which is understood to be a full path from the root of | 1515 * Converts [fullPath] which is understood to be a full path from the root of |
| 1519 * the generated docs to one relative to the current file. | 1516 * the generated docs to one relative to the current file. |
| 1520 */ | 1517 */ |
| 1521 String relativePath(String fullPath) { | 1518 String relativePath(String fullPath) { |
| 1522 // Don't make it relative if it's an absolute path. | 1519 // Don't make it relative if it's an absolute path. |
| 1523 if (isAbsolute(fullPath)) return fullPath; | 1520 if (isAbsolute(fullPath)) return fullPath; |
| 1524 | 1521 |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 final ClassMirror inheritedFrom; | 1903 final ClassMirror inheritedFrom; |
| 1907 | 1904 |
| 1908 DocComment(this.text, [this.inheritedFrom = null]) { | 1905 DocComment(this.text, [this.inheritedFrom = null]) { |
| 1909 assert(text != null && !text.trim().isEmpty); | 1906 assert(text != null && !text.trim().isEmpty); |
| 1910 } | 1907 } |
| 1911 | 1908 |
| 1912 String get html => md.markdownToHtml(text); | 1909 String get html => md.markdownToHtml(text); |
| 1913 | 1910 |
| 1914 String toString() => text; | 1911 String toString() => text; |
| 1915 } | 1912 } |
| OLD | NEW |