From 9d878ca49344232af7b7ac8631489a801757e1ce Mon Sep 17 00:00:00 2001 From: Greg Spencer Date: Tue, 27 Nov 2018 22:31:49 -0800 Subject: [PATCH] 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. --- dartdoc_options.yaml | 4 ++-- dev/tools/dartdoc.dart | 52 ------------------------------------------ 2 files changed, 2 insertions(+), 54 deletions(-) diff --git a/dartdoc_options.yaml b/dartdoc_options.yaml index 6fc305054b..4a68e2f842 100644 --- a/dartdoc_options.yaml +++ b/dartdoc_options.yaml @@ -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." diff --git a/dev/tools/dartdoc.dart b/dev/tools/dartdoc.dart index ed542a4bd1..43bc5dde48 100644 --- a/dev/tools/dartdoc.dart +++ b/dev/tools/dartdoc.dart @@ -101,7 +101,6 @@ Future main(List arguments) async { createFooter('$kDocsRoot/lib/footer.html'); copyAssets(); cleanOutSnippets(); - await precompileSnippetsTool(pubExecutable, pubEnvironment); final List dartdocBaseArgs = ['global', 'run']; if (args['checked']) { @@ -303,57 +302,6 @@ void cleanOutSnippets() { } } -Future precompileSnippetsTool( - String pubExecutable, - Map 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, - ['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, [ - '--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 canaries = [ '$kPublishRoot/assets/overrides.css',