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

Side by Side Diff: pkg/docgen/lib/src/generator.dart

Issue 242363004: pkg/docgen: moved model classes into minilibs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: cl nits Created 6 years, 8 months 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 | « pkg/docgen/lib/src/exports/source_mirrors.dart ('k') | pkg/docgen/lib/src/library_helpers.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library docgen.generator; 5 library docgen.generator;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:io'; 10 import 'dart:io';
11 11
12 import 'package:markdown/markdown.dart' as markdown; 12 import 'package:markdown/markdown.dart' as markdown;
13 import 'package:path/path.dart' as path; 13 import 'package:path/path.dart' as path;
14 14
15 import '../../../../sdk/lib/_internal/compiler/compiler.dart' as api; 15 import '../../../../sdk/lib/_internal/compiler/compiler.dart' as api;
16 import '../../../../sdk/lib/_internal/compiler/implementation/filenames.dart'; 16 import '../../../../sdk/lib/_internal/compiler/implementation/filenames.dart';
17 import '../../../../sdk/lib/_internal/compiler/implementation/mirrors/analyze.da rt' 17 import '../../../../sdk/lib/_internal/compiler/implementation/mirrors/analyze.da rt'
18 as dart2js; 18 as dart2js;
19 import '../../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mi rrors.dart'
20 as dart2js_mirrors;
21 import '../../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_ut il.dart'
22 as dart2js_util;
23 import '../../../../sdk/lib/_internal/compiler/implementation/mirrors/source_mir rors.dart';
24 import '../../../../sdk/lib/_internal/compiler/implementation/source_file_provid er.dart'; 19 import '../../../../sdk/lib/_internal/compiler/implementation/source_file_provid er.dart';
25 import '../../../../sdk/lib/_internal/libraries.dart'; 20
21 import 'exports/dart2js_mirrors.dart' as dart2js_mirrors;
22 import 'exports/libraries.dart';
23 import 'exports/mirrors_util.dart' as dart2js_util;
24 import 'exports/source_mirrors.dart';
26 25
27 import 'io.dart'; 26 import 'io.dart';
28 import 'library_helpers.dart'; 27 import 'library_helpers.dart';
29 import 'models.dart'; 28 import 'models.dart';
30 import 'package_helpers.dart' show packageNameFor, rootDirectory; 29 import 'package_helpers.dart' show packageNameFor, rootDirectory;
31 30
32 const String DEFAULT_OUTPUT_DIRECTORY = 'docs'; 31 const String DEFAULT_OUTPUT_DIRECTORY = 'docs';
33 32
34 /// The directory where the output docs are generated. 33 /// The directory where the output docs are generated.
35 String get outputDirectory => _outputDirectory; 34 String get outputDirectory => _outputDirectory;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 119
121 // Finds the root of SDK library based off the location of docgen. 120 // Finds the root of SDK library based off the location of docgen.
122 // We have two different places to look, depending if we're in a development 121 // We have two different places to look, depending if we're in a development
123 // repo or in a built SDK, either sdk or dart-sdk respectively 122 // repo or in a built SDK, either sdk or dart-sdk respectively
124 var root = rootDirectory; 123 var root = rootDirectory;
125 var sdkRoot = path.normalize(path.absolute(path.join(root, 'sdk'))); 124 var sdkRoot = path.normalize(path.absolute(path.join(root, 'sdk')));
126 if (!new Directory(sdkRoot).existsSync()) { 125 if (!new Directory(sdkRoot).existsSync()) {
127 sdkRoot = path.normalize(path.absolute(path.join(root, 'dart-sdk'))); 126 sdkRoot = path.normalize(path.absolute(path.join(root, 'dart-sdk')));
128 } 127 }
129 logger.info('SDK Root: ${sdkRoot}'); 128 logger.info('SDK Root: ${sdkRoot}');
130 return analyzeLibraries(libraries, sdkRoot, 129 return analyzeLibraries(libraries, sdkRoot, packageRoot: packageRoot);
131 packageRoot: packageRoot);
132 } 130 }
133 131
134 /// Writes [text] to a file in the output directory. 132 /// Writes [text] to a file in the output directory.
135 void _writeToFile(String text, String filename) { 133 void _writeToFile(String text, String filename) {
136 if (text == null) return; 134 if (text == null) return;
137 135
138 var filePath = path.join(_outputDirectory, filename); 136 var filePath = path.join(_outputDirectory, filename);
139 137
140 var parentDir = new Directory(path.dirname(filePath)); 138 var parentDir = new Directory(path.dirname(filePath));
141 if (!parentDir.existsSync()) parentDir.createSync(recursive: true); 139 if (!parentDir.existsSync()) parentDir.createSync(recursive: true);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 225
228 // Outputs all the qualified names documented with their type. 226 // Outputs all the qualified names documented with their type.
229 // This will help generate search results. 227 // This will help generate search results.
230 var sortedEntities = filteredEntities 228 var sortedEntities = filteredEntities
231 .map((e) => '${e.qualifiedName} ${e.typeName}') 229 .map((e) => '${e.qualifiedName} ${e.typeName}')
232 .toList(); 230 .toList();
233 231
234 sortedEntities.sort(); 232 sortedEntities.sort();
235 233
236 var buffer = new StringBuffer() 234 var buffer = new StringBuffer()
237 ..writeAll(sortedEntities, '\n') 235 ..writeAll(sortedEntities, '\n')
Emily Fortuna 2014/04/21 16:41:08 nope only two spaces for the ..
Emily Fortuna 2014/04/21 17:28:27 huh looks like the style guide was updated. Sheesh
238 ..write('\n'); 236 ..write('\n');
239 237
240 _writeToFile(buffer.toString(), 'index.txt'); 238 _writeToFile(buffer.toString(), 'index.txt');
241 239
242 var index = new SplayTreeMap.fromIterable(filteredEntities, 240 var index = new SplayTreeMap.fromIterable(filteredEntities,
243 key: (e) => e.qualifiedName, value: (e) => e.typeName); 241 key: (e) => e.qualifiedName, value: (e) => e.typeName);
244 242
245 _writeToFile(encoder.convert(index), 'index.json'); 243 _writeToFile(encoder.convert(index), 'index.json');
246 } 244 }
247 245
248 /// Helper method to serialize the given Indexable out to a file. 246 /// Helper method to serialize the given Indexable out to a file.
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 * [Samples](http://www.dartlang.org/samples/) 461 * [Samples](http://www.dartlang.org/samples/)
464 * [A Tour of the Dart Libraries](http://www.dartlang.org/docs/dart-up-and-runn ing/contents/ch03.html) 462 * [A Tour of the Dart Libraries](http://www.dartlang.org/docs/dart-up-and-runn ing/contents/ch03.html)
465 463
466 This API reference is automatically generated from the source code in the 464 This API reference is automatically generated from the source code in the
467 [Dart project](https://code.google.com/p/dart/). 465 [Dart project](https://code.google.com/p/dart/).
468 If you'd like to contribute to this documentation, see 466 If you'd like to contribute to this documentation, see
469 [Contributing](https://code.google.com/p/dart/wiki/Contributing) 467 [Contributing](https://code.google.com/p/dart/wiki/Contributing)
470 and 468 and
471 [Writing API Documentation](https://code.google.com/p/dart/wiki/WritingApiDocume ntation). 469 [Writing API Documentation](https://code.google.com/p/dart/wiki/WritingApiDocume ntation).
472 """; 470 """;
OLDNEW
« no previous file with comments | « pkg/docgen/lib/src/exports/source_mirrors.dart ('k') | pkg/docgen/lib/src/library_helpers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698