aboutsummaryrefslogtreecommitdiff
path: root/internal/api/testdata/pkg_test.go
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2026-03-27 15:18:20 -0400
committerJonathan Amsterdam <jba@google.com>2026-04-06 07:29:20 -0700
commitf7258b211d2eab96a43600ece95d591f3973ae69 (patch)
tree97f1c8d21108973533054f33a01f17e8d5d26269 /internal/api/testdata/pkg_test.go
parent2d0d60d0e456af02dfc52d79053d5a3a20fb11ff (diff)
downloadgo-x-pkgsite-f7258b211d2eab96a43600ece95d591f3973ae69.tar.xz
internal/api: add support for examples
renderDoc now includes examples. It has an option to omit examples, if we decide to omit them in order to reduce the context load. Change-Id: Ieaa411fe09b439f51aac7d49195cd5791a20d0d8 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/761000 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: Ethan Lee <ethanalee@google.com> TryBot-Bypass: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'internal/api/testdata/pkg_test.go')
-rw-r--r--internal/api/testdata/pkg_test.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/internal/api/testdata/pkg_test.go b/internal/api/testdata/pkg_test.go
new file mode 100644
index 00000000..4697bec4
--- /dev/null
+++ b/internal/api/testdata/pkg_test.go
@@ -0,0 +1,46 @@
+// Copyright 2026 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package pkg_test
+
+import (
+ "fmt"
+
+ "golang.org/x/pkgsite/internal/api/testdata"
+)
+
+func Example() {
+ fmt.Println("Package example")
+ // Output:
+ // Package example
+}
+
+func ExampleF() {
+ pkg.F()
+ fmt.Println("F example")
+ // Output:
+ // F example
+}
+
+func ExampleF_second() {
+ pkg.F()
+ fmt.Println("F second example")
+ // Output:
+ // F second example
+}
+
+func ExampleT() {
+ _ = pkg.T(0)
+ fmt.Println("T example")
+ // Output:
+ // T example
+}
+
+func ExampleT_M() {
+ var t pkg.T
+ t.M()
+ fmt.Println("M example")
+ // Output:
+ // M example
+}