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/tools/godoc: examples should skip build tag annotations in -play mode #26490
Comments
After moving the filepath.Walk example to a standalone example file[*] (so it could use a standalone function), godoc includes the build tag annotation ("// +build !windows,!plan9" in this case) in the runnable example. The example runs correctly, but the annotation might be confusing for new users. I think godoc should skip these annotations. Fixes golang/go#26490. [*] https://go-review.googlesource.com/c/go/+/122237
CC @andybons @agnivade @bradfitz @griesemer @ysmolsky |
So you just want to remove the +build lines from the output, and only for examples? Where? I don't see any +build lines at https://tip.golang.org/pkg/path/filepath/#Walk |
I moved the Could you mention the steps that you are doing to get this ? |
Ah nvm, I wasn't on latest master. I see it now. EDIT: @bradfitz the issue only occurs when the examples are runnable. tip.golang.org is not running with |
After moving the filepath.Walk example to a standalone example file in CL 122237 (so it could use a standalone function), godoc includes the build tag annotation ("// +build !windows,!plan9" in this case) in the runnable example. The example runs correctly, but the annotation might be confusing for new users. I think godoc should skip these annotations, when displaying examples. Fixes golang/go#26490.
Change https://golang.org/cl/125040 mentions this issue: |
After moving the filepath.Walk example to a standalone example file in CL 122237 (so it could use a standalone function), godoc includes the build tag annotation ("// +build !windows,!plan9" in this case) in the runnable example. The example runs correctly, but the annotation might be confusing for new users. I think godoc should skip these annotations when displaying examples. Fixes golang/go#26490. Change-Id: Ia4a542a48f28b03661ec881229124c7c7bf44646
After moving the filepath.Walk example to a standalone example file in CL 122237 (so it could use a standalone function), godoc includes the build tag annotation ("// +build !windows,!plan9" in this case) in the runnable example. The example runs correctly, but the annotation might be confusing for new users. I think godoc should skip these annotations when displaying examples. Fixes golang/go#26490. Change-Id: Ia4a542a48f28b03661ec881229124c7c7bf44646
After moving the filepath.Walk example to a standalone example file in CL 122237 (so it could use a standalone function), godoc includes the build tag annotation ("// +build !windows,!plan9" in this case) in the runnable example. The example runs correctly, but the annotation might be confusing for new users. I think godoc should skip these annotations when displaying examples. Fixes golang/go#26490. Change-Id: Ia4a542a48f28b03661ec881229124c7c7bf44646
After moving the filepath.Walk example to a standalone example file in CL 122237 (so it could use a standalone function), godoc includes the build tag annotation ("// +build !windows,!plan9" in this case) in the runnable example. The example runs correctly, but the annotation might be confusing for new users. I think godoc should skip these annotations when displaying examples. Fixes golang/go#26490. Change-Id: Ia4a542a48f28b03661ec881229124c7c7bf44646
Sorry for not mentioning the testcase earlier. On the tip of master, run Then open http://localhost:6060/pkg/path/filepath/#Walk in your browser and expand the Walk example: it starts with "// +build !windows,!plan9", which is not useful in the playground. |
After moving the filepath.Walk example to a standalone example file in CL 122237 (so it could use a standalone function), godoc includes the build tag annotation ("// +build !windows,!plan9" in this case) in the runnable example. The example runs correctly, but the annotation might be confusing for new users. I think godoc should skip these annotations when displaying examples. Fixes golang/go#26490. Skipped the testcase for now, since it triggers a false positive: golang/go#26627 Change-Id: I1da4b3b7e1e5a85a76773e25d9355b3f92479c19
Change https://golang.org/cl/126256 mentions this issue: |
After moving the filepath.Walk example to a standalone example file in CL 122237 (so it could use a standalone function), godoc includes the build tag annotation ("// +build !windows,!plan9" in this case) in the runnable example. The example runs correctly, but the annotation might be confusing for new users. I think godoc should skip these annotations when displaying examples. Fixes golang/go#26490. Avoid using a multiline string in the test, to avoid false positives from older versions of "go vet", which are still used on the build dashboard. Change-Id: I1da4b3b7e1e5a85a76773e25d9355b3f92479c19
After moving the filepath.Walk example to a standalone example file in CL 122237 (so it could use a standalone function), godoc includes the build tag annotation ("// +build !windows,!plan9" in this case) in the runnable example. The example runs correctly, but the annotation might be confusing for new users. Change the behavior so that godoc skips these annotations when displaying examples. To avoid false positives in older versions of "go vet", which are still used on the build dashboard, we avoid using a multiline string in the test. Fixes golang/go#26490. Change-Id: I1da4b3b7e1e5a85a76773e25d9355b3f92479c19
After moving the filepath.Walk example to a standalone example file in CL 122237 (so it could use a standalone function), godoc includes the build tag annotation ("// +build !windows,!plan9" in this case) in the runnable example. The example runs correctly, but the annotation might be confusing for new users. Change the behavior so that godoc skips these annotations when displaying examples. To avoid false positives in older versions of "go vet", which are still used on the build dashboard, we avoid using a multiline string in the test. Fixes golang/go#26490. Change-Id: I1da4b3b7e1e5a85a76773e25d9355b3f92479c19
After moving the filepath.Walk example to a standalone example file in CL 122237 (so it could use a standalone function), godoc includes the build tag annotation ("// +build !windows,!plan9" in this case) in the runnable example. The example runs correctly, but the annotation might be confusing for new users. Change the behavior so that godoc skips these annotations when displaying examples. To avoid false positives in older versions of "go vet", which are still used on the build dashboard, we avoid using a multiline string in the test. Fixes golang/go#26490. Change-Id: I1da4b3b7e1e5a85a76773e25d9355b3f92479c19
After moving the filepath.Walk example to a standalone example file in CL 122237 (so it could use a standalone function), godoc includes the build tag annotation ("// +build !windows,!plan9" in this case) in the runnable example. The example runs correctly, but the annotation might be confusing for new users. Change the behavior so that godoc skips these annotations when displaying examples. To avoid false positives in older versions of "go vet", which are still used on the build dashboard, we avoid using a multiline string in the test. Fixes golang/go#26490. Change-Id: I1da4b3b7e1e5a85a76773e25d9355b3f92479c19 GitHub-Last-Rev: bc5ed29 GitHub-Pull-Request: #42 Reviewed-on: https://go-review.googlesource.com/126256 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Andrew Bonventre <andybons@golang.org>
What did you do?
After moving the filepath.Walk example to a standalone example file (so it could use a standalone function), godoc includes the build tag annotation ("// +build !windows,!plan9" in this case) in the runnable example.
What did you expect to see?
The example, without the build tag annotation.
The text was updated successfully, but these errors were encountered: