Skip to content

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

Merged
merged 1 commit into from
Sep 1, 2017

Conversation

isoos
Copy link
Collaborator

@isoos isoos commented Aug 29, 2017

No description provided.

} finally {
await tempDir.delete(recursive: true);
}
return false; // no race detection
Copy link
Member

Choose a reason for hiding this comment

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

explain the comment?

Copy link
Collaborator Author

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.

Copy link
Member

@mkustermann mkustermann left a comment

Choose a reason for hiding this comment

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

looks fine


try {
final pkgLocation =
await pubEnv.getLocation(task.package, version: task.version);
Copy link
Member

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)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Member

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.

final pkgPath = pkgLocation.location;
await _runDartdoc(task, pkgPath);
await _writeMetadata(task, pkgPath);
// TODO: upload doc/api to the appropriate bucket
Copy link
Member

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.

await pubEnv.getLocation(task.package, version: task.version);
final pkgPath = pkgLocation.location;
await _runDartdoc(task, pkgPath);
await _writeMetadata(task, pkgPath);
Copy link
Member

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.

Copy link
Collaborator Author

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).

Copy link
Member

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.

return false; // no race detected
final tempDir =
await Directory.systemTemp.createTemp('pub-dartlang-dartdoc');
final pubCacheDir = await tempDir.resolveSymbolicLinks();
Copy link
Member

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?

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 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.

Copy link
Member

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)

return false; // no race detected
final tempDir =
await Directory.systemTemp.createTemp('pub-dartlang-dartdoc');
final pubCacheDir = await tempDir.resolveSymbolicLinks();
Copy link
Member

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)


try {
final pkgLocation =
await pubEnv.getLocation(task.package, version: task.version);
Copy link
Member

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.

await pubEnv.getLocation(task.package, version: task.version);
final pkgPath = pkgLocation.location;
await _runDartdoc(task, pkgPath);
await _writeMetadata(task, pkgPath);
Copy link
Member

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.

'exitCode: ${pr.exitCode}\n'
'stdout: ${pr.stdout}\n'
'stderr: ${pr.stderr}\n');
}
Copy link
Member

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!

'exitCode: ${pr.exitCode}\n'
'stdout: ${pr.stdout}\n'
'stderr: ${pr.stderr}\n');
return null;
Copy link
Member

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.

@isoos
Copy link
Collaborator Author

isoos commented Aug 31, 2017

PTAL, I think I've addressed most of the concerns (dependencies are fetched, separate directory for the dartdoc content, throwing on dartdoc failures).

Postponed:

  • direct download (some pana support is required for analyzer too, want to do that the same time)
  • upload (btw. I'm not sure that the bucket file path needs to have the dartdoc version, a direct mirror of the dartdocs.org dir structure could be more beneficial)

@mkustermann
Copy link
Member

upload (btw. I'm not sure that the bucket file path needs to have the dartdoc version, a direct mirror of the
dartdocs.org dir structure could be more beneficial)

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

  • it could change the entire look & feel: So we would have a time period where some of the generated docs have the old style and some new, it's not the best user experience
  • we avoid needing to delete old files & create new files (and have short time where there are no docs)
  • the new dartdoc version might have a bug and fail on some percentage of packages, then we can easily go back to the old available docs

@mkustermann
Copy link
Member

direct download (some pana support is required for analyzer too, want to do that the same time)

I've filed dart-lang/pana#78, so we don't forget about it.

@mkustermann mkustermann merged commit b6f886a into dart-lang:master Sep 1, 2017
@isoos isoos deleted the dartdoc_runner branch September 1, 2017 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants