Skip to content

Commit 9d878ca

Browse files
authored
Remove snippets snapshotting hack from dartdoc generation. (flutter#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.
1 parent d573c5d commit 9d878ca

File tree

2 files changed

+2
-54
lines changed

2 files changed

+2
-54
lines changed

dartdoc_options.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ dartdoc:
44
# The dev/tools/dartdoc.dart script does this automatically.
55
tools:
66
snippet:
7-
command: ["bin/cache/dart-sdk/bin/dart", "../../bin/cache/snippets.snapshot", "--type=application"]
7+
command: ["dev/snippets/lib/main.dart", "--type=application"]
88
description: "Creates application sample code documentation output from embedded documentation samples."
99
sample:
10-
command: ["bin/cache/dart-sdk/bin/dart", "../../bin/cache/snippets.snapshot", "--type=sample"]
10+
command: ["dev/snippets/lib/main.dart", "--type=sample"]
1111
description: "Creates sample code documentation output from embedded documentation samples."

dev/tools/dartdoc.dart

-52
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ Future<void> main(List<String> arguments) async {
101101
createFooter('$kDocsRoot/lib/footer.html');
102102
copyAssets();
103103
cleanOutSnippets();
104-
await precompileSnippetsTool(pubExecutable, pubEnvironment);
105104

106105
final List<String> dartdocBaseArgs = <String>['global', 'run'];
107106
if (args['checked']) {
@@ -303,57 +302,6 @@ void cleanOutSnippets() {
303302
}
304303
}
305304

306-
Future<File> precompileSnippetsTool(
307-
String pubExecutable,
308-
Map<String, String> pubEnvironment,
309-
) async {
310-
final File snapshotPath = File(path.join('bin', 'cache', 'snippets.snapshot'));
311-
print('Precompiling snippets tool into ${snapshotPath.absolute.path}');
312-
if (snapshotPath.existsSync()) {
313-
snapshotPath.deleteSync();
314-
}
315-
316-
final ProcessWrapper process = ProcessWrapper(await Process.start(
317-
pubExecutable,
318-
<String>['get'],
319-
workingDirectory: kSnippetsRoot,
320-
environment: pubEnvironment,
321-
));
322-
printStream(process.stdout, prefix: 'pub:stdout: ');
323-
printStream(process.stderr, prefix: 'pub:stderr: ');
324-
final int code = await process.done;
325-
if (code != 0)
326-
exit(code);
327-
328-
// In order to be able to optimize properly, we need to provide a training set
329-
// of arguments, and an input file to process.
330-
final Directory tempDir = Directory.systemTemp.createTempSync('dartdoc_snippet_');
331-
final File trainingFile = File(path.join(tempDir.path, 'snippet_training'));
332-
trainingFile.writeAsStringSync('```dart\nvoid foo(){}\n```');
333-
try {
334-
final ProcessResult result = Process.runSync(Platform.resolvedExecutable, <String>[
335-
'--snapshot=${snapshotPath.absolute.path}',
336-
'--snapshot_kind=app-jit',
337-
path.join(
338-
'lib',
339-
'main.dart',
340-
),
341-
'--type=sample',
342-
'--input=${trainingFile.absolute.path}',
343-
'--output=${path.join(tempDir.absolute.path, 'training_output.txt')}',
344-
], workingDirectory: path.absolute(kSnippetsRoot));
345-
if (result.exitCode != 0) {
346-
stdout.writeln(result.stdout);
347-
stderr.writeln(result.stderr);
348-
throw Exception('Could not generate snippets snapshot: process exited with code ${result.exitCode}');
349-
}
350-
} on ProcessException catch (error) {
351-
throw Exception('Could not generate snippets snapshot:\n$error');
352-
}
353-
tempDir.deleteSync(recursive: true);
354-
return snapshotPath;
355-
}
356-
357305
void sanityCheckDocs() {
358306
final List<String> canaries = <String>[
359307
'$kPublishRoot/assets/overrides.css',

0 commit comments

Comments
 (0)