| 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 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 writeln('</pre>'); | 974 writeln('</pre>'); |
| 975 } | 975 } |
| 976 | 976 |
| 977 writeln('</div>'); | 977 writeln('</div>'); |
| 978 } | 978 } |
| 979 | 979 |
| 980 /** Get the doc comment associated with the given type. */ | 980 /** Get the doc comment associated with the given type. */ |
| 981 String getTypeComment(Type type) { | 981 String getTypeComment(Type type) { |
| 982 String comment = _comments.find(type.span); | 982 String comment = _comments.find(type.span); |
| 983 if (comment == null) return null; | 983 if (comment == null) return null; |
| 984 return md.markdownToHtml(comment); | 984 return commentToHtml(comment); |
| 985 } | 985 } |
| 986 | 986 |
| 987 /** Get the doc comment associated with the given method. */ | 987 /** Get the doc comment associated with the given method. */ |
| 988 String getMethodComment(MethodMember method) { | 988 String getMethodComment(MethodMember method) { |
| 989 String comment = _comments.find(method.span); | 989 String comment = _comments.find(method.span); |
| 990 if (comment == null) return null; | 990 if (comment == null) return null; |
| 991 return md.markdownToHtml(comment); | 991 return commentToHtml(comment); |
| 992 } | 992 } |
| 993 | 993 |
| 994 /** Get the doc comment associated with the given field. */ | 994 /** Get the doc comment associated with the given field. */ |
| 995 String getFieldComment(FieldMember field) { | 995 String getFieldComment(FieldMember field) { |
| 996 String comment = _comments.find(field.span); | 996 String comment = _comments.find(field.span); |
| 997 if (comment == null) return null; | 997 if (comment == null) return null; |
| 998 return md.markdownToHtml(comment); | 998 return commentToHtml(comment); |
| 999 } | 999 } |
| 1000 | 1000 |
| 1001 String commentToHtml(String comment) => md.markdownToHtml(comment); |
| 1002 |
| 1001 /** | 1003 /** |
| 1002 * Converts [fullPath] which is understood to be a full path from the root of | 1004 * Converts [fullPath] which is understood to be a full path from the root of |
| 1003 * the generated docs to one relative to the current file. | 1005 * the generated docs to one relative to the current file. |
| 1004 */ | 1006 */ |
| 1005 String relativePath(String fullPath) { | 1007 String relativePath(String fullPath) { |
| 1006 // Don't make it relative if it's an absolute path. | 1008 // Don't make it relative if it's an absolute path. |
| 1007 if (isAbsolute(fullPath)) return fullPath; | 1009 if (isAbsolute(fullPath)) return fullPath; |
| 1008 | 1010 |
| 1009 // TODO(rnystrom): Walks all the way up to root each time. Shouldn't do | 1011 // TODO(rnystrom): Walks all the way up to root each time. Shouldn't do |
| 1010 // this if the paths overlap. | 1012 // this if the paths overlap. |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1278 | 1280 |
| 1279 return new md.Element.text('code', name); | 1281 return new md.Element.text('code', name); |
| 1280 } | 1282 } |
| 1281 | 1283 |
| 1282 // TODO(rnystrom): Move into SourceSpan? | 1284 // TODO(rnystrom): Move into SourceSpan? |
| 1283 int getSpanColumn(SourceSpan span) { | 1285 int getSpanColumn(SourceSpan span) { |
| 1284 final line = span.file.getLine(span.start); | 1286 final line = span.file.getLine(span.start); |
| 1285 return span.file.getColumn(line, span.start); | 1287 return span.file.getColumn(line, span.start); |
| 1286 } | 1288 } |
| 1287 } | 1289 } |
| OLD | NEW |