@@ -29,6 +29,7 @@ import 'package:dartdoc/src/utils.dart';
29
29
import 'package:dartdoc/src/version.dart' ;
30
30
import 'package:dartdoc/src/warnings.dart' ;
31
31
import 'package:html/parser.dart' show parse;
32
+ import 'package:meta/meta.dart' ;
32
33
import 'package:path/path.dart' as path;
33
34
34
35
export 'package:dartdoc/src/dartdoc_options.dart' ;
@@ -43,14 +44,14 @@ const String programName = 'dartdoc';
43
44
const String dartdocVersion = packageVersion;
44
45
45
46
class DartdocFileWriter implements FileWriter {
46
- final String outputDir ;
47
+ final String _outputDir ;
47
48
@override
48
49
final ResourceProvider resourceProvider;
49
50
final Map <String , Warnable > _fileElementMap = {};
50
51
@override
51
52
final Set <String > writtenFiles = {};
52
53
53
- DartdocFileWriter (this .outputDir , this .resourceProvider);
54
+ DartdocFileWriter (this ._outputDir , this .resourceProvider);
54
55
55
56
@override
56
57
void writeBytes (
@@ -97,11 +98,11 @@ class DartdocFileWriter implements FileWriter {
97
98
}
98
99
}
99
100
100
- /// Returns the file at [outFile] relative to [outputDir ] , creating the parent
101
- /// directory if necessary.
101
+ /// Returns the file at [outFile] relative to [_outputDir ] , creating the
102
+ /// parent directory if necessary.
102
103
File _getFile (String outFile) {
103
104
var file = resourceProvider
104
- .getFile (resourceProvider.pathContext.join (outputDir , outFile));
105
+ .getFile (resourceProvider.pathContext.join (_outputDir , outFile));
105
106
var parent = file.parent2;
106
107
if (! parent.exists) {
107
108
parent.create ();
@@ -116,15 +117,15 @@ class Dartdoc {
116
117
final Generator generator;
117
118
final PackageBuilder packageBuilder;
118
119
final DartdocOptionContext config;
119
- final Set <String > writtenFiles = {};
120
- Folder outputDir ;
120
+ final Set <String > _writtenFiles = {};
121
+ Folder _outputDir ;
121
122
122
123
// Fires when the self checks make progress.
123
124
final StreamController <String > _onCheckProgress =
124
125
StreamController (sync : true );
125
126
126
127
Dartdoc ._(this .config, this .generator, this .packageBuilder) {
127
- outputDir = config.resourceProvider
128
+ _outputDir = config.resourceProvider
128
129
.getFolder (config.resourceProvider.pathContext.absolute (config.output))
129
130
..create ();
130
131
}
@@ -183,16 +184,11 @@ class Dartdoc {
183
184
184
185
PackageGraph packageGraph;
185
186
186
- /// Generate Dartdoc documentation.
187
- ///
188
- /// [DartdocResults] is returned if dartdoc succeeds. [DartdocFailure] is
189
- /// thrown if dartdoc fails in an expected way, for example if there is an
190
- /// analysis error in the code.
187
+ @visibleForTesting
191
188
Future <DartdocResults > generateDocsBase () async {
192
189
var stopwatch = Stopwatch ()..start ();
193
- double seconds;
194
190
packageGraph = await packageBuilder.buildPackageGraph ();
195
- seconds = stopwatch.elapsedMilliseconds / 1000.0 ;
191
+ var seconds = stopwatch.elapsedMilliseconds / 1000.0 ;
196
192
var libs = packageGraph.libraries.length;
197
193
logInfo ("Initialized dartdoc with $libs librar${libs == 1 ? 'y' : 'ies' } "
198
194
'in ${seconds .toStringAsFixed (1 )} seconds' );
@@ -201,14 +197,14 @@ class Dartdoc {
201
197
var generator = this .generator;
202
198
if (generator != null ) {
203
199
// Create the out directory.
204
- if (! outputDir .exists) outputDir .create ();
200
+ if (! _outputDir .exists) _outputDir .create ();
205
201
206
- var writer = DartdocFileWriter (outputDir .path, config.resourceProvider);
202
+ var writer = DartdocFileWriter (_outputDir .path, config.resourceProvider);
207
203
await generator.generate (packageGraph, writer);
208
204
209
- writtenFiles .addAll (writer.writtenFiles);
210
- if (config.validateLinks && writtenFiles .isNotEmpty) {
211
- validateLinks (packageGraph, outputDir .path);
205
+ _writtenFiles .addAll (writer.writtenFiles);
206
+ if (config.validateLinks && _writtenFiles .isNotEmpty) {
207
+ _validateLinks (packageGraph, _outputDir .path);
212
208
}
213
209
}
214
210
@@ -229,9 +225,14 @@ class Dartdoc {
229
225
if (config.showStats) {
230
226
logInfo (markdownStats.buildReport ());
231
227
}
232
- return DartdocResults (config.topLevelPackageMeta, packageGraph, outputDir );
228
+ return DartdocResults (config.topLevelPackageMeta, packageGraph, _outputDir );
233
229
}
234
230
231
+ /// Generate Dartdoc documentation.
232
+ ///
233
+ /// [DartdocResults] is returned if dartdoc succeeds. [DartdocFailure] is
234
+ /// thrown if dartdoc fails in an expected way, for example if there is an
235
+ /// analysis error in the code.
235
236
Future <DartdocResults > generateDocs () async {
236
237
try {
237
238
logInfo ('Documenting ${config .topLevelPackageMeta }...' );
@@ -252,7 +253,6 @@ class Dartdoc {
252
253
return dartdocResults;
253
254
} finally {
254
255
// Clear out any cached tool snapshots and temporary directories.
255
- // ignore: unawaited_futures
256
256
SnapshotCache .instance? .dispose ();
257
257
// ignore: unawaited_futures
258
258
ToolTempFileTracker .instance? .dispose ();
@@ -325,7 +325,7 @@ class Dartdoc {
325
325
}
326
326
if (visited.contains (fullPath)) continue ;
327
327
var relativeFullPath = path.relative (fullPath, from: normalOrigin);
328
- if (! writtenFiles .contains (relativeFullPath)) {
328
+ if (! _writtenFiles .contains (relativeFullPath)) {
329
329
// This isn't a file we wrote (this time); don't claim we did.
330
330
_warn (
331
331
packageGraph, PackageWarning .unknownFile, fullPath, normalOrigin);
@@ -471,7 +471,7 @@ class Dartdoc {
471
471
472
472
/// Don't call this method more than once, and only after you've
473
473
/// generated all docs for the Package.
474
- void validateLinks (PackageGraph packageGraph, String origin) {
474
+ void _validateLinks (PackageGraph packageGraph, String origin) {
475
475
assert (_hrefs == null );
476
476
_hrefs = packageGraph.allHrefs;
477
477
0 commit comments