Skip to content
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

proposal: x/tools/{godoc,cmd/godoc}: isolate, tag, and delete godoc #59056

Open
adonovan opened this issue Mar 15, 2023 · 23 comments
Open

proposal: x/tools/{godoc,cmd/godoc}: isolate, tag, and delete godoc #59056

adonovan opened this issue Mar 15, 2023 · 23 comments
Labels
Milestone

Comments

@adonovan
Copy link
Member

The godoc command, golang.org/x/tools/cmd/godoc, was never redesigned to make full use of modules, has been deprecated in favor of pkgsite (https://pkg.go.dev), and has been neglected for some time. We propose to isolate, tag, and delete it from the golang.org/x/tools repository, using a similar process to the deletion of cmd/cover.

The main objection to doing so was that godoc is still useful for previewing the documentation of locally edited code, and that its replacement, pkgsite, was not well suited to the local preview use case and really needs additional features such as the ability to run without the network and to load packages on demand after startup. However, @findleyr recently added those features.

Are there any remaining reasons why we should not tag and delete cmd/godoc?

Related:

@gopherbot gopherbot added this to the Proposal milestone Mar 15, 2023
@aarzilli
Copy link
Contributor

I don't like that the recommended way to see documentation locally is something with 43 direct dependencies and 57 indirect dependencies. Why does it need two database drivers (redis and postgres), a VM for a scripting language (lua), an implementation of SSH, two RPC layers (grpc and protobuf), oauth2 and bindings to OpenTelemetry?

Pkgsite starts slower, serves pages slower, takes 30 seconds to load a standard library package every time I start it and it doesn't have the convenient list of packages that godoc has.

@go101
Copy link

go101 commented Mar 17, 2023

@aarzilli You may try Golds for an alternative.

@findleyr
Copy link
Contributor

Pkgsite starts slower, serves pages slower, takes 30 seconds to load a standard library package every time I start it and it doesn't have the convenient list of packages that godoc has.

@aarzilli FWIW I plan to fix both the slow loading and the downloading of the stdlib as part of https://go.dev/issue/40371. The slowness is due to rendering the entire module at once (rather than rendering packages as they are accessed). The stdlib loading time is due to downloading the stdlib rather than rendering GOROOT. Both should be fixable, and are definitely worth fixing.

As for why it needs so many dependencies: it is in the same module as pkg.go.dev, which integrates with cloud services. I suppose we could avoid this by splitting x/pkgsite into multiple modules, but that seems like a non-trivial amount of complexity and maintenance burden for little gain. I could be convinced otherwise, if folks have strong reasons why this is a problem.

@aarzilli
Copy link
Contributor

That's what I'm saying, there's always been two programs, what pkgsite is now used to be called gddo, it's not worth the effort trying to make pkgsite work well for both. The maintenance burden of godoc has been small so far, it should just be undeprecated.

@findleyr
Copy link
Contributor

I agree that the maintenance burden has been light thus far, and really appreciate all the community members that have stepped in to help with godoc. But having godoc live in x/tools means that it is ultimately the responsibility of the Go team to (at the very least) review CLs and not break the build. Ultimately, this requires attention, and attention is an extremely valuable resource!

Furthermore, there is no guarantee that the burden of this responsibility will continue to be light in the future. If in the future some change in Go causes godoc tests to fail, or if some critical bug is discovered in godoc, it will be incumbent upon the Go team to address the problem quickly, even if the fix is only to e.g. skip the test. (and if that's the fix, isn't it clearer to remove godoc from x/tools so as to not imply a level of support?).

@aarzilli
Copy link
Contributor

If that were to happen it could be removed then. On what basis do you predict the burden of maintenance will increase?

@amery
Copy link

amery commented Mar 19, 2023

@aarzilli You may try Golds for an alternative.

I tried @go101, but it falls apart when you work on multiple modules 😭

and pkgsite is still useless for local development. godoc seems to be still the only viable option

@go101
Copy link

go101 commented Mar 20, 2023

Yes, as Golds provides some richer features, such as showing be-direction relations between deping and deped packages (such as type implementation relation), there are some difficulties to parse multiple versions of a package at the same time, which is often caused by parsing multiple seed modules.

I believe the limitation originates from the golang.org/x/tools/go/packages package, though it is possible to make (some heavy) efforts to let Golds work through the limitation.

@zhsj
Copy link
Contributor

zhsj commented Mar 20, 2023

What's the recommended alternative for rendering private modules?

@amery
Copy link

amery commented Mar 20, 2023

Yes, as Golds provides some richer features, such as showing be-direction relations between deping and deped packages (such as type implementation relation), there are some difficulties to parse multiple versions of a package at the same time, which is often caused by parsing multiple seed modules.

I believe the limitation originates from the golang.org/x/tools/go/packages package, though it is possible to make (some heavy) efforts to let Golds work through the limitation.

wouldn't the dependency graph sort that instead of assuming the first package is the leaf?

@adonovan
Copy link
Member Author

[@amery] pkgsite is still useless for local development.

Could you elaborate? As of last week, pkgsite should display docs reflecting locally edited packages each time you reload the page.

@amery
Copy link

amery commented Mar 20, 2023

[@amery] pkgsite is still useless for local development.

Could you elaborate? As of last week, pkgsite should display docs reflecting locally edited packages each time you reload the page.

if you run pkgsite as-is you don't get any CSS or image, and to run frontend you need postgresql. pretty high requirements just to see the generated docs as godoc does out of the box

@findleyr
Copy link
Contributor

findleyr commented Mar 20, 2023

@amery please run x/pkgsite/cmd/pkgsite, which is the local version of pkgsite.

Edit: more specifically:

Install:

$ go install golang.org/x/pkgsite/cmd/pkgsite@master

Run:

$ pkgsite

@amery
Copy link

amery commented Mar 20, 2023

@amery please run x/pkgsite/cmd/pkgsite, which is the local version of pkgsite.

Edit: more specifically:

Install:

$ go install golang.org/x/pkgsite/cmd/pkgsite@master

Run:

$ pkgsite

I can confirm it now works. no idea why yesterday it was getting 404 from all static content pulled by the template. thanks a lot @findleyr

@fzipp
Copy link
Contributor

fzipp commented Mar 20, 2023

Some of the texts on the website mentioning godoc should probably be revised:

Finally the fmt and godoc commands are installed as regular binaries called gofmt and godoc because they are so often referenced.

--> godoc hasn't been included in the Go distribution since Go 1.13

One easy example is the server behind golang.org. It's just the godoc document server running in a production configuration on Google App Engine.

--> the website (now go.dev) is no longer served by godoc

For example, go install golang.org/x/tools/cmd/godoc@latest downloads, builds, and installs $GOBIN/godoc.

--> not wrong, but draws unnecessary attention to godoc, which is deprecated

@qiulaidongfeng
Copy link
Contributor

There are also several reasons not to delete cmd/godoc

@mvdan
Copy link
Member

mvdan commented Apr 24, 2023

@qiulaidongfeng note that you could always continue to use the last tag for godoc, as described in the original post. It won't get updates, but godoc isn't currently getting updates in master either.

@adonovan
Copy link
Member Author

@qiulaidongfeng I've reported #60114 for the slow std download problem and #40371 (comment) for the unexported symbols feature.

@gopherbot
Copy link

Change https://go.dev/cl/541237 mentions this issue: gopls/internal/lsp: add "Browse package documentation" code action

@3052
Copy link

3052 commented Jan 13, 2024

Are there any remaining reasons why we should not tag and delete cmd/godoc?

yep. godoc has a -url option, which can dump HTML:

-url string
     print HTML for named URL

honestly at this time both tools are pretty poor in general, as neither one seems to have an option to dump an entire module as a folder of HTML files. but failing that, godoc is still the better option of the two.

@qiulaidongfeng
Copy link
Contributor

qiulaidongfeng commented Jan 20, 2024

Find another reason not to delete cmd/godoc.

See #64920 and #61976 , If my use godoc, my experience is don't have to use the Internet.

More importantly, if my CL is used to modify documentation, in cmd, type godoc and you will see the revised std documentation in your browser.
Note that this practice relies on doing so that in order for vscode or gopls to work properly, it does not display hundreds of errors (e.g. use of internal package internal/abi not allowed), used in cmd ,set GOROOT=git clone go directory

See #60114 (comment) , use pkgsite can't see.

@adonovan
Copy link
Member Author

I believe the current consensus on the plan is for go doc -http [symbol] to start a local pkgsite instance which, thanks to work underway by @matloob, will start quickly and quietly. With a symbol argument, it will open a browser at the correct localhost URL. The details still need to be worked out.

In other news, VS Code is likely to get client-side support for rendering documentation within a pane of VS Code itself; see #64936 (comment). Other LSP clients will open a browser connected to a local pkgsite instance, or, perhaps, to the gopls server itself, which may serve pkgsite-like documentation; again there are details to work out.

@gopherbot
Copy link

Change https://go.dev/cl/571101 mentions this issue: _content/doc: update references to obsolete godoc

gopherbot pushed a commit to golang/website that referenced this issue Apr 11, 2024
Updates golang/go#59056

Change-Id: I43ff06556e06c5bd76ee17632d3b316a7fbb7e70
Reviewed-on: https://go-review.googlesource.com/c/website/+/571101
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Incoming
Development

No branches or pull requests