Граф коммитов

19 Коммитов

Автор SHA1 Сообщение Дата
Russ Cox 3712d1ccfb cmd/golangorg: fix package link URLs
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-07-09 19:55:51 +00:00
Oleksandr Redko c9f9352637 cmd,internal: replace deprecated ioutil with io and os
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>
2024-06-21 19:00:48 +00:00
Dmitri Shuralyov 26bd212416 internal/pkgdoc: remove support for Go 1.18
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>
2023-02-01 20:30:54 +00:00
Dmitri Shuralyov a697538369 internal/backport: delete
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-12-12 20:37:14 +00:00
Russ Cox 11196f2d29 internal/pkgdoc: fix rendering of generics like atomic.Pointer
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-08-03 16:34:40 +00:00
Russ Cox 3768cf1c56 internal/pkgdoc: use new doc comment formatter directly
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-07-25 20:38:04 +00:00
Frederik Zipp 4056b246ea all: fix a lot of typos
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-06-15 16:32:49 +00:00
Russ Cox 7a60f303d8 all: handle Go 1.18 code on Go 1.16 AppEngine using new internal/backport/go/*
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>
2022-03-15 21:20:57 +00:00
Russ Cox a3cb3101ad all: delete unmodified Go 1.16 backports
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-23 15:30:31 +00:00
Russ Cox ef7fed48ec internal/web: merge with go.dev/cmd/internal/site
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-17 13:59:37 +00:00
Russ Cox f4281e3dec cmd/golangorg: add ability to serve tip.golang.org directly from Gerrit
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-08-12 13:25:58 +00:00
Russ Cox 39c67f0653 internal/pkgdoc: take on doc-specific parts of internal/web
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-23 19:28:56 +00:00
Russ Cox aa5eb5fcb4 internal/web: redirect golang.org/pkg/... to pkg.go.dev/...
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-07-12 19:03:25 +00:00
Russ Cox d831351689 all: make compatible with Go 1.15
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-15 02:35:50 +00:00
Russ Cox 5ee419f2ea all: remove toFS usage
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-14 17:41:38 +00:00
Russ Cox 4c9e549253 internal/godoc: clean up use of templates
- 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-14 17:41:27 +00:00
Russ Cox 9d7d9c7a5d all: remove ?m=src
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-06-08 20:20:20 +00:00
Yu, Li-Yu 1eaa20f5b9 internal/pkgdoc: fix synopsis pkg name == dir name matching
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-04-26 16:24:13 +00:00
Russ Cox 7fe51e8c4a internal/godoc: split package docs into new package pkgdoc [generated]
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>
2021-03-12 19:58:10 +00:00