-
Notifications
You must be signed in to change notification settings - Fork 160
Run dartdoc for the given task. #322
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
} finally { | ||
await tempDir.delete(recursive: true); | ||
} | ||
return false; // no race detection |
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.
explain the 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.
The method should return true if there were a race of processing detected (e.g. in analyzer
), false otherwise. Not sure how we want to comment on it in such case.
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.
looks fine
app/lib/dartdoc/dartdoc_runner.dart
Outdated
|
||
try { | ||
final pkgLocation = | ||
await pubEnv.getLocation(task.package, version: task.version); |
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.
Does this end up downloading from the proper https://pub.dartlang.org/packages/<name>/versions/<version>.tar.gz
url?
(so we don't have the memcache issue)
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.
Unfortunately pub
does a sanity check before doing that:
https://github.com/dart-lang/pub/blob/master/lib/src/command/cache_add.dart#L57
https://github.com/dart-lang/pub/blob/master/lib/src/source/hosted.dart#L130
Btw. this affects pana
the very same way. /cc @kevmoo
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.
We don't have to use pub to download the package! We only need pub to download a package's dependencies via pub get
.
app/lib/dartdoc/dartdoc_runner.dart
Outdated
final pkgPath = pkgLocation.location; | ||
await _runDartdoc(task, pkgPath); | ||
await _writeMetadata(task, pkgPath); | ||
// TODO: upload doc/api to the appropriate bucket |
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.
Ideally the bucket organization would use a scheme like gs://<bucket-name>/<dartdoc-version>/<package>/<version>/{index.html,...}
here.
app/lib/dartdoc/dartdoc_runner.dart
Outdated
await pubEnv.getLocation(task.package, version: task.version); | ||
final pkgPath = pkgLocation.location; | ||
await _runDartdoc(task, pkgPath); | ||
await _writeMetadata(task, pkgPath); |
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.
If _runDartdoc
failed, this call will fail, since the doc
folder is not there.
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.
TaskScheduler
has a proper error handling, so we don't really need to worry about handling each of these errors separately. In fact, not having a doc
directory helps us to get an exception without explicitly checking for it (and then throwing ourselves).
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.
It's generally not advisable running commands / steps if they have assumptions about previous commands without ensuring that these previous commands completed successfully.
That's precisely why shell scripts often use set -e
to abort after the first failed command.
Just assume that the package author already had a doc
folder, then we might accidentally upload that, incorrect doc folder, to cloud storage and claim everything is fine, even though we didn't generate proper docs.
I'll add a comment further down about it.
app/lib/dartdoc/dartdoc_runner.dart
Outdated
return false; // no race detected | ||
final tempDir = | ||
await Directory.systemTemp.createTemp('pub-dartlang-dartdoc'); | ||
final pubCacheDir = await tempDir.resolveSymbolicLinks(); |
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.
Ideally we would reuse a pub cache, instead of just re-downloading all transitive dependencies for every single package we generate documentation for.
What is this PubEnvironment
stuff doing?
Is pubCacheDir
the real PUB_CACHE
or is it a directory where this particular (package, version) tarball will be downloaded 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.
We have had an issue with the analyzer
service early on, when I've left out the temp dir creation and cleanup: the packages fill up the disk quickly.
In this case pubCacheDir
is a clean environment, initialized and clear for every dartdoc
run. However, pub cache
does not download the transitive dependencies, only the specified package, so it is fine to use it a a clean env.
PubEnvironment
encapsulates the various executables, commands and environment variables for pana
. It felt better to reuse it here, than to reinvent everything.
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.
... does not download the transitive dependencies ...
How does it then generate the correct docs? I mean if one package has a class inheriting from another package's class, how does dartdoc know about inherited members. It needs to know the other package's class for it.
Therefore I would naively conclude that dartdoc needs, in order to generate documentation for package A, the source for all packages A depends on (transitively).
PubEnvironment encapsulates the various executables, commands and environment variables for pana. It felt better
to reuse it here, than to reinvent everything.
It depends on whether it does the right thing. e.g. using the correct URL for downloading tarballs (to avoid hitting the memcache issue)
app/lib/dartdoc/dartdoc_runner.dart
Outdated
return false; // no race detected | ||
final tempDir = | ||
await Directory.systemTemp.createTemp('pub-dartlang-dartdoc'); | ||
final pubCacheDir = await tempDir.resolveSymbolicLinks(); |
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.
... does not download the transitive dependencies ...
How does it then generate the correct docs? I mean if one package has a class inheriting from another package's class, how does dartdoc know about inherited members. It needs to know the other package's class for it.
Therefore I would naively conclude that dartdoc needs, in order to generate documentation for package A, the source for all packages A depends on (transitively).
PubEnvironment encapsulates the various executables, commands and environment variables for pana. It felt better
to reuse it here, than to reinvent everything.
It depends on whether it does the right thing. e.g. using the correct URL for downloading tarballs (to avoid hitting the memcache issue)
app/lib/dartdoc/dartdoc_runner.dart
Outdated
|
||
try { | ||
final pkgLocation = | ||
await pubEnv.getLocation(task.package, version: task.version); |
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.
We don't have to use pub to download the package! We only need pub to download a package's dependencies via pub get
.
app/lib/dartdoc/dartdoc_runner.dart
Outdated
await pubEnv.getLocation(task.package, version: task.version); | ||
final pkgPath = pkgLocation.location; | ||
await _runDartdoc(task, pkgPath); | ||
await _writeMetadata(task, pkgPath); |
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.
It's generally not advisable running commands / steps if they have assumptions about previous commands without ensuring that these previous commands completed successfully.
That's precisely why shell scripts often use set -e
to abort after the first failed command.
Just assume that the package author already had a doc
folder, then we might accidentally upload that, incorrect doc folder, to cloud storage and claim everything is fine, even though we didn't generate proper docs.
I'll add a comment further down about it.
app/lib/dartdoc/dartdoc_runner.dart
Outdated
'exitCode: ${pr.exitCode}\n' | ||
'stdout: ${pr.stdout}\n' | ||
'stderr: ${pr.stderr}\n'); | ||
} |
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.
Please throw an exception or give a boolean to the caller to indicate whether it was successful. If we fail to generate dartdocs, we should not try running gcs uploading code!
app/lib/dartdoc/dartdoc_runner.dart
Outdated
'exitCode: ${pr.exitCode}\n' | ||
'stdout: ${pr.stdout}\n' | ||
'stderr: ${pr.stderr}\n'); | ||
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.
Ditto, if we can't determine the version, we should not continue.
PTAL, I think I've addressed most of the concerns (dependencies are fetched, separate directory for the dartdoc content, throwing on dartdoc failures). Postponed:
|
The normal dartdocs URL space could just redirect to the active dartdoc-version GCS URLs. There are multiple advantages of doing this: If we roll a new dartdoc version
|
I've filed dart-lang/pana#78, so we don't forget about it. |
No description provided.