Skip to content

Commit f5da1f2

Browse files
authored
Serve test package docs through grinder (#1578)
* Serve test package docs through grinder * pubspec update * Fix label for test package server
1 parent 617d928 commit f5da1f2

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

tool/grind.dart

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ Directory get dartdocDocsDir =>
2323
tempdirsCache.memoized1(createTempSync, 'dartdoc');
2424
Directory get sdkDocsDir => tempdirsCache.memoized1(createTempSync, 'sdkdocs');
2525
Directory get flutterDir => tempdirsCache.memoized1(createTempSync, 'flutter');
26+
Directory get testPackage =>
27+
new Directory(path.joinAll(['testing', 'test_package']));
28+
Directory get testPackageDocsDir =>
29+
tempdirsCache.memoized1(createTempSync, 'test_package');
2630

2731
/// Version of dartdoc we should use when making comparisons.
2832
String get dartdocOriginalBranch {
@@ -136,7 +140,7 @@ Future<List<Map>> _buildSdkDocs(String sdkDocsPath, Future<String> futureCwd,
136140
Platform.resolvedExecutable,
137141
[
138142
'--checked',
139-
'bin/dartdoc.dart',
143+
path.join('bin', 'dartdoc.dart'),
140144
'--output',
141145
'${sdkDocsDir.path}',
142146
'--sdk-docs',
@@ -146,6 +150,56 @@ Future<List<Map>> _buildSdkDocs(String sdkDocsPath, Future<String> futureCwd,
146150
workingDirectory: cwd);
147151
}
148152

153+
Future<List<Map>> _buildTestPackageDocs(
154+
String outputDir, Future<String> futureCwd,
155+
[String label]) async {
156+
if (label == null) label = '';
157+
if (label != '') label = '-$label';
158+
var launcher = new SubprocessLauncher('build-test-package-docs$label');
159+
await launcher.runStreamed(sdkBin('pub'), ['get'],
160+
workingDirectory: testPackage.absolute.path);
161+
String cwd = await futureCwd;
162+
await launcher.runStreamed(sdkBin('pub'), ['get'], workingDirectory: cwd);
163+
return await launcher.runStreamed(
164+
Platform.resolvedExecutable,
165+
[
166+
'--checked',
167+
path.join(cwd, 'bin', 'dartdoc.dart'),
168+
'--output',
169+
outputDir,
170+
'--auto-include-dependencies',
171+
'--example-path-prefix',
172+
'examples',
173+
'--include-source',
174+
'--json',
175+
'--pretty-index-json',
176+
'--exclude',
177+
'dart.async,dart.collection,dart.convert,dart.core,dart.math,dart.typed_data,meta',
178+
],
179+
workingDirectory: testPackage.absolute.path);
180+
}
181+
182+
@Task('Build generated test package docs (with inherited docs and source code)')
183+
Future buildTestPackageDocs() async {
184+
await _buildTestPackageDocs(testPackageDocsDir.absolute.path,
185+
new Future.value(Directory.current.path));
186+
}
187+
188+
@Task('Serve test package docs locally with dhttpd on port 8002')
189+
@Depends(buildTestPackageDocs)
190+
Future serveTestPackageDocs() async {
191+
log('launching dhttpd on port 8002 for SDK');
192+
var launcher = new SubprocessLauncher('serve-test-package-docs');
193+
await launcher.runStreamed(sdkBin('pub'), [
194+
'run',
195+
'dhttpd',
196+
'--port',
197+
'8002',
198+
'--path',
199+
'${testPackageDocsDir.absolute.path}',
200+
]);
201+
}
202+
149203
@Task('Serve generated SDK docs locally with dhttpd on port 8000')
150204
@Depends(buildSdkDocs)
151205
Future serveSdkDocs() async {

0 commit comments

Comments
 (0)