@@ -60,17 +60,19 @@ Future<List<Generator>> initGenerators(String url, List<String> headerFilePaths,
6060/// directory.
6161class DartDoc {
6262 final Directory rootDir;
63- final List <String > excludes;
6463 final Directory sdkDir;
6564 final List <Generator > generators;
6665 final Directory outputDir;
6766 final PackageMeta packageMeta;
6867 final List <String > includes;
68+ final List <String > includeExternals;
69+ final List <String > excludes;
6970
7071 Stopwatch _stopwatch;
7172
7273 DartDoc (this .rootDir, this .excludes, this .sdkDir, this .generators,
73- this .outputDir, this .packageMeta, this .includes);
74+ this .outputDir, this .packageMeta, this .includes,
75+ {this .includeExternals: const []});
7476
7577 /// Generate DartDoc documentation.
7678 ///
@@ -85,14 +87,25 @@ class DartDoc {
8587 ? const []
8688 : findFilesToDocumentInPackage (rootDir.path).toList ();
8789
88- List <LibraryElement > libraries = _parseLibraries (files, includes );
90+ List <LibraryElement > libraries = _parseLibraries (files, includeExternals );
8991
90- // remove excluded libraries
91- excludes.forEach ((pattern) {
92- libraries.removeWhere ((lib) {
93- return lib.name.startsWith (pattern) || lib.name == pattern;
92+ if (includes != null && includes.isNotEmpty) {
93+ Iterable knownLibraryNames = libraries.map ((l) => l.name);
94+ Set notFound =
95+ new Set .from (includes).difference (new Set .from (knownLibraryNames));
96+ if (notFound.isNotEmpty) {
97+ throw 'Did not find: [${notFound .join (', ' )}] in '
98+ 'known libraries: [${knownLibraryNames .join (', ' )}]' ;
99+ }
100+ libraries.removeWhere ((lib) => ! includes.contains (lib.name));
101+ } else {
102+ // remove excluded libraries
103+ excludes.forEach ((pattern) {
104+ libraries.removeWhere ((lib) {
105+ return lib.name.startsWith (pattern) || lib.name == pattern;
106+ });
94107 });
95- });
108+ }
96109
97110 if (includes.isNotEmpty || excludes.isNotEmpty) {
98111 print ('generating docs for libraries ${libraries .join (', ' )}\n ' );
@@ -121,7 +134,7 @@ class DartDoc {
121134 }
122135
123136 List <LibraryElement > _parseLibraries (
124- List <String > files, List <String > includes ) {
137+ List <String > files, List <String > includeExternals ) {
125138 Set <LibraryElement > libraries = new Set ();
126139 DartSdk sdk = new DirectoryBasedDartSdk (new JavaFile (sdkDir.path));
127140 List <UriResolver > resolvers = [];
@@ -206,10 +219,10 @@ class DartDoc {
206219 result = context.performAnalysisTask ();
207220 }
208221
209- // Use the includes .
222+ // Use the includeExternals .
210223 for (Source source in context.librarySources) {
211224 LibraryElement library = context.computeLibraryElement (source);
212- if (includes .contains (Library .getLibraryName (library))) {
225+ if (includeExternals .contains (Library .getLibraryName (library))) {
213226 libraries.add (library);
214227 }
215228 }
0 commit comments