Skip to content
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

x/pkgsite: examples missing playground links #36865

Closed
myitcv opened this issue Jan 29, 2020 · 21 comments
Closed

x/pkgsite: examples missing playground links #36865

myitcv opened this issue Jan 29, 2020 · 21 comments
Labels
FeatureRequest FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. pkgsite

Comments

@myitcv
Copy link
Member

myitcv commented Jan 29, 2020

What is the URL of the page with the issue?

https://pkg.go.dev/regexp?tab=doc#example-MatchString

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

Screenshot

Screen Shot 2020-01-29 at 13 09 25

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

Screen Shot 2020-01-29 at 13 09 44

What did you see instead?

No link.

@myitcv myitcv added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. pkgsite labels Jan 29, 2020
@julieqiu
Copy link
Member

/cc @dmitshur

@gopherbot gopherbot added this to the Unreleased milestone Feb 6, 2020
@Sajmani Sajmani self-assigned this Apr 1, 2020
gopherbot pushed a commit to golang/pkgsite that referenced this issue Jun 15, 2020
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>
@julieqiu julieqiu reopened this Jun 15, 2020
@julieqiu julieqiu assigned AceroM and unassigned Sajmani Jun 15, 2020
@julieqiu julieqiu changed the title go.dev: examples missing playground links x/pkgsite examples missing playground links Jun 15, 2020
@gopherbot
Copy link

Change https://golang.org/cl/241259 mentions this issue: internal/fetch: remove fetchplayurl implementation

@gopherbot
Copy link

Change https://golang.org/cl/241164 mentions this issue: internal/frontend: add frontend server endpoint for proxying play.golang.org/share

gopherbot pushed a commit to golang/pkgsite that referenced this issue Jul 9, 2020
…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>
@gopherbot
Copy link

Change https://golang.org/cl/240685 mentions this issue: internal/fetch: modify render function to use doc.example and removed fetchplayurl

gopherbot pushed a commit to golang/pkgsite that referenced this issue Jul 16, 2020
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>
@gopherbot
Copy link

Change https://golang.org/cl/243037 mentions this issue: internal: fix experiment variable for executable examples

gopherbot pushed a commit to golang/pkgsite that referenced this issue Jul 16, 2020
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>
@gopherbot
Copy link

Change https://golang.org/cl/243222 mentions this issue: internal/fetch: modify the documentation HTML/CSS to include playground executable examples

@gopherbot
Copy link

Change https://golang.org/cl/243638 mentions this issue: content/static: add CSS styling to the new embedded playground

@gopherbot
Copy link

Change https://golang.org/cl/243699 mentions this issue: content/static: add JS functionality to the new embedded playground

gopherbot pushed a commit to golang/pkgsite that referenced this issue Jul 22, 2020
…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>
@gopherbot
Copy link

Change https://golang.org/cl/244397 mentions this issue: internal/frontend: add integration test for playground example

gopherbot pushed a commit to golang/pkgsite that referenced this issue Jul 24, 2020
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>
@gopherbot
Copy link

Change https://golang.org/cl/244763 mentions this issue: internal/fetch: revert HideButtons field experiment flag

gopherbot pushed a commit to golang/pkgsite that referenced this issue Jul 25, 2020
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>
gopherbot pushed a commit to golang/pkgsite that referenced this issue Jul 27, 2020
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>
@gopherbot
Copy link

Change https://golang.org/cl/245378 mentions this issue: internal/frontend: add integration test for playground example

gopherbot pushed a commit to golang/pkgsite that referenced this issue Jul 29, 2020
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>
gopherbot pushed a commit to golang/pkgsite that referenced this issue Jul 30, 2020
…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>
@gopherbot
Copy link

Change https://golang.org/cl/245898 mentions this issue: internal/frontend: add metrics for playground share requests

@gopherbot
Copy link

Change https://golang.org/cl/246218 mentions this issue: content/static,internal: fix css padding for playground examples

@dmitshur dmitshur changed the title x/pkgsite examples missing playground links x/pkgsite: examples missing playground links Jul 31, 2020
gopherbot pushed a commit to golang/pkgsite that referenced this issue Aug 3, 2020
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>
@gopherbot
Copy link

Change https://golang.org/cl/246498 mentions this issue: content/static: fix css padding for playground examples

@gopherbot
Copy link

Change https://golang.org/cl/247401 mentions this issue: content/static: fix css margins for playground examples

gopherbot pushed a commit to golang/pkgsite that referenced this issue Aug 7, 2020
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>
@AceroM
Copy link

AceroM commented Aug 20, 2020

This feature is now code complete and will be available soon on pkg.go.dev! The output should look like this:
Kapture 2020-08-20 at 12 00 49
This will work for all playable examples on pkg.go.dev.

If you would like to test it out locally, you can do so by:
Running go run ./devtools/cmd/experiment create executable-examples to enable the experiment flag
Setting this CSS class to display: flex;

@gopherbot
Copy link

Change https://golang.org/cl/253599 mentions this issue: content/static/css: remove commented line to enable executable examples

gopherbot pushed a commit to golang/pkgsite that referenced this issue Sep 9, 2020
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>
@AceroM AceroM closed this as completed Sep 15, 2020
@mvdan
Copy link
Member

mvdan commented Sep 15, 2020

Why was this issue closed? Has it been fixed and deployed? Please specify when closing.

@AceroM
Copy link

AceroM commented Sep 15, 2020

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.

@golang golang locked and limited conversation to collaborators Sep 15, 2021
@rsc rsc unassigned AceroM Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. pkgsite
Projects
None yet
Development

No branches or pull requests

7 participants
@myitcv @mvdan @julieqiu @gopherbot @Sajmani @AceroM and others