aboutsummaryrefslogtreecommitdiff
path: root/internal/pkgdoc
AgeCommit message (Collapse)Author
15 hours[DO-NOT-MERGE] cmd/golangorg: allow serving in local as "go.local"Shulhan
Change-Id: I73aa112ba125b56dbdaf2727a3a7165c03de9b3f
2024-12-05all: remove unreachable codeSean Liao
While running go test -vet=all I saw a failure from unreachable code, which lead me to run deadcode on the entire repo. Change-Id: I20a7cd83f54595d12d46d1bdb714975e1efaf5e3 Reviewed-on: https://go-review.googlesource.com/c/website/+/633895 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-07-09cmd/golangorg: fix package link URLsRuss Cox
Doc comment text was linking to / instead of /pkg, which was creating dead links. Fix that. All other doc links were using /pkg/cmd/ instead of /cmd/. And we were serving everything in cmd in both places. Fix the links, and redirect /pkg/cmd/ to /cmd/. Change-Id: Ib5c205b3faf53aff0f0bb6d475fa942a6718e616 Reviewed-on: https://go-review.googlesource.com/c/website/+/596436 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2024-06-21cmd,internal: replace deprecated ioutil with io and osOleksandr Redko
Change-Id: I1d66a5c7b087d9329628efb6ce8849a004663b51 Reviewed-on: https://go-review.googlesource.com/c/website/+/592895 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2023-02-01internal/pkgdoc: remove support for Go 1.18Dmitri Shuralyov
Simplify code now that Go 1.18 is no longer supported. Change-Id: I97b522e04bcb5884c19ccbcf98bbd12b2709329b Reviewed-on: https://go-review.googlesource.com/c/website/+/457035 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
2022-12-12internal/backport: deleteDmitri Shuralyov
Now that the deploy happens with Go 1.19, it's viable to start using these packages from the standard library instead of their backported temporary copies. Keeping Go 1.18 happy during its last two months of support requires a tiny complication in pkgdoc package. An alternative path is to not drop internal/backport/go/doc and all of its dependencies right away, but getting to zero backported packages sooner was hard to resist... For golang/go#51800. Change-Id: Ieb7a137a033d6b6850dfc019c8c0c767756cc30d Reviewed-on: https://go-review.googlesource.com/c/website/+/456522 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Bypass: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
2022-08-03internal/pkgdoc: fix rendering of generics like atomic.PointerRuss Cox
Fixes golang/go#54200. Change-Id: I407b7368c524746b0f14c6ec5495c509794e331a Reviewed-on: https://go-review.googlesource.com/c/website/+/420794 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-07-25internal/pkgdoc: use new doc comment formatter directlyRuss Cox
The backport update brought in the new doc comment formatter, and it is already used via the deprecated APIs, but using the direct APIs allows better resolution of doc links within a given package. Fixes golang/go#51082. Change-Id: I6e8ff47b0381526a56d104c22c4ad69f716d4960 Reviewed-on: https://go-review.googlesource.com/c/website/+/417651 Reviewed-by: Jonathan Amsterdam <jba@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org>
2022-06-15all: fix a lot of typosFrederik Zipp
Change-Id: I0754d18f4c3c3d5dfa0c34b4bc154a35ac20b917 Reviewed-on: https://go-review.googlesource.com/c/website/+/411794 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-03-15all: handle Go 1.18 code on Go 1.16 AppEngine using new internal/backport/go/*Russ Cox
The immediate need was go/build, because the Go 1.16 go/build rejects code that has //go:build without // +build, as Go 1.18 code now does. But displaying code using generics would also have failed, for inability to parse that code. Add the full go/ast, go/doc, go/format, go/parser, go/printer, go/scanner, and go/token to fix those failures, which would become more frequent as generics are used more inside the standard library. The code is all from the go1.18 tag of the Go repo, post-processed to rewrite imports and apply gofmt -w -r 'any -> interface{}' to keep it building with the other backports and with Go 1.16 syntax. For golang/go#51686. Change-Id: I1e14f4634d8bc09bdaa04c014eadb1be97ea5047 Reviewed-on: https://go-review.googlesource.com/c/website/+/393194 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2021-08-23all: delete unmodified Go 1.16 backportsRuss Cox
Go 1.16 is available on App Engine now, so use it. Also, Go 1.17 has been released, meaning we don't need to keep Go 1.15 builders working. Delete all the Go 1.16 backports except the template packages, which contain modifications we need. Change-Id: I4612441a1484ce9272a22268da73d67f7624309b Reviewed-on: https://go-review.googlesource.com/c/website/+/343935 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-08-17internal/web: merge with go.dev/cmd/internal/siteRuss Cox
internal/web was the framework left serving golang.org. go.dev/cmd/internal/site was the framework serving go.dev. This CL merges the two into a coherent, simple site serving framework that works for both sites, a step toward merging the sites themselves. The CL is difficult to break up, so it's a bit larger than would be ideal. The best place to start is the doc comment in internal/web/site.go and then the other changes in that directory. The rest of the CL is just minor adjustments to the repo to match. Change-Id: I927dea29396104a817bd81b6bf25fa43f996968f Reviewed-on: https://go-review.googlesource.com/c/website/+/339403 Trust: Russ Cox <rsc@golang.org> Website-Publish: Russ Cox <rsc@golang.org> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-08-12cmd/golangorg: add ability to serve tip.golang.org directly from GerritRuss Cox
Currently, tip.golang.org is deployed by a background loop that fetches the latest Go and website repos every few minutes and then does a deploy to a whole separate app. Because this setup is different from the main app deploy, it often gets broken by changes in the way the main app runs. This CL removes the recurring source of breakage by making the main app capable of serving tip.golang.org directly. It does this by watching the main Go repo itself and downloading a new copy of the file tree whenever there are changes. The website repo is not watched: new changes to the website repo already result in redeploys of the entire app when appropriate. This CL does not actually enable the new tip.golang.org code. A followup CL will do that, for easier rollback. Change-Id: I015368c614579c90fa72a6699f6ab76202f87e7e Reviewed-on: https://go-review.googlesource.com/c/website/+/328214 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-07-23internal/pkgdoc: take on doc-specific parts of internal/webRuss Cox
Not all the package docs-specific parts of the server moved into internal/pkgdoc before. Finish the job. Now the API for pkgdoc is like the API for codewalk: just a NewServer that returns a handler. Speaking of codewalk, unexport the Server type to match the trimmed-down pkgdoc. Change-Id: I19ba7351d55fb5d23d551a0296bb89d8abac6e9b Reviewed-on: https://go-review.googlesource.com/c/website/+/328212 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Website-Publish: Russ Cox <rsc@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-07-12internal/web: redirect golang.org/pkg/... to pkg.go.dev/...Russ Cox
This reduces the number of documentation sites we have to one. Except in China, where we have to keep serving on the one domain golang.google.cn - there is no pkg.go.dev in China. And unless people opt out with ?m=old. For golang/go#44356. Change-Id: I2a5b788ac861ce37f356287413468497d184fc09 Reviewed-on: https://go-review.googlesource.com/c/website/+/327849 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-06-15all: make compatible with Go 1.15Russ Cox
With the help of the backported libraries introduced in the previous CL, we can make the whole cmd/golangorg site run on Go 1.15 again. This will let us use App Engine standard in advance of the release of Go 1.16 on App Engine. Change-Id: I9d1612de6f366e0774919aa6a94af14aafb248f5 Reviewed-on: https://go-review.googlesource.com/c/website/+/323891 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-06-14all: remove toFS usageRuss Cox
The toFS calls were a stop-gap to convert from old code that wasn't strict about path forms to the io/fs routines that are more strict. Arrange to pass io/fs-compatible paths everywhere and remove toFS. Change-Id: Id69c0f23074ebd3a6dfef2255b2f8185ad1d1249 Reviewed-on: https://go-review.googlesource.com/c/website/+/317659 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-06-14internal/godoc: clean up use of templatesRuss Cox
- convert from text/template to html/template - use proper template set - always pass *godoc.Page to templates, with custom value in .Data - move stateful site template functions to methods on *godoc.Page - unexport Presentation.ServeFile: ServeHTTP is good enough - reorder api.DB.Func args to match source order (pkg first) - rename lib/godoc/godoc.html to lib/godoc/site.html (lib/godoc itself must stay lib/godoc because of links to other content it holds). Change-Id: I873f17db20107fdab11d276932e6d847a6081015 Reviewed-on: https://go-review.googlesource.com/c/website/+/317655 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-06-08all: remove ?m=srcRuss Cox
Instead of /pkg/fmt/?m=src people can use /src/pkg/fmt/. Change-Id: I77dd11dcfa1b3e8d660e9cda6a5f07dbb60d721b Reviewed-on: https://go-review.googlesource.com/c/website/+/317654 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Website-Publish: Russ Cox <rsc@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-04-26internal/pkgdoc: fix synopsis pkg name == dir name matchingYu, Li-Yu
file.Name.Name should match the directory name not the filename. In CL 296378, newDirTree's name parameter was removed and synopsis matched against the filename of the source code, e.g. "*.go". Fixes golang/go#45042 Fixes golang/go#45614 Change-Id: Ifa4c8a70429e277efb1f9f726de9249509cbcee0 Reviewed-on: https://go-review.googlesource.com/c/website/+/311089 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Cherry Zhang <cherryyz@google.com>
2021-03-12internal/godoc: split package docs into new package pkgdoc [generated]Russ Cox
Isolate package docs scanning and extraction into a new package. Generated by script below. [git-generate] cd internal/godoc rf ' # We want to end up with each package having its own toFS, # but to keep each step leaving a valid package, export toFS as ToFSPath # so it can be used as pkgdoc.ToFSPath after the move. # We will rewrite the uses left behind after the move. mv toFS ToFSPath mv newDirTree newDir mv Directory Dir mv Dir.listing Dir.List mv Dir.lookup Dir.Lookup mv \ ToFSPath \ Dir \ Dir.Name \ DirList \ DirEntry \ DirEntry.Name \ Dir.Lookup \ Dir.List \ newDir \ isPkgFile \ isPkgDir \ Dir.walk \ walkDirs \ parseFile \ parseFiles \ linePrefix \ replaceLinePrefixCommentsWithBlankLine \ dir.go mv stripExampleSuffix TrimExampleSuffix mv splitExampleName SplitExampleName mv poorMansImporter simpleImporter mv dirtrees_test.go dir_test.go mv \ DocTree \ NewDocTree \ PageInfo \ PageInfo.IsEmpty \ PageInfoMode \ NoFiltering \ modeNames \ PageInfoMode.String \ GetPageInfoMode \ DocTree.GetPageInfo \ DocTree.includePath \ simpleImporter \ packageExports \ funcsByName \ funcsByName.Len \ funcsByName.Swap \ funcsByName.Less \ collectExamples \ globalNames \ addNames \ SplitExampleName \ TrimExampleSuffix \ startsWithUppercase \ doc.go mv \ TestIgnoredGoFiles \ TestIssue5247 \ doc_test.go mv dir.go dir_test.go doc.go doc_test.go golang.org/x/website/internal/pkgdoc # Add a new toFS and rewrite the uses left behind. add server.go:/^\)/ \ // toFS returns the io/fs name for path (no leading slash). \ func toFS(name string) string { \ if name == "/" { \ return "." \ } \ return path.Clean(strings.TrimPrefix(name, "/")) \ } ex { import "golang.org/x/website/internal/pkgdoc" var x string pkgdoc.ToFSPath(x) -> toFS(x) } ' rm dirtrees.go parser.go cd ../pkgdoc rf ' # Finish toFS split mv ToFSPath toFS # Clean up API for package pkgdoc mv PageInfo Page mv DocTree.GetPageInfo Doc.Page mv DocTree Docs mv NewDocTree NewDocs mv PageInfoMode Mode mv GetPageInfoMode ParseMode mv NoFiltering ModeAll mv FlatDir ModeFlat mv AllMethods ModeMethods mv ShowSource ModeSrc mv NoTypeAssoc ModeBuiltin ' Change-Id: I24384f40739af286c528beb06aa153843005a870 Reviewed-on: https://go-review.googlesource.com/c/website/+/296380 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>