| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 * **docgen** is a tool for creating machine readable representations of Dart | 6 * **docgen** is a tool for creating machine readable representations of Dart |
| 7 * code metadata, including: classes, members, comments and annotations. | 7 * code metadata, including: classes, members, comments and annotations. |
| 8 * | 8 * |
| 9 * docgen is run on a `.dart` file or a directory containing `.dart` files. | 9 * docgen is run on a `.dart` file or a directory containing `.dart` files. |
| 10 * | 10 * |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 entityMap.values.where((e) => e is Class).forEach((c) => c.makeValid()); | 241 entityMap.values.where((e) => e is Class).forEach((c) => c.makeValid()); |
| 242 // Everything is a subclass of Object, therefore empty the list to avoid a | 242 // Everything is a subclass of Object, therefore empty the list to avoid a |
| 243 // giant list of subclasses to be printed out. | 243 // giant list of subclasses to be printed out. |
| 244 if (parseSdk) entityMap['dart.core.Object'].subclasses.clear(); | 244 if (parseSdk) entityMap['dart.core.Object'].subclasses.clear(); |
| 245 | 245 |
| 246 var filteredEntities = entityMap.values.where(_isVisible); | 246 var filteredEntities = entityMap.values.where(_isVisible); |
| 247 // Output libraries and classes to file after all information is generated. | 247 // Output libraries and classes to file after all information is generated. |
| 248 filteredEntities.where((e) => e is Class || e is Library).forEach((output) { | 248 filteredEntities.where((e) => e is Class || e is Library).forEach((output) { |
| 249 _writeIndexableToFile(output, outputToYaml); | 249 _writeIndexableToFile(output, outputToYaml); |
| 250 }); | 250 }); |
| 251 // Outputs a yaml file with all libraries and their preview comments after | 251 // Outputs a YAML or JSON file with all libraries and their preview comments |
| 252 // creating all libraries. This will help the viewer know what libraries are | 252 // after creating all libraries. This will help the viewer know what |
| 253 // available to read in. | 253 // libraries are available to read in. |
| 254 var libraryMap = { | 254 var libraryMap = { |
| 255 'libraries' : filteredEntities.where((e) => | 255 'libraries' : filteredEntities.where((e) => |
| 256 e is Library).map((e) => e.previewMap).toList(), | 256 e is Library).map((e) => e.previewMap).toList(), |
| 257 'introduction' : introduction == '' ? | 257 'introduction' : introduction == '' ? |
| 258 '' : markdown.markdownToHtml(new File(introduction).readAsStringSync(), | 258 '' : markdown.markdownToHtml(new File(introduction).readAsStringSync(), |
| 259 linkResolver: linkResolver, inlineSyntaxes: markdownSyntaxes) | 259 linkResolver: linkResolver, inlineSyntaxes: markdownSyntaxes) |
| 260 }; | 260 }; |
| 261 _writeToFile(getYamlString(libraryMap), 'library_list.yaml', append: append); | 261 if (outputToYaml) { |
| 262 _writeToFile(getYamlString(libraryMap), 'library_list.yaml', |
| 263 append: append); |
| 264 } else { |
| 265 _writeToFile(stringify(libraryMap), 'library_list.json', append: append); |
| 266 } |
| 262 // Outputs all the qualified names documented with their type. | 267 // Outputs all the qualified names documented with their type. |
| 263 // This will help generate search results. | 268 // This will help generate search results. |
| 264 _writeToFile(filteredEntities.map((e) => | 269 _writeToFile(filteredEntities.map((e) => |
| 265 '${e.qualifiedName} ${e.typeName}').join('\n'), | 270 '${e.qualifiedName} ${e.typeName}').join('\n'), |
| 266 'index.txt', append: append); | 271 'index.txt', append: append); |
| 267 } | 272 } |
| 268 | 273 |
| 269 Library generateLibrary(dart2js.Dart2JsLibraryMirror library) { | 274 Library generateLibrary(dart2js.Dart2JsLibraryMirror library) { |
| 270 _currentLibrary = library; | 275 _currentLibrary = library; |
| 271 var result = new Library(library.qualifiedName, _commentToHtml(library), | 276 var result = new Library(library.qualifiedName, _commentToHtml(library), |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1149 String qualifiedName; | 1154 String qualifiedName; |
| 1150 List<String> parameters; | 1155 List<String> parameters; |
| 1151 | 1156 |
| 1152 Annotation(this.qualifiedName, this.parameters); | 1157 Annotation(this.qualifiedName, this.parameters); |
| 1153 | 1158 |
| 1154 Map toMap() => { | 1159 Map toMap() => { |
| 1155 'name': qualifiedName, | 1160 'name': qualifiedName, |
| 1156 'parameters': parameters | 1161 'parameters': parameters |
| 1157 }; | 1162 }; |
| 1158 } | 1163 } |
| OLD | NEW |