Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
x/pkgsite: examples missing playground links #36865
What is the URL of the page with the issue?
What is your user agent?
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.66 Safari/537.36
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?
Yes thanks, I came here looking for this. If you visit the current site:
You get complete example, with
Now if you visit the same page with the new site:
You dont get a complete example, everything is stripped except for pretty much
I get that some might want to clean things up and remove cruft, but at a minimum
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 <email@example.com>
…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 <firstname.lastname@example.org> Reviewed-by: Jonathan Amsterdam <email@example.com>
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 <firstname.lastname@example.org>
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 <email@example.com> Reviewed-by: Julie Qiu <firstname.lastname@example.org>
…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 <email@example.com>
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 <firstname.lastname@example.org>
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 <email@example.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 <firstname.lastname@example.org>
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 <email@example.com> Reviewed-by: Jonathan Amsterdam <firstname.lastname@example.org>
…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 <email@example.com>
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 <firstname.lastname@example.org>