From e41ffcb742c387c7880f6d0568399b31a1c49e78 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Thu, 29 Feb 2024 15:10:53 -0800 Subject: [PATCH] Reland "Use dartpad's main channel for master/main docs (#144329)" (#144431) Fix is in the second commit. The logic here went out of sync with the logic in the snippets generator from https://github.com/flutter/assets-for-api-docs, whose version was bumped as part of this change. --- dev/bots/docs.sh | 2 +- dev/snippets/config/skeletons/dartpad-sample.html | 2 +- dev/tools/create_api_docs.dart | 8 ++++---- dev/tools/test/create_api_docs_test.dart | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dev/bots/docs.sh b/dev/bots/docs.sh index 4b613da98f8..21fed4fd7ef 100755 --- a/dev/bots/docs.sh +++ b/dev/bots/docs.sh @@ -116,7 +116,7 @@ function generate_docs() { # Install and activate the snippets tool, which resides in the # assets-for-api-docs repo: # https://github.com/flutter/assets-for-api-docs/tree/master/packages/snippets - "$DART" pub global activate snippets 0.4.0 + "$DART" pub global activate snippets 0.4.2 # This script generates a unified doc set, and creates # a custom index.html, placing everything into DOC_DIR. diff --git a/dev/snippets/config/skeletons/dartpad-sample.html b/dev/snippets/config/skeletons/dartpad-sample.html index 9afc6233d90..d8ce7cafd31 100644 --- a/dev/snippets/config/skeletons/dartpad-sample.html +++ b/dev/snippets/config/skeletons/dartpad-sample.html @@ -13,7 +13,7 @@

{@end-inject-html} \ No newline at end of file diff --git a/dev/tools/create_api_docs.dart b/dev/tools/create_api_docs.dart index 12c49deb7d6..959b5c6d340 100644 --- a/dev/tools/create_api_docs.dart +++ b/dev/tools/create_api_docs.dart @@ -742,15 +742,15 @@ class DartdocGenerator { // Check a "dartpad" example, any one will do, and check for the correct URL // arguments. - // Just use "master" for any branch other than the LUCI_BRANCH. + // Just use "main" for any branch other than "stable", just like it is done + // in the snippet generator at https://github.com/flutter/assets-for-api-docs/blob/cc56972b8f03552fc5f9f9f1ef309efc6c93d7bc/packages/snippets/lib/src/snippet_generator.dart#L104. final String? luciBranch = platform.environment['LUCI_BRANCH']?.trim(); - final String expectedBranch = luciBranch != null && luciBranch.isNotEmpty ? luciBranch : 'master'; + final String expectedChannel = luciBranch == 'stable' ? 'stable' : 'main'; final List argumentRegExps = [ r'split=\d+', r'run=true', r'sample_id=widgets\.Listener\.\d+', - 'sample_channel=$expectedBranch', - 'channel=$expectedBranch', + 'channel=$expectedChannel', ]; for (final String argumentRegExp in argumentRegExps) { _sanityCheckExample( diff --git a/dev/tools/test/create_api_docs_test.dart b/dev/tools/test/create_api_docs_test.dart index 8e6d8e6f739..560eaef5902 100644 --- a/dev/tools/test/create_api_docs_test.dart +++ b/dev/tools/test/create_api_docs_test.dart @@ -441,7 +441,7 @@ void main() { '''); - const String queryParams = 'split=1&run=true&sample_id=widgets.Listener.123&sample_channel=master&channel=master'; + const String queryParams = 'split=1&run=true&sample_id=widgets.Listener.123&channel=main'; widgetsDir.childFile('Listener-class.html').writeAsStringSync('''