Skip to content

Serve test package docs through grinder #1578

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 5 commits into from
Jan 4, 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
56 changes: 55 additions & 1 deletion tool/grind.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Directory get dartdocDocsDir =>
tempdirsCache.memoized1(createTempSync, 'dartdoc');
Directory get sdkDocsDir => tempdirsCache.memoized1(createTempSync, 'sdkdocs');
Directory get flutterDir => tempdirsCache.memoized1(createTempSync, 'flutter');
Directory get testPackage =>
new Directory(path.joinAll(['testing', 'test_package']));
Directory get testPackageDocsDir =>
tempdirsCache.memoized1(createTempSync, 'test_package');

/// Version of dartdoc we should use when making comparisons.
String get dartdocOriginalBranch {
Expand Down Expand Up @@ -136,7 +140,7 @@ Future<List<Map>> _buildSdkDocs(String sdkDocsPath, Future<String> futureCwd,
Platform.resolvedExecutable,
[
'--checked',
'bin/dartdoc.dart',
path.join('bin', 'dartdoc.dart'),
'--output',
'${sdkDocsDir.path}',
'--sdk-docs',
Expand All @@ -146,6 +150,56 @@ Future<List<Map>> _buildSdkDocs(String sdkDocsPath, Future<String> futureCwd,
workingDirectory: cwd);
}

Future<List<Map>> _buildTestPackageDocs(
String outputDir, Future<String> futureCwd,
[String label]) async {
if (label == null) label = '';
if (label != '') label = '-$label';
var launcher = new SubprocessLauncher('build-test-package-docs$label');
await launcher.runStreamed(sdkBin('pub'), ['get'],
Copy link
Member

Choose a reason for hiding this comment

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

I think there's a grinder shorthand for sdkBin('pub') (but don't recall what it is).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is indeed (a class named Pub). However grind's shorthands don't allow me to have the control I want for how they are executed. I've found it frustrating to debug a series of fork-execs that is partially hidden by "shorthands" that look like they aren't fork/execs. This way, I can see exactly what it is doing both in the output of grinder and in the source code.

workingDirectory: testPackage.absolute.path);
String cwd = await futureCwd;
await launcher.runStreamed(sdkBin('pub'), ['get'], workingDirectory: cwd);
return await launcher.runStreamed(
Platform.resolvedExecutable,
[
'--checked',
path.join(cwd, 'bin', 'dartdoc.dart'),
'--output',
outputDir,
'--auto-include-dependencies',
'--example-path-prefix',
'examples',
'--include-source',
'--json',
'--pretty-index-json',
'--exclude',
'dart.async,dart.collection,dart.convert,dart.core,dart.math,dart.typed_data,meta',
],
workingDirectory: testPackage.absolute.path);
}

@Task('Build generated test package docs (with inherited docs and source code)')
Future buildTestPackageDocs() async {
await _buildTestPackageDocs(testPackageDocsDir.absolute.path,
new Future.value(Directory.current.path));
}

@Task('Serve test package docs locally with dhttpd on port 8002')
@Depends(buildTestPackageDocs)
Future serveTestPackageDocs() async {
log('launching dhttpd on port 8002 for SDK');
var launcher = new SubprocessLauncher('serve-test-package-docs');
await launcher.runStreamed(sdkBin('pub'), [
'run',
'dhttpd',
'--port',
'8002',
'--path',
'${testPackageDocsDir.absolute.path}',
]);
}

@Task('Serve generated SDK docs locally with dhttpd on port 8000')
@Depends(buildSdkDocs)
Future serveSdkDocs() async {
Expand Down