Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(738)

Side by Side Diff: pkg/dartdoc/lib/dartdoc.dart

Issue 11345026: Move location to DeclarationMirror (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/dartdoc/lib/mirrors.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 writeln('</div>'); 1432 writeln('</div>');
1433 } else { 1433 } else {
1434 writeln(comment.html); 1434 writeln(comment.html);
1435 } 1435 }
1436 } 1436 }
1437 } 1437 }
1438 1438
1439 /** 1439 /**
1440 * Documents the source code contained within [location]. 1440 * Documents the source code contained within [location].
1441 */ 1441 */
1442 void docCode(Location location) { 1442 void docCode(SourceLocation location) {
1443 if (includeSource) { 1443 if (includeSource) {
1444 writeln('<pre class="source">'); 1444 writeln('<pre class="source">');
1445 writeln(md.escapeHtml(unindentCode(location))); 1445 writeln(md.escapeHtml(unindentCode(location)));
1446 writeln('</pre>'); 1446 writeln('</pre>');
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
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 return '${type.declaration.simpleName}&lt;$args&gt;'; 1681 return '${type.declaration.simpleName}&lt;$args&gt;';
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(Location span) { 1691 unindentCode(SourceLocation span) {
1692 final column = getLocationColumn(span); 1692 final column = getLocationColumn(span);
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
1703 /** 1703 /**
1704 * Takes a string of Dart code and turns it into sanitized HTML. 1704 * Takes a string of Dart code and turns it into sanitized HTML.
1705 */ 1705 */
1706 formatCode(Location span) { 1706 formatCode(SourceLocation span) {
1707 final code = unindentCode(span); 1707 final code = unindentCode(span);
1708 1708
1709 // Syntax highlight. 1709 // Syntax highlight.
1710 return classifySource(code); 1710 return classifySource(code);
1711 } 1711 }
1712 1712
1713 /** 1713 /**
1714 * This will be called whenever a doc comment hits a `[name]` in square 1714 * This will be called whenever a doc comment hits a `[name]` in square
1715 * brackets. It will try to figure out what the name refers to and link or 1715 * brackets. It will try to figure out what the name refers to and link or
1716 * style it appropriately. 1716 * style it appropriately.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « no previous file | pkg/dartdoc/lib/mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698