@@ -29,6 +29,7 @@ import 'package:dartdoc/src/utils.dart';
2929import 'package:dartdoc/src/version.dart' ;
3030import 'package:dartdoc/src/warnings.dart' ;
3131import 'package:html/parser.dart' show parse;
32+ import 'package:meta/meta.dart' ;
3233import 'package:path/path.dart' as path;
3334
3435export 'package:dartdoc/src/dartdoc_options.dart' ;
@@ -43,14 +44,14 @@ const String programName = 'dartdoc';
4344const String dartdocVersion = packageVersion;
4445
4546class DartdocFileWriter implements FileWriter {
46- final String outputDir ;
47+ final String _outputDir ;
4748 @override
4849 final ResourceProvider resourceProvider;
4950 final Map <String , Warnable > _fileElementMap = {};
5051 @override
5152 final Set <String > writtenFiles = {};
5253
53- DartdocFileWriter (this .outputDir , this .resourceProvider);
54+ DartdocFileWriter (this ._outputDir , this .resourceProvider);
5455
5556 @override
5657 void writeBytes (
@@ -97,11 +98,11 @@ class DartdocFileWriter implements FileWriter {
9798 }
9899 }
99100
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.
102103 File _getFile (String outFile) {
103104 var file = resourceProvider
104- .getFile (resourceProvider.pathContext.join (outputDir , outFile));
105+ .getFile (resourceProvider.pathContext.join (_outputDir , outFile));
105106 var parent = file.parent2;
106107 if (! parent.exists) {
107108 parent.create ();
@@ -116,15 +117,15 @@ class Dartdoc {
116117 final Generator generator;
117118 final PackageBuilder packageBuilder;
118119 final DartdocOptionContext config;
119- final Set <String > writtenFiles = {};
120- Folder outputDir ;
120+ final Set <String > _writtenFiles = {};
121+ Folder _outputDir ;
121122
122123 // Fires when the self checks make progress.
123124 final StreamController <String > _onCheckProgress =
124125 StreamController (sync : true );
125126
126127 Dartdoc ._(this .config, this .generator, this .packageBuilder) {
127- outputDir = config.resourceProvider
128+ _outputDir = config.resourceProvider
128129 .getFolder (config.resourceProvider.pathContext.absolute (config.output))
129130 ..create ();
130131 }
@@ -183,16 +184,11 @@ class Dartdoc {
183184
184185 PackageGraph packageGraph;
185186
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
191188 Future <DartdocResults > generateDocsBase () async {
192189 var stopwatch = Stopwatch ()..start ();
193- double seconds;
194190 packageGraph = await packageBuilder.buildPackageGraph ();
195- seconds = stopwatch.elapsedMilliseconds / 1000.0 ;
191+ var seconds = stopwatch.elapsedMilliseconds / 1000.0 ;
196192 var libs = packageGraph.libraries.length;
197193 logInfo ("Initialized dartdoc with $libs librar${libs == 1 ? 'y' : 'ies' } "
198194 'in ${seconds .toStringAsFixed (1 )} seconds' );
@@ -201,14 +197,14 @@ class Dartdoc {
201197 var generator = this .generator;
202198 if (generator != null ) {
203199 // Create the out directory.
204- if (! outputDir .exists) outputDir .create ();
200+ if (! _outputDir .exists) _outputDir .create ();
205201
206- var writer = DartdocFileWriter (outputDir .path, config.resourceProvider);
202+ var writer = DartdocFileWriter (_outputDir .path, config.resourceProvider);
207203 await generator.generate (packageGraph, writer);
208204
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);
212208 }
213209 }
214210
@@ -229,9 +225,14 @@ class Dartdoc {
229225 if (config.showStats) {
230226 logInfo (markdownStats.buildReport ());
231227 }
232- return DartdocResults (config.topLevelPackageMeta, packageGraph, outputDir );
228+ return DartdocResults (config.topLevelPackageMeta, packageGraph, _outputDir );
233229 }
234230
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.
235236 Future <DartdocResults > generateDocs () async {
236237 try {
237238 logInfo ('Documenting ${config .topLevelPackageMeta }...' );
@@ -252,7 +253,6 @@ class Dartdoc {
252253 return dartdocResults;
253254 } finally {
254255 // Clear out any cached tool snapshots and temporary directories.
255- // ignore: unawaited_futures
256256 SnapshotCache .instance? .dispose ();
257257 // ignore: unawaited_futures
258258 ToolTempFileTracker .instance? .dispose ();
@@ -325,7 +325,7 @@ class Dartdoc {
325325 }
326326 if (visited.contains (fullPath)) continue ;
327327 var relativeFullPath = path.relative (fullPath, from: normalOrigin);
328- if (! writtenFiles .contains (relativeFullPath)) {
328+ if (! _writtenFiles .contains (relativeFullPath)) {
329329 // This isn't a file we wrote (this time); don't claim we did.
330330 _warn (
331331 packageGraph, PackageWarning .unknownFile, fullPath, normalOrigin);
@@ -471,7 +471,7 @@ class Dartdoc {
471471
472472 /// Don't call this method more than once, and only after you've
473473 /// generated all docs for the Package.
474- void validateLinks (PackageGraph packageGraph, String origin) {
474+ void _validateLinks (PackageGraph packageGraph, String origin) {
475475 assert (_hrefs == null );
476476 _hrefs = packageGraph.allHrefs;
477477
0 commit comments