@@ -60,17 +60,19 @@ Future<List<Generator>> initGenerators(String url, List<String> headerFilePaths,
60
60
/// directory.
61
61
class DartDoc {
62
62
final Directory rootDir;
63
- final List <String > excludes;
64
63
final Directory sdkDir;
65
64
final List <Generator > generators;
66
65
final Directory outputDir;
67
66
final PackageMeta packageMeta;
68
67
final List <String > includes;
68
+ final List <String > includeExternals;
69
+ final List <String > excludes;
69
70
70
71
Stopwatch _stopwatch;
71
72
72
73
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 []});
74
76
75
77
/// Generate DartDoc documentation.
76
78
///
@@ -85,14 +87,25 @@ class DartDoc {
85
87
? const []
86
88
: findFilesToDocumentInPackage (rootDir.path).toList ();
87
89
88
- List <LibraryElement > libraries = _parseLibraries (files, includes );
90
+ List <LibraryElement > libraries = _parseLibraries (files, includeExternals );
89
91
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
+ });
94
107
});
95
- });
108
+ }
96
109
97
110
if (includes.isNotEmpty || excludes.isNotEmpty) {
98
111
print ('generating docs for libraries ${libraries .join (', ' )}\n ' );
@@ -121,7 +134,7 @@ class DartDoc {
121
134
}
122
135
123
136
List <LibraryElement > _parseLibraries (
124
- List <String > files, List <String > includes ) {
137
+ List <String > files, List <String > includeExternals ) {
125
138
Set <LibraryElement > libraries = new Set ();
126
139
DartSdk sdk = new DirectoryBasedDartSdk (new JavaFile (sdkDir.path));
127
140
List <UriResolver > resolvers = [];
@@ -206,10 +219,10 @@ class DartDoc {
206
219
result = context.performAnalysisTask ();
207
220
}
208
221
209
- // Use the includes .
222
+ // Use the includeExternals .
210
223
for (Source source in context.librarySources) {
211
224
LibraryElement library = context.computeLibraryElement (source);
212
- if (includes .contains (Library .getLibraryName (library))) {
225
+ if (includeExternals .contains (Library .getLibraryName (library))) {
213
226
libraries.add (library);
214
227
}
215
228
}
0 commit comments