Skip to content

Run pkg/pub_dartdoc instead of global dartdoc #1384

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
Jun 20, 2018
Merged
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
32 changes: 26 additions & 6 deletions app/lib/dartdoc/dartdoc_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const _buildLogFilePath = 'log.txt';
const _dartdocTimeout = const Duration(minutes: 10);
final Duration _twoYears = const Duration(days: 2 * 365);

final _pkgPubDartdocDir =
Platform.script.resolve('../../pkg/pub_dartdoc').toFilePath();

class DartdocJobProcessor extends JobProcessor {
DartdocJobProcessor({Duration lockDuration})
: super(service: JobService.dartdoc, lockDuration: lockDuration);
Expand Down Expand Up @@ -179,16 +182,33 @@ class DartdocJobProcessor extends JobProcessor {
final canonicalUrl = pkgDocUrl(job.packageName,
version: canonicalVersion, includeHost: true, omitTrailingSlash: true);

Future<DartdocResult> runDartdoc(bool validateLinks) {
return toolEnv.dartdoc(
Future<DartdocResult> runDartdoc(bool validateLinks) async {
final args = [
'--input',
pkgPath,
'--output',
outputDir,
canonicalPrefix: canonicalUrl,
hostedUrl: siteRoot,
'--hosted-url',
siteRoot,
'--rel-canonical-prefix',
canonicalUrl,
'--link-to-remote',
];
if (!validateLinks) {
args.add('--no-validate-links');
}
final pr = await runProc(
'dart',
['bin/pub_dartdoc.dart']..addAll(args),
workingDirectory: _pkgPubDartdocDir,
timeout: _dartdocTimeout,
validateLinks: validateLinks,
linkToRemote: true,
);
final hasIndexHtml =
await new File(p.join(outputDir, 'index.html')).exists();
final hasIndexJson =
await new File(p.join(outputDir, 'index.json')).exists();
return new DartdocResult(
pr, pr.exitCode == 15, hasIndexHtml, hasIndexJson);
Copy link

Choose a reason for hiding this comment

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

What about other error codes besides 0 and 15?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

15 is SIGTERM, which we get when the timeout kills the process. In that case we retry it without link validation, which is a time-consuming thing to do on a large archive. On any non-zero we emit the the log.warning about it.

However we don't really care about the exit code besides these two, as long as the run produced index.html and index.json (and we may add pub-data.json to that list too).

}

DartdocResult r = await runDartdoc(true);
Expand Down