-
Notifications
You must be signed in to change notification settings - Fork 127
Canonicalization overhaul #1368
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
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
47966ee
fix key for _implementors, stop overwriting files all the time
jcollins-g 3bc180e
Intermediate attempt to resolve duplicates and add some debugging.
jcollins-g 3016e8b
Implemented by and a few other things still broken, but closer.
jcollins-g a7a9ce6
Fixed Implemented By again with a refactor. Still need to condense c…
jcollins-g 6154a18
Some duplicate libraries or something going on here.
jcollins-g 687cf72
Things are working better now. Edge cases with fields and dart:_inte…
jcollins-g 5c03e6d
Field inheritance still broken for getters/setters. May have to fix …
jcollins-g 531a559
Fix up brokenness from merges
jcollins-g add09d1
fix key for _implementors, stop overwriting files all the time
jcollins-g 692b727
Intermediate attempt to resolve duplicates and add some debugging.
jcollins-g 9d4ebf9
Implemented by and a few other things still broken, but closer.
jcollins-g ab1da77
Fixed Implemented By again with a refactor. Still need to condense c…
jcollins-g ed7af68
Some duplicate libraries or something going on here.
jcollins-g c9dc37f
Things are working better now. Edge cases with fields and dart:_inte…
jcollins-g a8e7a18
Field inheritance still broken for getters/setters. May have to fix …
jcollins-g 8a80a18
Fix up brokenness from merges
jcollins-g 8edf848
Another incremental step; field inheritance canonicalization seems co…
jcollins-g aecb075
merge fixups
jcollins-g 34b0645
Fix enclosingCanonicalElement detection on deep inheritance trees, up…
jcollins-g 06f65ba
More bugs fixed with a new inheritance chain builder in Class.inherit…
jcollins-g da0b42a
Generating test package docs with no broken links and everything seem…
jcollins-g 55b6c8a
all the tests pass. but we still can't build SDK docs.
jcollins-g 8cb927e
Down to one broken sdk link
jcollins-g 88a5bc2
Reintroduce workaround for missing names in some instances
jcollins-g 167bffd
Fix linkage for class members
jcollins-g 1a5c085
Merge branch 'master' of github.com:dart-lang/dartdoc into 1334-imple…
jcollins-g 91bfdbe
Display warnings and re-fix Implemented By tracking
jcollins-g f31199a
Clean up generated test package docs. New semantics for --auto-inclu…
jcollins-g c3b1ee9
And add back all the missing hashCode, etc now that we're hiding the …
jcollins-g 189b069
dartfmt
jcollins-g 738dce3
Cleanup, add comments, only thing left is Inheritance
jcollins-g 0784d76
Fix a few more edge case behaviors
jcollins-g 46c9f04
Dynamics can have no name, that's legit
jcollins-g 5b53b58
Fix all analysis warnings (excepting deprecation)
jcollins-g f8898f3
Update version to 0.10.0, add CHANGELOG entries
jcollins-g 22da575
Typo in changelog, drop more of my persistent breakpoints
jcollins-g c79c0e7
Remove breakpoints
jcollins-g 6cdf4f6
Update changelog to reflect additional bugs this fixes
jcollins-g 4179bf9
First wave review comments
jcollins-g 849a3ec
dartfmt
jcollins-g 3d0ee6e
Drop null check that can't happen for library
jcollins-g edd9f07
Rename one of the library find methods for clarity, add some comments
jcollins-g File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ export 'src/package_meta.dart'; | |
|
||
const String name = 'dartdoc'; | ||
// Update when pubspec version changes. | ||
const String version = '0.9.13'; | ||
const String version = '0.10.0'; | ||
|
||
final String defaultOutDir = path.join('doc', 'api'); | ||
|
||
|
@@ -134,6 +134,7 @@ class DartDoc { | |
? const [] | ||
: findFilesToDocumentInPackage(rootDir.path).toList(); | ||
|
||
// TODO(jcollins-g): seems like most of this belongs in the Package constructor | ||
List<LibraryElement> libraries = _parseLibraries(files, includeExternals); | ||
|
||
if (includes != null && includes.isNotEmpty) { | ||
|
@@ -154,21 +155,27 @@ class DartDoc { | |
}); | ||
} | ||
|
||
if (includes.isNotEmpty || excludes.isNotEmpty) { | ||
print('generating docs for libraries ${libraries.join(', ')}\n'); | ||
} | ||
|
||
Package package = new Package(libraries, packageMeta); | ||
|
||
Package package; | ||
if (config != null && config.autoIncludeDependencies) { | ||
final newLibraryElements = | ||
_buildLibrariesWithAutoincludedDependencies(package); | ||
Library.clearLibraryMap(); | ||
package = new Package(newLibraryElements, packageMeta); | ||
package = Package.withAutoIncludedDependencies(libraries, packageMeta); | ||
libraries = package.libraries.map((l) => l.element).toList(); | ||
// remove excluded libraries again, in case they are picked up through | ||
// dependencies. | ||
excludes.forEach((pattern) { | ||
libraries.removeWhere((lib) { | ||
return lib.name.startsWith(pattern) || lib.name == pattern; | ||
}); | ||
}); | ||
} | ||
package = new Package(libraries, packageMeta); | ||
|
||
print( | ||
'generating docs for libraries ${package.libraries.map((Library l) => l.name).join(', ')}\n'); | ||
|
||
// Go through docs of every model element in package to prebuild the macros index | ||
package.allModelElements.forEach((m) => m.documentation); | ||
// TODO(jcollins-g): move index building into a cached-on-demand generation | ||
// like most other bits in [Package]. | ||
package.allCanonicalModelElements.forEach((m) => m.documentation); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eliminates repeats? Were we looking at documentation for elements that were not documented? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right. |
||
|
||
// Create the out directory. | ||
if (!outputDir.existsSync()) outputDir.createSync(recursive: true); | ||
|
@@ -179,11 +186,11 @@ class DartDoc { | |
|
||
double seconds = _stopwatch.elapsedMilliseconds / 1000.0; | ||
print( | ||
"\nDocumented ${libraries.length} librar${libraries.length == 1 ? 'y' : 'ies'} " | ||
"\nDocumented ${package.libraries.length} librar${package.libraries.length == 1 ? 'y' : 'ies'} " | ||
"in ${seconds.toStringAsFixed(1)} seconds."); | ||
|
||
if (libraries.isEmpty) { | ||
print( | ||
if (package.libraries.isEmpty) { | ||
stderr.write( | ||
"\ndartdoc could not find any libraries to document. Run `pub get` and try again."); | ||
} | ||
|
||
|
@@ -192,7 +199,7 @@ class DartDoc { | |
|
||
List<LibraryElement> _parseLibraries( | ||
List<String> files, List<String> includeExternals) { | ||
List<LibraryElement> libraries = []; | ||
Set<LibraryElement> libraries = new Set(); | ||
DartSdk sdk = new FolderBasedDartSdk(PhysicalResourceProvider.INSTANCE, | ||
PhysicalResourceProvider.INSTANCE.getFolder(sdkDir.path)); | ||
List<UriResolver> resolvers = []; | ||
|
@@ -257,7 +264,7 @@ class DartDoc { | |
sources.add(source); | ||
if (context.computeKindOf(source) == SourceKind.LIBRARY) { | ||
LibraryElement library = context.computeLibraryElement(source); | ||
libraries.add(library); | ||
if (!isPrivate(library)) libraries.add(library); | ||
} | ||
} | ||
|
||
|
@@ -281,11 +288,35 @@ class DartDoc { | |
LibraryElement library = context.computeLibraryElement(source); | ||
String libraryName = Library.getLibraryName(library); | ||
var fullPath = source.fullName; | ||
|
||
if (includeExternals.any((string) => fullPath.endsWith(string))) { | ||
if (libraries.map(Library.getLibraryName).contains(libraryName)) { | ||
continue; | ||
} | ||
libraries.add(library); | ||
} else if (config != null && | ||
config.autoIncludeDependencies && | ||
libraryName != '') { | ||
File searchFile = new File(fullPath); | ||
searchFile = | ||
new File(path.join(searchFile.parent.path, 'pubspec.yaml')); | ||
bool foundLibSrc = false; | ||
while (!foundLibSrc && searchFile.parent != null) { | ||
if (searchFile.existsSync()) break; | ||
List<String> pathParts = path.split(searchFile.parent.path); | ||
// This is a pretty intensely hardcoded convention, but there seems to | ||
// to be no other way to identify what might be a "top level" library | ||
// here. If lib/src is in the path between the file and the pubspec, | ||
// assume that this is supposed to be private. | ||
if (pathParts.length < 2) break; | ||
pathParts = pathParts.sublist(pathParts.length - 2, pathParts.length); | ||
foundLibSrc = | ||
path.join(pathParts[0], pathParts[1]) == path.join('lib', 'src'); | ||
searchFile = new File( | ||
path.join(searchFile.parent.parent.path, 'pubspec.yaml')); | ||
} | ||
if (foundLibSrc) continue; | ||
libraries.add(library); | ||
} | ||
} | ||
|
||
|
@@ -376,26 +407,3 @@ class _Error implements Comparable<_Error> { | |
@override | ||
String toString() => '[${severityName}] ${description}'; | ||
} | ||
|
||
Iterable<LibraryElement> _buildLibrariesWithAutoincludedDependencies( | ||
Package package) { | ||
final List<LibraryElement> newLibraryElements = [] | ||
..addAll(package.libraries.map((l) => l.element as LibraryElement)); | ||
|
||
package.allModelElements.forEach((modelElement) { | ||
modelElement.usedElements.forEach((used) { | ||
if (used != null && used.modelType != null) { | ||
final ModelElement modelTypeElement = used.modelType.element; | ||
final library = package.findLibraryFor(modelTypeElement.element); | ||
if (library == null && modelTypeElement.library != null) { | ||
if (!newLibraryElements.contains(modelTypeElement.library.element) && | ||
!modelTypeElement.library.name.startsWith("dart:")) { | ||
newLibraryElements.add(modelTypeElement.library.element); | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
return newLibraryElements; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to using stderr here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍