@@ -48,15 +48,15 @@ class DartdocGeneratorOptionContext extends DartdocOptionContext
48
48
/// directory.
49
49
class Dartdoc extends PackageBuilder {
50
50
final List <Generator > generators;
51
- final Set <String > writtenFiles = new Set ();
51
+ final Set <String > writtenFiles = Set ();
52
52
Directory outputDir;
53
53
54
54
// Fires when the self checks make progress.
55
55
final StreamController <String > _onCheckProgress =
56
- new StreamController (sync : true );
56
+ StreamController (sync : true );
57
57
58
58
Dartdoc ._(DartdocOptionContext config, this .generators) : super (config) {
59
- outputDir = new Directory (config.output)..createSync (recursive: true );
59
+ outputDir = Directory (config.output)..createSync (recursive: true );
60
60
generators.forEach ((g) => g.onFileCreated.listen (logProgress));
61
61
}
62
62
@@ -65,19 +65,19 @@ class Dartdoc extends PackageBuilder {
65
65
static Future <Dartdoc > withDefaultGenerators (
66
66
DartdocGeneratorOptionContext config) async {
67
67
List <Generator > generators = await initGenerators (config);
68
- return new Dartdoc ._(config, generators);
68
+ return Dartdoc ._(config, generators);
69
69
}
70
70
71
71
/// An asynchronous factory method that builds
72
72
static Future <Dartdoc > withEmptyGenerator (DartdocOptionContext config) async {
73
73
List <Generator > generators = await initEmptyGenerators (config);
74
- return new Dartdoc ._(config, generators);
74
+ return Dartdoc ._(config, generators);
75
75
}
76
76
77
77
/// Basic synchronous factory that gives a stripped down Dartdoc that won't
78
78
/// use generators. Useful for testing.
79
79
factory Dartdoc .withoutGenerators (DartdocOptionContext config) {
80
- return new Dartdoc ._(config, []);
80
+ return Dartdoc ._(config, []);
81
81
}
82
82
83
83
Stream <String > get onCheckProgress => _onCheckProgress.stream;
@@ -90,7 +90,7 @@ class Dartdoc extends PackageBuilder {
90
90
/// thrown if dartdoc fails in an expected way, for example if there is an
91
91
/// analysis error in the code.
92
92
Future <DartdocResults > generateDocsBase () async {
93
- Stopwatch _stopwatch = new Stopwatch ()..start ();
93
+ Stopwatch _stopwatch = Stopwatch ()..start ();
94
94
double seconds;
95
95
packageGraph = await buildPackageGraph ();
96
96
seconds = _stopwatch.elapsedMilliseconds / 1000.0 ;
@@ -125,23 +125,21 @@ class Dartdoc extends PackageBuilder {
125
125
logInfo (
126
126
"Documented ${packageGraph .localPublicLibraries .length } public librar${packageGraph .localPublicLibraries .length == 1 ? 'y' : 'ies' } "
127
127
"in ${seconds .toStringAsFixed (1 )} seconds" );
128
- return new DartdocResults (
129
- config.topLevelPackageMeta, packageGraph, outputDir);
128
+ return DartdocResults (config.topLevelPackageMeta, packageGraph, outputDir);
130
129
}
131
130
132
131
Future <DartdocResults > generateDocs () async {
133
132
logPrint ("Documenting ${config .topLevelPackageMeta }..." );
134
133
135
134
DartdocResults dartdocResults = await generateDocsBase ();
136
135
if (dartdocResults.packageGraph.localPublicLibraries.isEmpty) {
137
- throw new DartdocFailure (
138
- "dartdoc could not find any libraries to document" );
136
+ throw DartdocFailure ("dartdoc could not find any libraries to document" );
139
137
}
140
138
141
139
final int errorCount =
142
140
dartdocResults.packageGraph.packageWarningCounter.errorCount;
143
141
if (errorCount > 0 ) {
144
- throw new DartdocFailure (
142
+ throw DartdocFailure (
145
143
"dartdoc encountered $errorCount } errors while processing." );
146
144
}
147
145
logInfo (
@@ -156,7 +154,7 @@ class Dartdoc extends PackageBuilder {
156
154
// Ordinarily this would go in [Package.warn], but we don't actually know what
157
155
// ModelElement to warn on yet.
158
156
Warnable warnOnElement;
159
- Set <Warnable > referredFromElements = new Set ();
157
+ Set <Warnable > referredFromElements = Set ();
160
158
Set <Warnable > warnOnElements;
161
159
162
160
// Make all paths relative to origin.
@@ -202,7 +200,7 @@ class Dartdoc extends PackageBuilder {
202
200
String indexJson = path.joinAll ([normalOrigin, 'index.json' ]);
203
201
bool foundIndexJson = false ;
204
202
for (FileSystemEntity f
205
- in new Directory (normalOrigin).listSync (recursive: true )) {
203
+ in Directory (normalOrigin).listSync (recursive: true )) {
206
204
var fullPath = path.normalize (f.path);
207
205
if (f is Directory ) {
208
206
continue ;
@@ -240,7 +238,7 @@ class Dartdoc extends PackageBuilder {
240
238
// This is extracted to save memory during the check; be careful not to hang
241
239
// on to anything referencing the full file and doc tree.
242
240
Tuple2 <Iterable <String >, String > _getStringLinksAndHref (String fullPath) {
243
- File file = new File ("$fullPath " );
241
+ File file = File ("$fullPath " );
244
242
if (! file.existsSync ()) {
245
243
return null ;
246
244
}
@@ -256,21 +254,21 @@ class Dartdoc extends PackageBuilder {
256
254
.where ((href) => href != null )
257
255
.toList ();
258
256
259
- return new Tuple2 (stringLinks, baseHref);
257
+ return Tuple2 (stringLinks, baseHref);
260
258
}
261
259
262
260
void _doSearchIndexCheck (
263
261
PackageGraph packageGraph, String origin, Set <String > visited) {
264
262
String fullPath = path.joinAll ([origin, 'index.json' ]);
265
263
String indexPath = path.joinAll ([origin, 'index.html' ]);
266
- File file = new File ("$fullPath " );
264
+ File file = File ("$fullPath " );
267
265
if (! file.existsSync ()) {
268
266
return null ;
269
267
}
270
- JsonDecoder decoder = new JsonDecoder ();
268
+ JsonDecoder decoder = JsonDecoder ();
271
269
List jsonData = decoder.convert (file.readAsStringSync ());
272
270
273
- Set <String > found = new Set ();
271
+ Set <String > found = Set ();
274
272
found.add (fullPath);
275
273
// The package index isn't supposed to be in the search, so suppress the
276
274
// warning.
@@ -322,9 +320,9 @@ class Dartdoc extends PackageBuilder {
322
320
// here instead -- occasionally, very large jobs have overflowed
323
321
// the stack without this.
324
322
// (newPathToCheck, newFullPath)
325
- Set <Tuple2 <String , String >> toVisit = new Set ();
323
+ Set <Tuple2 <String , String >> toVisit = Set ();
326
324
327
- final RegExp ignoreHyperlinks = new RegExp (r'^(https:|http:|mailto:|ftp:)' );
325
+ final RegExp ignoreHyperlinks = RegExp (r'^(https:|http:|mailto:|ftp:)' );
328
326
for (String href in stringLinks) {
329
327
if (! href.startsWith (ignoreHyperlinks)) {
330
328
Uri uri;
@@ -345,7 +343,7 @@ class Dartdoc extends PackageBuilder {
345
343
String newFullPath = path.joinAll ([origin, newPathToCheck]);
346
344
newFullPath = path.normalize (newFullPath);
347
345
if (! visited.contains (newFullPath)) {
348
- toVisit.add (new Tuple2 (newPathToCheck, newFullPath));
346
+ toVisit.add (Tuple2 (newPathToCheck, newFullPath));
349
347
visited.add (newFullPath);
350
348
}
351
349
}
@@ -366,7 +364,7 @@ class Dartdoc extends PackageBuilder {
366
364
assert (_hrefs == null );
367
365
_hrefs = packageGraph.allHrefs;
368
366
369
- final Set <String > visited = new Set ();
367
+ final Set <String > visited = Set ();
370
368
final String start = 'index.html' ;
371
369
logInfo ('Validating docs...' );
372
370
_doCheck (packageGraph, origin, visited, start);
0 commit comments