OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 /** Path to corePath library. */ | 27 /** Path to corePath library. */ |
28 final corePath = 'lib'; | 28 final corePath = 'lib'; |
29 | 29 |
30 /** Path to generate html files into. */ | 30 /** Path to generate html files into. */ |
31 final outdir = 'docs'; | 31 final outdir = 'docs'; |
32 | 32 |
33 /** Set to `false` to not include the source code in the generated docs. */ | 33 /** Set to `false` to not include the source code in the generated docs. */ |
34 bool includeSource = true; | 34 bool includeSource = true; |
35 | 35 |
| 36 FileSystem files; |
| 37 |
36 /** Special comment position used to store the library-level doc comment. */ | 38 /** Special comment position used to store the library-level doc comment. */ |
37 final _libraryDoc = -1; | 39 final _libraryDoc = -1; |
38 | 40 |
39 /** The library that we're currently generating docs for. */ | 41 /** The library that we're currently generating docs for. */ |
40 Library _currentLibrary; | 42 Library _currentLibrary; |
41 | 43 |
42 /** The type that we're currently generating docs for. */ | 44 /** The type that we're currently generating docs for. */ |
43 Type _currentType; | 45 Type _currentType; |
44 | 46 |
45 /** The member that we're currently generating docs for. */ | 47 /** The member that we're currently generating docs for. */ |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 100 |
99 files = new NodeFileSystem(); | 101 files = new NodeFileSystem(); |
100 parseOptions('../../frog', [] /* args */, files); | 102 parseOptions('../../frog', [] /* args */, files); |
101 initializeWorld(files); | 103 initializeWorld(files); |
102 | 104 |
103 final elapsed = time(() { | 105 final elapsed = time(() { |
104 initializeDartDoc(); | 106 initializeDartDoc(); |
105 document(entrypoint); | 107 document(entrypoint); |
106 }); | 108 }); |
107 | 109 |
108 printStats(); | 110 printStats(elapsed); |
109 } | 111 } |
110 | 112 |
111 void initializeDartDoc() { | 113 void initializeDartDoc() { |
112 _comments = <Map<int, String>>{}; | 114 _comments = <Map<int, String>>{}; |
113 _typeDocumenters = <TypeDocumenter>[]; | 115 _typeDocumenters = <TypeDocumenter>[]; |
114 _methodDocumenters = <MethodDocumenter>[]; | 116 _methodDocumenters = <MethodDocumenter>[]; |
115 _fieldDocumenters = <FieldDocumenter>[]; | 117 _fieldDocumenters = <FieldDocumenter>[]; |
116 | 118 |
117 // Patch in support for [:...:]-style code to the markdown parser. | 119 // Patch in support for [:...:]-style code to the markdown parser. |
118 // TODO(rnystrom): Markdown already has syntax for this. Phase this out? | 120 // TODO(rnystrom): Markdown already has syntax for this. Phase this out? |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // Generate the docs. | 162 // Generate the docs. |
161 docIndex(); | 163 docIndex(); |
162 for (final library in world.libraries.getValues()) { | 164 for (final library in world.libraries.getValues()) { |
163 docLibrary(library); | 165 docLibrary(library); |
164 } | 166 } |
165 } finally { | 167 } finally { |
166 options.dietParse = oldDietParse; | 168 options.dietParse = oldDietParse; |
167 } | 169 } |
168 } | 170 } |
169 | 171 |
170 printStats() { | 172 printStats(num elapsed) { |
171 print('Documented $_totalLibraries libraries, $_totalTypes types, and ' + | 173 print('Documented $_totalLibraries libraries, $_totalTypes types, and ' + |
172 '$_totalMembers members in ${elapsed}msec.'); | 174 '$_totalMembers members in ${elapsed}msec.'); |
173 } | 175 } |
174 | 176 |
175 writeHeader(String title) { | 177 writeHeader(String title) { |
176 writeln( | 178 writeln( |
177 ''' | 179 ''' |
178 <!DOCTYPE html> | 180 <!DOCTYPE html> |
179 <html> | 181 <html> |
180 <head> | 182 <head> |
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 } | 889 } |
888 | 890 |
889 /** Register a callback to add additional documentation to a type. */ | 891 /** Register a callback to add additional documentation to a type. */ |
890 addTypeDocumenter(TypeDocumenter fn) => _typeDocumenters.add(fn); | 892 addTypeDocumenter(TypeDocumenter fn) => _typeDocumenters.add(fn); |
891 | 893 |
892 /** Register a callback to add additional documentation to a method. */ | 894 /** Register a callback to add additional documentation to a method. */ |
893 addMethodDocumenter(MethodDocumenter fn) => _methodDocumenters.add(fn); | 895 addMethodDocumenter(MethodDocumenter fn) => _methodDocumenters.add(fn); |
894 | 896 |
895 /** Register a callback to add additional documentation to a field. */ | 897 /** Register a callback to add additional documentation to a field. */ |
896 addFieldDocumenter(FieldDocumenter fn) => _fieldDocumenters.add(fn); | 898 addFieldDocumenter(FieldDocumenter fn) => _fieldDocumenters.add(fn); |
OLD | NEW |