You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "damondouglas (via GitHub)" <gi...@apache.org> on 2023/01/30 16:49:07 UTC

[GitHub] [beam] damondouglas commented on a diff in pull request #25034: Test loading URLs

damondouglas commented on code in PR #25034:
URL: https://github.com/apache/beam/pull/25034#discussion_r1090863370


##########
playground/frontend/README.md:
##########
@@ -205,6 +205,143 @@ To add a new localization (using `fr` as an example):
 
 3. Add the locale to the list in `lib/l10n/l10n.dart`.
 
+## URLs and Embedding
+
+### Linking to a single example
+
+#### 1. Linking to a catalog example by path
+
+`https://play.beam.apache.org/?path=SDK_JAVA/PRECOMPILED_OBJECT_TYPE_KATA/AggregationMax&sdk=java`
+
+Handled by `StandardExampleLoader`.
+
+#### 2. Linking to the default catalog example
+
+`https://play.beam.apache.org/?sdk=python&default=true`
+
+Handled by `CatalogDefaultExampleLoader`.
+
+#### 3. Linking to a user-shared example
+
+`https://play.beam.apache.org/?sdk=java&shared=sdFdNV324HC`
+
+Handled by `UserSharedExampleLoader`.
+
+#### 4. Linking to an example by URL
+
+`https://play.beam.apache.org/?sdk=go&url=https://raw.githubusercontent.com/golang/go/master/src/fmt/format.go`
+
+Handled by `HttpExampleLoader`. The server with the example file must allow
+the cross-origin access. GitHub is known to allow it.
+Some servers may have different cross-origin policies when requested from localhost
+and other domains.
+
+#### 5. Linking to an empty editor
+
+`https://play.beam.apache.org/?sdk=go&empty=true`
+
+Handled by `EmptyExampleLoader`.
+
+### Passing view options
+
+Additional options may be passed with any of the above URL patterns.
+For them to work, the example must contain sections with the following syntax:
+
+```
+// [START section_name]
+void method() {
+...
+}
+// [END section_name]
+```
+
+See more on the syntax and limitations in the
+[README of the editor](https://pub.dev/packages/flutter_code_editor)
+that Playground uses.
+
+These options can be combined.
+
+#### Read-only sections
+
+Add `readonly` parameter with comma-separated section names:
+
+`https://play.beam.apache.org/?sdk=go&url=https://raw.githubusercontent.com/GoogleCloudPlatform/golang-samples/main/iam/snippets/roles_get.go&readonly=iam_get_role`
+
+#### Folding everything except sections
+
+Add `unfold` parameter with comma-separated section names:
+
+`https://play.beam.apache.org/?sdk=go&url=https://raw.githubusercontent.com/GoogleCloudPlatform/golang-samples/main/iam/snippets/roles_get.go&unfold=iam_get_role`
+
+This folds all foldable blocks that do not overlap with
+any of the given section.
+
+#### Hiding everything except a section
+
+Add `show` parameter with a single section name:
+
+`https://play.beam.apache.org/?sdk=go&url=https://raw.githubusercontent.com/GoogleCloudPlatform/golang-samples/main/iam/snippets/roles_get.go&show=iam_get_role`
+
+It is still the whole snippet that is sent for execution although only the given section
+is visible.
+
+This also makes the editor read-only so the user cannot add code that conflicts
+with the hidden text.
+
+### Linking to multiple examples
+
+With the above URLs, when the SDK is switched the following will be shown:
+
+- The catalog default example for the new SDK in the standalone playground.
+- The empty editor for the new SDK in the embedded playground.
+
+This can be changed by linking to multiple examples, up to one per SDK.
+
+For this purpose, make a JSON array with any combination of parameters that
+are allowed for loading single examples, for instance:
+
+```json
+[
+   {
+      "sdk": "java",
+      "path": "SDK_JAVA/PRECOMPILED_OBJECT_TYPE_KATA/AggregationMax"
+   },
+   {
+      "sdk": "go",
+      "url": "https://raw.githubusercontent.com/GoogleCloudPlatform/golang-samples/main/iam/snippets/roles_get.go",
+      "readonly": "iam_get_role"
+   }
+]
+```
+
+This starts with the Go example loaded from the URL.
+If SDK is then switched to Java, the `AggregationMax` catalog example is loaded for it.
+If SDK is switched to any other one, the default example for that SDK is loaded
+because no override was provided.
+
+`https://play.beam.apache.org/?sdk=go&examples=[{"sdk":"java","path":"SDK_JAVA/PRECOMPILED_OBJECT_TYPE_KATA/AggregationMax"},{"sdk":"go","url":"https://raw.githubusercontent.com/GoogleCloudPlatform/golang-samples/main/iam/snippets/roles_get.go","readonly":"iam_get_role"}]`

Review Comment:
   Tried this when running this branch locally and saw errors:
   ```
   The processing has started
   error: 7ac176f7-0249-4c06-86ea-c553b0a0f311.go:1:1: expected 'package', found 'EOF'
   
   output: 7ac176f7-0249-4c06-86ea-c553b0a0f311.go:1:1: expected 'package', found 'EOF'
   ```
   
   On the terminal I saw:
   ```
   Error: Assertion failed: flutter/lib/src/painting/text_painter.dart:975:12
   ```



##########
playground/frontend/build.gradle:
##########
@@ -183,16 +183,30 @@ ext.deleteFilesByRegExp = { re ->
 }
 
 tasks.register("integrationTest") {

Review Comment:
   Ran this command after following README instructions to download chromedriver.  Naturally as I was unable to run locally, the integration tests froze on the first URL.



-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org