OLD | NEW |
1 // Copyright (c) 2011, 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 use it, from this directory, run: | 6 * To use it, from this directory, run: |
7 * | 7 * |
8 * $ ./dartdoc <path to .dart file> | 8 * $ ./dartdoc <path to .dart file> |
9 * | 9 * |
10 * This will create a "docs" directory with the docs for your libraries. To | 10 * This will create a "docs" directory with the docs for your libraries. To |
11 * create these beautiful docs, dartdoc parses your library and every library | 11 * create these beautiful docs, dartdoc parses your library and every library |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 * This dramatically reduces the generated size of the HTML since a large | 44 * This dramatically reduces the generated size of the HTML since a large |
45 * fraction of each static page is just redundant navigation links. | 45 * fraction of each static page is just redundant navigation links. |
46 * | 46 * |
47 * In this mode, the browser will do a XHR for nav.json which means that to | 47 * In this mode, the browser will do a XHR for nav.json which means that to |
48 * preview docs locally, you will need to enable requesting file:// links in | 48 * preview docs locally, you will need to enable requesting file:// links in |
49 * your browser or run a little local server like `python -m SimpleHTTPServer`. | 49 * your browser or run a little local server like `python -m SimpleHTTPServer`. |
50 */ | 50 */ |
51 final MODE_LIVE_NAV = 1; | 51 final MODE_LIVE_NAV = 1; |
52 | 52 |
53 /** | 53 /** |
54 * Run this from the `utils/dartdoc` directory. | 54 * Run this from the `lib/dartdoc` directory. |
55 */ | 55 */ |
56 void main() { | 56 void main() { |
57 final args = new Options().arguments; | 57 final args = new Options().arguments; |
58 | 58 |
59 // The entrypoint of the library to generate docs for. | 59 // The entrypoint of the library to generate docs for. |
60 final entrypoint = args[args.length - 1]; | 60 final entrypoint = args[args.length - 1]; |
61 | 61 |
62 // Parse the dartdoc options. | 62 // Parse the dartdoc options. |
63 bool includeSource = true; | 63 bool includeSource = true; |
64 var mode = MODE_LIVE_NAV; | 64 var mode = MODE_LIVE_NAV; |
(...skipping 12 matching lines...) Expand all Loading... |
77 case '--mode=live-nav': | 77 case '--mode=live-nav': |
78 mode = MODE_LIVE_NAV; | 78 mode = MODE_LIVE_NAV; |
79 break; | 79 break; |
80 | 80 |
81 default: | 81 default: |
82 print('Unknown option: $arg'); | 82 print('Unknown option: $arg'); |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 final files = new VMFileSystem(); | 86 final files = new VMFileSystem(); |
| 87 // TODO(rnystrom): Note that the following line gets munged by create-sdk to |
| 88 // work with the SDK's different file layout. If you change it here, make |
| 89 // sure SDK builds still work. |
87 parseOptions('../../frog', ['', '', '--libdir=../../frog/lib'], files); | 90 parseOptions('../../frog', ['', '', '--libdir=../../frog/lib'], files); |
88 initializeWorld(files); | 91 initializeWorld(files); |
89 | 92 |
90 var dartdoc; | 93 var dartdoc; |
91 final elapsed = time(() { | 94 final elapsed = time(() { |
92 dartdoc = new Dartdoc(); | 95 dartdoc = new Dartdoc(); |
93 dartdoc.includeSource = includeSource; | 96 dartdoc.includeSource = includeSource; |
94 dartdoc.mode = mode; | 97 dartdoc.mode = mode; |
95 | 98 |
96 dartdoc.document(entrypoint); | 99 dartdoc.document(entrypoint); |
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 | 1212 |
1210 return new md.Element.text('code', name); | 1213 return new md.Element.text('code', name); |
1211 } | 1214 } |
1212 | 1215 |
1213 // TODO(rnystrom): Move into SourceSpan? | 1216 // TODO(rnystrom): Move into SourceSpan? |
1214 int getSpanColumn(SourceSpan span) { | 1217 int getSpanColumn(SourceSpan span) { |
1215 final line = span.file.getLine(span.start); | 1218 final line = span.file.getLine(span.start); |
1216 return span.file.getColumn(line, span.start); | 1219 return span.file.getColumn(line, span.start); |
1217 } | 1220 } |
1218 } | 1221 } |
OLD | NEW |