Remove snippets snapshotting hack from dartdoc generation. (#24812)

Now that dartdoc automatically generates snapshots for external dart tools, I can remove my path hack from the dartdoc_options.yaml file.

This will allow other packages to again build dartdocs (e.g. plugins) that link to Flutter's dartdocs, and allow me to re-enable dartdoc's cross-linking test that was disabled because of this hack.
This commit is contained in:
Greg Spencer 2018-11-27 22:31:49 -08:00 committed by GitHub
parent d573c5d09a
commit 9d878ca493
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 54 deletions

View file

@ -4,8 +4,8 @@ dartdoc:
# The dev/tools/dartdoc.dart script does this automatically.
tools:
snippet:
command: ["bin/cache/dart-sdk/bin/dart", "../../bin/cache/snippets.snapshot", "--type=application"]
command: ["dev/snippets/lib/main.dart", "--type=application"]
description: "Creates application sample code documentation output from embedded documentation samples."
sample:
command: ["bin/cache/dart-sdk/bin/dart", "../../bin/cache/snippets.snapshot", "--type=sample"]
command: ["dev/snippets/lib/main.dart", "--type=sample"]
description: "Creates sample code documentation output from embedded documentation samples."

View file

@ -101,7 +101,6 @@ Future<void> main(List<String> arguments) async {
createFooter('$kDocsRoot/lib/footer.html');
copyAssets();
cleanOutSnippets();
await precompileSnippetsTool(pubExecutable, pubEnvironment);
final List<String> dartdocBaseArgs = <String>['global', 'run'];
if (args['checked']) {
@ -303,57 +302,6 @@ void cleanOutSnippets() {
}
}
Future<File> precompileSnippetsTool(
String pubExecutable,
Map<String, String> pubEnvironment,
) async {
final File snapshotPath = File(path.join('bin', 'cache', 'snippets.snapshot'));
print('Precompiling snippets tool into ${snapshotPath.absolute.path}');
if (snapshotPath.existsSync()) {
snapshotPath.deleteSync();
}
final ProcessWrapper process = ProcessWrapper(await Process.start(
pubExecutable,
<String>['get'],
workingDirectory: kSnippetsRoot,
environment: pubEnvironment,
));
printStream(process.stdout, prefix: 'pub:stdout: ');
printStream(process.stderr, prefix: 'pub:stderr: ');
final int code = await process.done;
if (code != 0)
exit(code);
// In order to be able to optimize properly, we need to provide a training set
// of arguments, and an input file to process.
final Directory tempDir = Directory.systemTemp.createTempSync('dartdoc_snippet_');
final File trainingFile = File(path.join(tempDir.path, 'snippet_training'));
trainingFile.writeAsStringSync('```dart\nvoid foo(){}\n```');
try {
final ProcessResult result = Process.runSync(Platform.resolvedExecutable, <String>[
'--snapshot=${snapshotPath.absolute.path}',
'--snapshot_kind=app-jit',
path.join(
'lib',
'main.dart',
),
'--type=sample',
'--input=${trainingFile.absolute.path}',
'--output=${path.join(tempDir.absolute.path, 'training_output.txt')}',
], workingDirectory: path.absolute(kSnippetsRoot));
if (result.exitCode != 0) {
stdout.writeln(result.stdout);
stderr.writeln(result.stderr);
throw Exception('Could not generate snippets snapshot: process exited with code ${result.exitCode}');
}
} on ProcessException catch (error) {
throw Exception('Could not generate snippets snapshot:\n$error');
}
tempDir.deleteSync(recursive: true);
return snapshotPath;
}
void sanityCheckDocs() {
final List<String> canaries = <String>[
'$kPublishRoot/assets/overrides.css',