-
Notifications
You must be signed in to change notification settings - Fork 18k
x/pkgsite: examples missing playground links #36865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
/cc @dmitshur |
During doc fetch, share each example to the Go playground, then add a link to that shared example alongside the code. Fixes golang/go#36865 Change-Id: I541774af5f29e0bdbb9bd812496cc6e4fd39fcb6 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/715584 Reviewed-by: Julie Qiu <julieqiu@google.com>
Change https://golang.org/cl/241259 mentions this issue: |
Change https://golang.org/cl/241164 mentions this issue: |
…ang.org/share This change adds a /play handler that mirrors requests to play.golang.org/share which is used in implementing playground integration in the frontend. This change also adds a test that includes a mock server using net/httptest to check for proper status codes. Updates golang/go#36865 Change-Id: Ia3e902808534189ada747b270fed908e766c224b Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/241164 Reviewed-by: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
Change https://golang.org/cl/240685 mentions this issue: |
This commit modifies the codeHTML function to use *doc.Example instead of a *doc.Example.Code so that we can have access to *doc.Example.Play whenever the example is executable. This is important so that the imports are visible in the example documentation. If the example doesn't include a executable editor, it will default to rendering *doc.Example.Code. Also, this commit modifies the HTML template to include a play button for the playground integration, which will be displayed once all of the play button functionality is incorporated. This commit also adds an experiment flag to enable the feature by passing in context to the render function For golang/go#36865 Change-Id: If2ef0d128fdd791617aad5dd8eb8a08c90e9ae72 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/240685 Reviewed-by: Jonathan Amsterdam <jba@google.com>
Change https://golang.org/cl/243037 mentions this issue: |
The experiment variable for executable examples was describing the description of the variable rather than the name constant. This CL changes it to the name constant. For golang/go#36865 Change-Id: I84c3fcf8147c2c3964c262037ff2340f2ca0f39a Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/243037 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
Change https://golang.org/cl/243222 mentions this issue: |
Change https://golang.org/cl/243638 mentions this issue: |
Change https://golang.org/cl/243699 mentions this issue: |
…r executable examples This CL adds the HTML changes for the new play button, and error message for the playground integration. Corresponding experiment/feature flag is included. This change also adds example_test testdata for tests that verify executable and non executable examples. For golang/go#36865 Change-Id: I3b0339f61c2e46881681cc271252499142785000 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/243222 Reviewed-by: Julie Qiu <julie@golang.org>
Change https://golang.org/cl/244397 mentions this issue: |
This CL adds the CSS styling for the new playground examples. It is currently under a feature flag, so the CL won't make any visible changes to the website yet. Without error: https://i.imgur.com/OK4V0sU.png With error: https://i.imgur.com/sfqhZub.png For golang/go#36865 Change-Id: I8d0e2aeeb4076bb863d36887bfe8cb0d791a1f25 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/243638 Reviewed-by: Andrew Bonventre <andybons@golang.org>
Change https://golang.org/cl/244763 mentions this issue: |
This CL reverts the change for a "HideButtons" field in a package example struct. Instead of using a feature flag that we turn off and on for displaying the new Playground buttons, we will just replace the `display: none;` property back to `display: flex` in a future commit. For golang/go#36865 Change-Id: Iee29c431c22dc263bda8a812dfc148fd62d77f84 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/244763 Reviewed-by: Miguel Acero <acero@google.com>
fetchPlayUrl creates a request to golang.org/share during the fetch process which we do not want since it would make too many requests. We no longer need this code since we are generating the playUrl in the client side through a button in the frontend. The current implementation has tests for modules with examples and replaces the playlinks. This commit also updates the tests to reflect the current playground implementation. For golang/go#36865 Change-Id: Ie590538db2dcdb94d5aa2cdac9c72c3522b7a565 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/241259 Reviewed-by: Julie Qiu <julie@golang.org>
Change https://golang.org/cl/245378 mentions this issue: |
This change adds a boolean "replay" flag in the existing playground test for the /share endpoint. When enabled, the test will make a request to play.golang.org instead of a mock httptest server. For golang/go#36865 Change-Id: I26bb79d21500edbc128ce46e19bed493585a3e31 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/245378 Reviewed-by: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
…yground This CL implements a "play button" for each example in a given package that redirects to play.golang.org. This code is based on https://golang.org/lib/godoc/playground.js, it was modified to remove the dependence on jquery and bootstrap, as well as removing DOM creation to prevent jittering of the website. Example behavior: https://i.imgur.com/NcGO3kx.gif For golang/go#36865 Change-Id: Ic17ebd038561ef4dabbd139f6fa2e378968b01a1 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/243699 Reviewed-by: Andrew Bonventre <andybons@golang.org>
Change https://golang.org/cl/245898 mentions this issue: |
Change https://golang.org/cl/246218 mentions this issue: |
A metric is added for everytime a request is sent to play.golang.org. The request status code will be used and is useful to have better visibility on how many users click the new playground "play" button. For golang/go#36865 Change-Id: I243efe5b3d8724fa6bdd60d332e2932925ffe094 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/245898 Reviewed-by: Jonathan Amsterdam <jba@google.com>
Change https://golang.org/cl/246498 mentions this issue: |
Change https://golang.org/cl/247401 mentions this issue: |
The changes here will not appear until the display: none; experiment flag is removed If a playground example doesn't have an output and is accompanied by another example right below, currently there is no margin that separates the dropdown div and code input div above it. This change adds a margin-top to the dropdown. i.e: Non-executable example with no output https://pkg.go.dev/github.com/prometheus/client_golang/prometheus?tab=doc#example-Timer before: https://i.imgur.com/SpCNKQj.png after: https://i.imgur.com/iIr6ThE.png If a playground example doesn't have an output, currently there is no margin that separates the button and the code input div above it. This change adds a margin-top on the button container. i.e: Executable example with no output. https://pkg.go.dev/cloud.google.com/go?tab=doc#example-package-ApplicationDefaultCredentials before: https://i.imgur.com/yFMkKrt.png after: https://i.imgur.com/UkmqiHJ.png The reason the margin-top in the button container doesn't add onto the margin-bottom in an example with an output is because of margin collapsing that occurs between margin top and bottom properties. This is also true for the dropdown margin-top when the div above the dropdown is not the code input div. i.e: Executable example with output the before and after will remain the same https://i.imgur.com/hSzjvBn.png i.e: Dropdown with paragraph element above the before and after will remain the same https://i.imgur.com/niyfG7B.png For golang/go#36865 Change-Id: I5a271cb6cb899fcec6cbd22920e885c69c20b52b Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/247401 Reviewed-by: Julie Qiu <julie@golang.org>
This feature is now code complete and will be available soon on pkg.go.dev! The output should look like this: If you would like to test it out locally, you can do so by: |
Change https://golang.org/cl/253599 mentions this issue: |
This change replaces display: none; with display: flex; to enable executable examples in in the documentation page. The HTML changes used for this CSS change requires the executable-examples feature flag. Updates golang/go#36865 Change-Id: I2cb62438663ecbfbccfe1f5b4b6b1e2dbe3e3916 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/253599 Reviewed-by: Julie Qiu <julie@golang.org>
Why was this issue closed? Has it been fixed and deployed? Please specify when closing. |
Sorry about that! 😅 As @nu8 mentioned, the "play" button is now deployed now and should appear in packages with examples. |
What is the URL of the page with the issue?
https://pkg.go.dev/regexp?tab=doc#example-MatchString
What is your user agent?
Screenshot
What did you do?
Visited the link above to view the example.
What did you expect to see?
Expected to see a link that takes me to the example in the Go Playground, like godoc.org
What did you see instead?
No link.
The text was updated successfully, but these errors were encountered: