Skip to content

Change the --include-external flag to be more selective #1289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## unreleased
* change the `--include-external` flag to help disambiguate files to
include (#1236)

## 0.9.8
* support for generic methods.
* remove deps on cli_utils and which.
Expand Down
4 changes: 3 additions & 1 deletion bin/dartdoc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ ArgParser _createArgsParser() {
parser.addOption('include',
allowMultiple: true, help: 'library names to generate docs for');
parser.addOption('include-external',
allowMultiple: true, help: 'additional (external) libraries to include');
allowMultiple: true,
help: 'additional (external) dart files to include, use "dir/fileName", '
'as in lib/material.dart');
parser.addOption('hosted-url',
help:
'URL where the docs will be hosted (used to generate the sitemap).');
Expand Down
5 changes: 3 additions & 2 deletions lib/dartdoc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,13 @@ class DartDoc {
while (result.hasMoreWork) {
result = context.performAnalysisTask();
}

// Use the includeExternals.
for (Source source in context.librarySources) {
LibraryElement library = context.computeLibraryElement(source);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and libraryName are no longer used in the case where the library doesn't match. No clue if it's expensive or not. (Sorry to keep commenting on your completed CL, was just playing around in this code and noticed.) Thanks again for the fix! :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can always optimize! Though you will see a slowdown once flutter is back to generating all the docs, I saw ~20 sec difference on my machine between the two cases.

String libraryName = Library.getLibraryName(library);
if (includeExternals.contains(libraryName)) {
var fullPath = source.fullName;
if (includeExternals.any((string) => fullPath.endsWith(string))) {
if (libraries.map(Library.getLibraryName).contains(libraryName)) {
continue;
}
Expand Down