damondouglas commented on code in PR #25034: URL: https://github.com/apache/beam/pull/25034#discussion_r1097934897
########## playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart: ########## @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ignore_for_file: prefer_interpolation_to_compose_strings + +import 'package:http/http.dart' as http; +import 'package:playground_components/playground_components.dart'; + +import '../code.dart'; + +const _noGraphSdks = [Sdk.go, Sdk.scio]; + +/// Describes an example for the purpose of integration tests. +class ExampleDescriptor { + static const _schemaAndHost = 'https://raw.githubusercontent.com/'; + + static const _defaultRepositoryAndRef = 'apache/beam/master'; + // If running before this is deployed, change to this: + // static const _defaultRepositoryAndRef = + // 'akvelon/beam/issue24959_test-loading-url'; + + const ExampleDescriptor( + this.name, { + required this.dbPath, + required this.path, + required this.sdk, + this.contextLine1Based, + this.croppedFoldedVisibleText, + this.foldedVisibleText, + this.outputContains, + this.outputTail, + this.repositoryAndRef = _defaultRepositoryAndRef, + }); + + /// 1-based line index to set cursor to. + final int? contextLine1Based; + + /// A token to retrieve the example from server. + final String dbPath; + + /// Name as shown in the dropdown. + final String name; + + /// File path relative to the repository root, starting with `/`. + final String path; + + final String repositoryAndRef; Review Comment: Comment? ########## playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart: ########## @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ignore_for_file: prefer_interpolation_to_compose_strings + +import 'package:http/http.dart' as http; +import 'package:playground_components/playground_components.dart'; + +import '../code.dart'; + +const _noGraphSdks = [Sdk.go, Sdk.scio]; + +/// Describes an example for the purpose of integration tests. +class ExampleDescriptor { + static const _schemaAndHost = 'https://raw.githubusercontent.com/'; + + static const _defaultRepositoryAndRef = 'apache/beam/master'; + // If running before this is deployed, change to this: + // static const _defaultRepositoryAndRef = + // 'akvelon/beam/issue24959_test-loading-url'; + + const ExampleDescriptor( + this.name, { + required this.dbPath, + required this.path, + required this.sdk, + this.contextLine1Based, + this.croppedFoldedVisibleText, + this.foldedVisibleText, + this.outputContains, + this.outputTail, + this.repositoryAndRef = _defaultRepositoryAndRef, + }); + + /// 1-based line index to set cursor to. + final int? contextLine1Based; + + /// A token to retrieve the example from server. + final String dbPath; + + /// Name as shown in the dropdown. + final String name; + + /// File path relative to the repository root, starting with `/`. + final String path; + + final String repositoryAndRef; + + final Sdk sdk; + + /// Visible text when using `visibleSectionNames` and `foldOutsideSections()`. + final String? croppedFoldedVisibleText; + + /// Visible text when using `foldOutsideSections()`. + final String? foldedVisibleText; + + final List<String>? outputContains; + final String? outputTail; Review Comment: Comment? ########## playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart: ########## @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ignore_for_file: prefer_interpolation_to_compose_strings + +import 'package:http/http.dart' as http; +import 'package:playground_components/playground_components.dart'; + +import '../code.dart'; + +const _noGraphSdks = [Sdk.go, Sdk.scio]; + +/// Describes an example for the purpose of integration tests. +class ExampleDescriptor { + static const _schemaAndHost = 'https://raw.githubusercontent.com/'; + + static const _defaultRepositoryAndRef = 'apache/beam/master'; + // If running before this is deployed, change to this: + // static const _defaultRepositoryAndRef = + // 'akvelon/beam/issue24959_test-loading-url'; + + const ExampleDescriptor( + this.name, { + required this.dbPath, + required this.path, + required this.sdk, + this.contextLine1Based, + this.croppedFoldedVisibleText, + this.foldedVisibleText, + this.outputContains, + this.outputTail, + this.repositoryAndRef = _defaultRepositoryAndRef, + }); + + /// 1-based line index to set cursor to. + final int? contextLine1Based; + + /// A token to retrieve the example from server. + final String dbPath; + + /// Name as shown in the dropdown. + final String name; + + /// File path relative to the repository root, starting with `/`. + final String path; + + final String repositoryAndRef; + + final Sdk sdk; + + /// Visible text when using `visibleSectionNames` and `foldOutsideSections()`. + final String? croppedFoldedVisibleText; + + /// Visible text when using `foldOutsideSections()`. + final String? foldedVisibleText; + + final List<String>? outputContains; + final String? outputTail; + + bool get hasGraphTab => !_noGraphSdks.contains(sdk); + + /// The URL to view the file raw content on GitHub. + String get url => '$_schemaAndHost$repositoryAndRef$path'; + + Future<String> getVisibleText() async { + final content = await getFullText(); + + return foldLicenseAndImports(content, sdk.highlightMode!); + } + + Future<String> getFullText() async { + final response = await http.get(Uri.parse(url)); + return cutTagComments(response.body); + } + + static String cutTagComments(String code) { Review Comment: Comment? ########## playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart: ########## @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ignore_for_file: prefer_interpolation_to_compose_strings + +import 'package:http/http.dart' as http; +import 'package:playground_components/playground_components.dart'; + +import '../code.dart'; + +const _noGraphSdks = [Sdk.go, Sdk.scio]; + +/// Describes an example for the purpose of integration tests. +class ExampleDescriptor { + static const _schemaAndHost = 'https://raw.githubusercontent.com/'; + + static const _defaultRepositoryAndRef = 'apache/beam/master'; + // If running before this is deployed, change to this: + // static const _defaultRepositoryAndRef = + // 'akvelon/beam/issue24959_test-loading-url'; + + const ExampleDescriptor( + this.name, { + required this.dbPath, + required this.path, + required this.sdk, + this.contextLine1Based, + this.croppedFoldedVisibleText, + this.foldedVisibleText, + this.outputContains, + this.outputTail, + this.repositoryAndRef = _defaultRepositoryAndRef, + }); + + /// 1-based line index to set cursor to. + final int? contextLine1Based; + + /// A token to retrieve the example from server. + final String dbPath; + + /// Name as shown in the dropdown. + final String name; + + /// File path relative to the repository root, starting with `/`. + final String path; + + final String repositoryAndRef; + + final Sdk sdk; + + /// Visible text when using `visibleSectionNames` and `foldOutsideSections()`. + final String? croppedFoldedVisibleText; + + /// Visible text when using `foldOutsideSections()`. + final String? foldedVisibleText; + + final List<String>? outputContains; + final String? outputTail; + + bool get hasGraphTab => !_noGraphSdks.contains(sdk); + + /// The URL to view the file raw content on GitHub. + String get url => '$_schemaAndHost$repositoryAndRef$path'; + + Future<String> getVisibleText() async { + final content = await getFullText(); + + return foldLicenseAndImports(content, sdk.highlightMode!); + } + + Future<String> getFullText() async { Review Comment: Comment? ########## playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart: ########## @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ignore_for_file: prefer_interpolation_to_compose_strings + +import 'package:http/http.dart' as http; +import 'package:playground_components/playground_components.dart'; + +import '../code.dart'; + +const _noGraphSdks = [Sdk.go, Sdk.scio]; + +/// Describes an example for the purpose of integration tests. +class ExampleDescriptor { + static const _schemaAndHost = 'https://raw.githubusercontent.com/'; + + static const _defaultRepositoryAndRef = 'apache/beam/master'; + // If running before this is deployed, change to this: + // static const _defaultRepositoryAndRef = + // 'akvelon/beam/issue24959_test-loading-url'; + + const ExampleDescriptor( + this.name, { + required this.dbPath, + required this.path, + required this.sdk, + this.contextLine1Based, + this.croppedFoldedVisibleText, + this.foldedVisibleText, + this.outputContains, + this.outputTail, + this.repositoryAndRef = _defaultRepositoryAndRef, + }); + + /// 1-based line index to set cursor to. + final int? contextLine1Based; + + /// A token to retrieve the example from server. + final String dbPath; + + /// Name as shown in the dropdown. + final String name; + + /// File path relative to the repository root, starting with `/`. + final String path; + + final String repositoryAndRef; + + final Sdk sdk; Review Comment: Comment? ########## playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart: ########## @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ignore_for_file: prefer_interpolation_to_compose_strings + +import 'package:http/http.dart' as http; +import 'package:playground_components/playground_components.dart'; + +import '../code.dart'; + +const _noGraphSdks = [Sdk.go, Sdk.scio]; + +/// Describes an example for the purpose of integration tests. +class ExampleDescriptor { + static const _schemaAndHost = 'https://raw.githubusercontent.com/'; + + static const _defaultRepositoryAndRef = 'apache/beam/master'; + // If running before this is deployed, change to this: + // static const _defaultRepositoryAndRef = + // 'akvelon/beam/issue24959_test-loading-url'; + + const ExampleDescriptor( + this.name, { + required this.dbPath, + required this.path, + required this.sdk, + this.contextLine1Based, + this.croppedFoldedVisibleText, + this.foldedVisibleText, + this.outputContains, + this.outputTail, + this.repositoryAndRef = _defaultRepositoryAndRef, + }); + + /// 1-based line index to set cursor to. + final int? contextLine1Based; + + /// A token to retrieve the example from server. + final String dbPath; + + /// Name as shown in the dropdown. + final String name; + + /// File path relative to the repository root, starting with `/`. + final String path; + + final String repositoryAndRef; + + final Sdk sdk; + + /// Visible text when using `visibleSectionNames` and `foldOutsideSections()`. + final String? croppedFoldedVisibleText; + + /// Visible text when using `foldOutsideSections()`. + final String? foldedVisibleText; + + final List<String>? outputContains; + final String? outputTail; + + bool get hasGraphTab => !_noGraphSdks.contains(sdk); Review Comment: Comment? ########## playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart: ########## @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ignore_for_file: prefer_interpolation_to_compose_strings + +import 'package:http/http.dart' as http; +import 'package:playground_components/playground_components.dart'; + +import '../code.dart'; + +const _noGraphSdks = [Sdk.go, Sdk.scio]; + +/// Describes an example for the purpose of integration tests. +class ExampleDescriptor { + static const _schemaAndHost = 'https://raw.githubusercontent.com/'; + + static const _defaultRepositoryAndRef = 'apache/beam/master'; + // If running before this is deployed, change to this: + // static const _defaultRepositoryAndRef = + // 'akvelon/beam/issue24959_test-loading-url'; + + const ExampleDescriptor( + this.name, { + required this.dbPath, + required this.path, + required this.sdk, + this.contextLine1Based, + this.croppedFoldedVisibleText, + this.foldedVisibleText, + this.outputContains, + this.outputTail, + this.repositoryAndRef = _defaultRepositoryAndRef, + }); + + /// 1-based line index to set cursor to. + final int? contextLine1Based; + + /// A token to retrieve the example from server. + final String dbPath; + + /// Name as shown in the dropdown. + final String name; + + /// File path relative to the repository root, starting with `/`. + final String path; + + final String repositoryAndRef; + + final Sdk sdk; + + /// Visible text when using `visibleSectionNames` and `foldOutsideSections()`. + final String? croppedFoldedVisibleText; + + /// Visible text when using `foldOutsideSections()`. + final String? foldedVisibleText; + + final List<String>? outputContains; Review Comment: Comment? ########## playground/frontend/playground_components_dev/lib/src/examples/example_descriptor.dart: ########## @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ignore_for_file: prefer_interpolation_to_compose_strings + +import 'package:http/http.dart' as http; +import 'package:playground_components/playground_components.dart'; + +import '../code.dart'; + +const _noGraphSdks = [Sdk.go, Sdk.scio]; + +/// Describes an example for the purpose of integration tests. +class ExampleDescriptor { + static const _schemaAndHost = 'https://raw.githubusercontent.com/'; + + static const _defaultRepositoryAndRef = 'apache/beam/master'; + // If running before this is deployed, change to this: + // static const _defaultRepositoryAndRef = + // 'akvelon/beam/issue24959_test-loading-url'; + + const ExampleDescriptor( + this.name, { + required this.dbPath, + required this.path, + required this.sdk, + this.contextLine1Based, + this.croppedFoldedVisibleText, + this.foldedVisibleText, + this.outputContains, + this.outputTail, + this.repositoryAndRef = _defaultRepositoryAndRef, + }); + + /// 1-based line index to set cursor to. + final int? contextLine1Based; + + /// A token to retrieve the example from server. + final String dbPath; + + /// Name as shown in the dropdown. + final String name; + + /// File path relative to the repository root, starting with `/`. + final String path; + + final String repositoryAndRef; + + final Sdk sdk; + + /// Visible text when using `visibleSectionNames` and `foldOutsideSections()`. + final String? croppedFoldedVisibleText; + + /// Visible text when using `foldOutsideSections()`. + final String? foldedVisibleText; + + final List<String>? outputContains; + final String? outputTail; + + bool get hasGraphTab => !_noGraphSdks.contains(sdk); + + /// The URL to view the file raw content on GitHub. + String get url => '$_schemaAndHost$repositoryAndRef$path'; + + Future<String> getVisibleText() async { Review Comment: Comment? ########## playground/frontend/playground_components_dev/lib/src/examples/go/example.dart: ########## @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'package:playground_components/playground_components.dart'; + +import '../example_descriptor.dart'; + +const goExample = ExampleDescriptor( Review Comment: What is this an example of? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
