| 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 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 _totalLibraries++; | 629 _totalLibraries++; |
| 630 _currentLibrary = library; | 630 _currentLibrary = library; |
| 631 _currentType = null; | 631 _currentType = null; |
| 632 | 632 |
| 633 startFile(libraryUrl(library)); | 633 startFile(libraryUrl(library)); |
| 634 writeHeader('${library.name} Library', | 634 writeHeader('${library.name} Library', |
| 635 [library.name, libraryUrl(library)]); | 635 [library.name, libraryUrl(library)]); |
| 636 writeln('<h2><strong>${library.name}</strong> library</h2>'); | 636 writeln('<h2><strong>${library.name}</strong> library</h2>'); |
| 637 | 637 |
| 638 // Look for a comment for the entire library. | 638 // Look for a comment for the entire library. |
| 639 final comment = _comments.findLibrary(library.baseSource); | 639 final comment = getLibraryComment(library); |
| 640 if (comment != null) { | 640 if (comment != null) { |
| 641 final html = md.markdownToHtml(comment); | 641 writeln('<div class="doc">$comment</div>'); |
| 642 writeln('<div class="doc">$html</div>'); | |
| 643 } | 642 } |
| 644 | 643 |
| 645 // Document the top-level members. | 644 // Document the top-level members. |
| 646 docMembers(library.topType); | 645 docMembers(library.topType); |
| 647 | 646 |
| 648 // Document the types. | 647 // Document the types. |
| 649 final classes = <Type>[]; | 648 final classes = <Type>[]; |
| 650 final interfaces = <Type>[]; | 649 final interfaces = <Type>[]; |
| 651 final exceptions = <Type>[]; | 650 final exceptions = <Type>[]; |
| 652 | 651 |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 | 1045 |
| 1047 if (includeSource && showCode) { | 1046 if (includeSource && showCode) { |
| 1048 writeln('<pre class="source">'); | 1047 writeln('<pre class="source">'); |
| 1049 writeln(md.escapeHtml(unindentCode(span))); | 1048 writeln(md.escapeHtml(unindentCode(span))); |
| 1050 writeln('</pre>'); | 1049 writeln('</pre>'); |
| 1051 } | 1050 } |
| 1052 | 1051 |
| 1053 writeln('</div>'); | 1052 writeln('</div>'); |
| 1054 } | 1053 } |
| 1055 | 1054 |
| 1055 |
| 1056 /** Get the doc comment associated with the given library. */ |
| 1057 String getLibraryComment(Library library) { |
| 1058 // Look for a comment for the entire library. |
| 1059 final comment = _comments.findLibrary(library.baseSource); |
| 1060 if (comment != null) { |
| 1061 return md.markdownToHtml(comment); |
| 1062 } |
| 1063 return null; |
| 1064 } |
| 1065 |
| 1056 /** Get the doc comment associated with the given type. */ | 1066 /** Get the doc comment associated with the given type. */ |
| 1057 String getTypeComment(Type type) { | 1067 String getTypeComment(Type type) { |
| 1058 String comment = _comments.find(type.span); | 1068 String comment = _comments.find(type.span); |
| 1059 if (comment == null) return null; | 1069 if (comment == null) return null; |
| 1060 return commentToHtml(comment); | 1070 return commentToHtml(comment); |
| 1061 } | 1071 } |
| 1062 | 1072 |
| 1063 /** Get the doc comment associated with the given method. */ | 1073 /** Get the doc comment associated with the given method. */ |
| 1064 String getMethodComment(MethodMember method) { | 1074 String getMethodComment(MethodMember method) { |
| 1065 String comment = _comments.find(method.span); | 1075 String comment = _comments.find(method.span); |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 if (filename.endsWith('appcache.manifest')) { | 1387 if (filename.endsWith('appcache.manifest')) { |
| 1378 return; | 1388 return; |
| 1379 } | 1389 } |
| 1380 var relativePath = filename.substring(pathPrefixLength + 1); | 1390 var relativePath = filename.substring(pathPrefixLength + 1); |
| 1381 write("$relativePath\n"); | 1391 write("$relativePath\n"); |
| 1382 }; | 1392 }; |
| 1383 toCache.onDone = (done) => endFile(); | 1393 toCache.onDone = (done) => endFile(); |
| 1384 toCache.list(recursive: true); | 1394 toCache.list(recursive: true); |
| 1385 } | 1395 } |
| 1386 } | 1396 } |
| OLD | NEW |