diff options
| author | Jonathan Amsterdam <jba@google.com> | 2026-03-20 13:37:49 -0400 |
|---|---|---|
| committer | Jonathan Amsterdam <jba@google.com> | 2026-03-24 09:32:29 -0700 |
| commit | 21096dc7108a47eba6d7bb0ada27be396420f88a (patch) | |
| tree | a429e21446268dfeac0daa6a1a1918760bc8f4ca /internal/api/testdata/pkg.go | |
| parent | f2497254fdac6fde9ff38a604f6891753b583a20 (diff) | |
| download | go-x-pkgsite-21096dc7108a47eba6d7bb0ada27be396420f88a.tar.xz | |
internal/api: render text documentation
Preliminary attempt to render documentation as text.
The output doesn't match either pkgsite or go doc.
It's a simplification of the latter.
The go doc command turns out to be surprisingly complicated,
so it's best to start simple.
Change-Id: I7b5a6bf36b1892afb30c212309dd646e3cf8b06a
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/757501
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Ethan Lee <ethanalee@google.com>
kokoro-CI: kokoro <noreply+kokoro@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'internal/api/testdata/pkg.go')
| -rw-r--r-- | internal/api/testdata/pkg.go | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/internal/api/testdata/pkg.go b/internal/api/testdata/pkg.go new file mode 100644 index 00000000..b9650bb8 --- /dev/null +++ b/internal/api/testdata/pkg.go @@ -0,0 +1,78 @@ +// 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 has every form of declaration. +// +// # Links +// +// - pkgsite repo, https://go.googlesource.com/pkgsite +// - Play with Go, https://play-with-go.dev +package pkg + +// C is a shorthand for 1. +const C = 1 + +// No exported name; should not appear. +const ( + a = 1 + b = 2 + c = 3 +) + +// V is a variable. +var V = 2 + +// F is a function. +func F() {} + +// Several constants. +const ( + X = 1 + Y = 2 +) + +// CT is a typed constant. +// They appear after their type. +const CT T = 3 + +// TF is a constructor for T. +func TF() T { return T(0) } + +// M is a method of T. +// BUG(xxx): this verifies that notes are rendered. +func (T) M() {} + +// T is a type. +type T int + +// S1 is a struct. +type S1 struct { + F int // field +} + +// S2 is another struct. +type S2 struct { + S1 + G int +} + +// I1 is an interface. +type I1 interface { + M1() +} + +type I2 interface { + I1 + M2() +} + +type ( + A int + B bool +) + +// Add adds 1 to x. +func Add(x int) int { + return x + 1 +} |
