-
Notifications
You must be signed in to change notification settings - Fork 124
Canonicalization overhaul part two #1390
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
Conversation
@@ -3,6 +3,7 @@ | |||
<component name="ProjectModuleManager"> | |||
<modules> | |||
<module fileurl="file://$PROJECT_DIR$/dartdoc.iml" filepath="$PROJECT_DIR$/dartdoc.iml" /> | |||
<module fileurl="file://$PROJECT_DIR$/../mustache4dart/mustache4dart.iml" filepath="$PROJECT_DIR$/../mustache4dart/mustache4dart.iml" /> |
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.
probably want to drop this line
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.
I would prefer to just delete the whole file so I can have my own intellij settings. Is that a bad idea?
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.
No, feel free to delete.
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.
Done.
CHANGELOG.md
Outdated
* Upgrades to new Package.warn system. | ||
* Fully integrated all scattered "warnings" and added new ones for the link checker. | ||
* Allow for setting which warnings are errors in the library. | ||
* Change location output to something IntelliJ can understand and link to |
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
Travis failures are because for some reason the link checker allocates a tremendous amount of memory. I'll try to figure out why that is. |
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.
Nice changes! I made one pass through.
You alluded to this in your PR comments, but some of the changes here - the warnings overhaul for example - could have been handled in separate, smaller PRs before this one. That would make for happier reviewers - it's hard to meaningfully review PRs of this size.
I note that the flutter bot is failing on this PR; do you know why?
Travis failures are because for some reason the link checker allocates a tremendous amount of memory. I'll try to figure out why that is.
Nevermind, looks like our comments crossed.
|
||
* Many cleanups to dartdoc stdout/stderr, error messages, and warnings: | ||
* Display fatal errors with 'fatal error' string to distinguish them from ordinary errors | ||
* Upgrades to new Package.warn system. |
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.
Food for thought for later - Dart now has good support for detecting when a console supports ansi. There are some very lightweight libraries for colorizing console output and showing indeterminate progress. We may want to use ansi colors when writing warnings and errors.
https://github.com/google/tuneup.dart/blob/master/lib/src/ansi.dart
https://github.com/google/tuneup.dart/blob/master/lib/src/logger.dart#L92
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.
Nice. I was wondering about that.
lib/dartdoc.dart
Outdated
@@ -167,21 +185,170 @@ class DartDoc { | |||
|
|||
for (var generator in generators) { | |||
await generator.generate(package, outputDir); | |||
generator.writtenFiles |
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.
Perhaps slightly clearer as writtenFiles.addAll(generator.writtenFiles.map(path.normalize))
?
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.
Done.
lib/dartdoc.dart
Outdated
String staticAssets = path.joinAll([normalOrigin, 'static-assets', '']); | ||
String indexJson = path.joinAll([normalOrigin, 'index.json']); | ||
bool foundIndex = false; | ||
await for (FileSystemEntity f |
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.
Perhaps a bit simpler to use listSync()?
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.
I think you could then remove the async
from _doOrphanCheck
.
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.
And - not necessarily for this PR - it would be interesting to add the lint that checks that you're only awaiting Futures. It should then fire when you make _doOrphanCheck
sync, on the await in verifyLinks.
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.
Sounds good. Went with listSync and removed async where appropriate.
lib/dartdoc.dart
Outdated
fullPath = path.normalize(fullPath); | ||
} | ||
|
||
File file = new File("$fullPath"); |
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.
new File(fullPath)
?
lib/dartdoc.dart
Outdated
if (!file.existsSync()) { | ||
_warn(package, PackageWarning.brokenLink, pathToCheck, | ||
path.normalize(origin), | ||
source: source); |
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.
This may auto-format slightly nicer if you add a trailing comma after source
.
lib/src/model.dart
Outdated
@@ -828,7 +879,7 @@ class Constructor extends ModelElement | |||
String constructorName = element.name; | |||
Class c = new ModelElement.from(element.enclosingElement, library) as Class; | |||
if (constructorName.isEmpty) { | |||
return c.name; | |||
return '${c.name}'; |
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.
Is name
a String? This isn't necessary, unless you don't want to return null.
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.
Yeah, no need for this here, there were intermediate changes I had that renamed all constructors to "ClassName.ConstructorName", even defaults. Fixed.
lib/src/model.dart
Outdated
} | ||
|
||
String get arrow { | ||
if (readOnly) return r'→'; |
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.
You could have the actual char in a line comment to help readers (// →
).
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.
Done.
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.
Done.
class Package implements Nameable, Documentable { | ||
/// Provides description text and command line flags for warnings. | ||
/// TODO(jcollins-g): Actually use this for command line flags. | ||
Map<PackageWarning, List<String>> packageWarningText = { |
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.
Very cool! Nice to have a centralized structure for the errors we emit.
lib/src/model.dart
Outdated
PackageWarningOptions() { | ||
_asWarnings.addAll(PackageWarning.values); | ||
ignore(PackageWarning.typeAsHtml); | ||
//error(PackageWarning.brokenLink); |
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.
delete?
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.
Done.
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.
done.
lib/src/model.dart
Outdated
'dartdoc detected an unknown file in the doc tree: ${message}'; | ||
break; | ||
case PackageWarning.typeAsHtml: | ||
warningMessage = 'generic type handled as HTML: """${message}"""'; |
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.
Why so many quotes? A single "
should work here too.
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.
I found it visually indistinct when the sample message often contained quotes and so on for this warning.
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.
Added clarifying comment, but it turned out that the symbols typically involved in the message string made it visually indistinct to use single quotes.
Yes. I actually tried to avoid fixing the warnings while fixing the broken links, but incrementally I found it impossible to correct the broken links without doing so, so the two wound up happening together. Same with the link checker. I expect there to be a finite, small number of these giant PRs. I think the code is improved enough now that future PRs will not be wide ranging; a goal here is to make it less structurally necessary to touch quite so much just to fix something like #1391. |
@@ -3,6 +3,7 @@ | |||
<component name="ProjectModuleManager"> | |||
<modules> | |||
<module fileurl="file://$PROJECT_DIR$/dartdoc.iml" filepath="$PROJECT_DIR$/dartdoc.iml" /> | |||
<module fileurl="file://$PROJECT_DIR$/../mustache4dart/mustache4dart.iml" filepath="$PROJECT_DIR$/../mustache4dart/mustache4dart.iml" /> |
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.
Done.
|
||
* Many cleanups to dartdoc stdout/stderr, error messages, and warnings: | ||
* Display fatal errors with 'fatal error' string to distinguish them from ordinary errors | ||
* Upgrades to new Package.warn system. |
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.
Nice. I was wondering about that.
lib/dartdoc.dart
Outdated
@@ -167,21 +185,170 @@ class DartDoc { | |||
|
|||
for (var generator in generators) { | |||
await generator.generate(package, outputDir); | |||
generator.writtenFiles |
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.
Done.
lib/dartdoc.dart
Outdated
String staticAssets = path.joinAll([normalOrigin, 'static-assets', '']); | ||
String indexJson = path.joinAll([normalOrigin, 'index.json']); | ||
bool foundIndex = false; | ||
await for (FileSystemEntity f |
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.
Sounds good. Went with listSync and removed async where appropriate.
lib/dartdoc.dart
Outdated
_hrefs = package.allHrefs; | ||
|
||
Set<String> visited = new Set(); | ||
String start = 'index.html'; |
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.
done
lib/src/model.dart
Outdated
PackageWarningOptions() { | ||
_asWarnings.addAll(PackageWarning.values); | ||
ignore(PackageWarning.typeAsHtml); | ||
//error(PackageWarning.brokenLink); |
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.
Done.
lib/src/model.dart
Outdated
'dartdoc detected an unknown file in the doc tree: ${message}'; | ||
break; | ||
case PackageWarning.typeAsHtml: | ||
warningMessage = 'generic type handled as HTML: """${message}"""'; |
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.
I found it visually indistinct when the sample message often contained quotes and so on for this warning.
lib/src/model.dart
Outdated
} | ||
|
||
String get arrow { | ||
if (readOnly) return r'→'; |
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.
Done.
lib/src/model.dart
Outdated
PackageWarningOptions() { | ||
_asWarnings.addAll(PackageWarning.values); | ||
ignore(PackageWarning.typeAsHtml); | ||
//error(PackageWarning.brokenLink); |
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.
done.
lib/src/model.dart
Outdated
'dartdoc detected an unknown file in the doc tree: ${message}'; | ||
break; | ||
case PackageWarning.typeAsHtml: | ||
warningMessage = 'generic type handled as HTML: """${message}"""'; |
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.
Added clarifying comment, but it turned out that the symbols typically involved in the message string made it visually indistinct to use single quotes.
CHANGELOG.md
Outdated
* Change --show-warnings to show all warnings, even those that might not be useful yet. | ||
* Display a count of all warnings/errors after document generation. | ||
* Make the progress counter tick slower. | ||
* Added a built-in link checker and orphaned file generator, and tied it into Package.warn so |
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.
==> orphaned file checker
?
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.
done
lgtm for my part! Excited to get this into play for the flutter docs |
lib/src/markdown_processor.dart
Outdated
// TODO(jcollins-g): Rewrite this to handle constructors in a less hacky way | ||
// TODO(jcollins-g): This function breaks down naturally into many helpers, extract them | ||
// TODO(jcollins-g): Subcomponents of this function shouldn't be adding nulls to results, strip the | ||
// removes out that are gratuitous and |
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.
missing end of comment
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.
done.
lib/src/markdown_processor.dart
Outdated
// and will add to [results] | ||
void _getResultsForClass(Class tryClass, String codeRefChomped, | ||
Set<ModelElement> results, String codeRef, Package package) { | ||
if ((tryClass.modelType.typeArguments.map((e) => e.name)) |
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.
comment, indicate this is for type arguments
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.
done
CHANGELOG.md
Outdated
* Change --show-warnings to show all warnings, even those that might not be useful yet. | ||
* Display a count of all warnings/errors after document generation. | ||
* Make the progress counter tick slower. | ||
* Added a built-in link checker and orphaned file generator, and tied it into Package.warn so |
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.
done
Welcome to the second part of the canonicalization overhaul begun in #1368. It's somewhat smaller and less fundamental.
The key elements are the rewrite of how comment references are handled (changes to _findRefElementInLibrary and its callers particularly) and the new hints to ModelElement.from and findCanonicalModelElementFor -- if you understand those, most of the remaining structural changes are understandable.
The link checker and warning enhancements are, in retrospect, somewhat orthogonal to the change, but were very much necessary to be able to corral all the consequences from canonicalization and insure they remain fixed.
More unit tests are on deck for some of the features and capabilities the code has now, but since the many new asserts and the new, better warnings make problems much more visible, regressions will be detectable in other ways. Given that and upcoming flutter deadlines, I wanted to get this out for review ASAP.