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

cmd/go: doc -http should start a pkgsite instance and open a browser #68106

Open
adonovan opened this issue Jun 21, 2024 · 9 comments
Open

cmd/go: doc -http should start a pkgsite instance and open a browser #68106

adonovan opened this issue Jun 21, 2024 · 9 comments
Assignees
Labels
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Jun 21, 2024

The go doc command displays documentation to stdout, which is handy for quick forays for a single package or symbol, but for extended reading a browser is more convenient, as it has better typography and linked cross-references. We propose that go doc -http should start a pkgsite instance in the background (if one is not running already) and open a web browser to the correct URL for the package or symbol.

The pkgsite program is currently rather large and slow to start as it was designed as a long-lived server for a large corpus on Google Cloud. Issue #61399 tracks the work to slim it down and reduce dependencies.

Open questions:

  • How should successive go doc processes communicate the port or pid of the running instance, and deal with server crashes?
  • The server would necessarily outlive the go command. Is an explicit "stop" operation necessary?
  • Should the -http flag be a boolean, or an integer port? I think boolean (picking any unused port) would be more friendly.

@rsc @matloob

@gopherbot gopherbot added this to the Proposal milestone Jun 21, 2024
@adonovan adonovan added FeatureRequest GoCommand cmd/go pkgsite/cmd Issues related to x/pkgsite/cmd/pkgsite and removed Proposal labels Jun 21, 2024
@gabyhelp
Copy link

Similar Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@qiulaidongfeng
Copy link
Member

I would like know to run go doc -http, which starts a pkgsite process and opens a browser, then waits for the syscall.SIGINT signal, and when it receives the signal, first close the pkgsite process and then exit itself ,how?

@adonovan
Copy link
Member Author

We could certainly make go doc -http block until interrupted before terminating the server. And perhaps that's the least surprising interface, as many Go commands that take an -http flag block indefinitely.

@ianlancetaylor ianlancetaylor moved this to Incoming in Proposals Jun 26, 2024
@matloob matloob self-assigned this Jun 27, 2024
@rsc
Copy link
Contributor

rsc commented Jul 25, 2024

This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group

@rsc rsc moved this from Incoming to Active in Proposals Jul 25, 2024
@rsc
Copy link
Contributor

rsc commented Aug 7, 2024

go doc -http should open the browser (we have other go tools that do that).
and it should print the URL and block until you get a ^C.

it would be slick if the browser integration could track reliably whether the last page was closed and have go doc -http exit at that point.

@rsc
Copy link
Contributor

rsc commented Aug 14, 2024

Have all remaining concerns about this proposal been addressed?

The proposal is to add go doc -http, which will start a server and attempt to open a browser window on the docs for a given package. If a browser successfully navigates there and then all the open browser windows close, go doc -http will exit. Otherwise it can be ^C-ed early, of course.

@rsc rsc moved this from Active to Likely Accept in Proposals Aug 29, 2024
@rsc
Copy link
Contributor

rsc commented Aug 29, 2024

Based on the discussion above, this proposal seems like a likely accept.
— rsc for the proposal review group

The proposal is to add go doc -http, which will start a server and attempt to open a browser window on the docs for a given package. If a browser successfully navigates there and then all the open browser windows close, go doc -http will exit. Otherwise it can be ^C-ed early, of course.

@rsc
Copy link
Contributor

rsc commented Sep 4, 2024

No change in consensus, so accepted. 🎉
This issue now tracks the work of implementing the proposal.
— rsc for the proposal review group

The proposal is to add go doc -http, which will start a server and attempt to open a browser window on the docs for a given package. If a browser successfully navigates there and then all the open browser windows close, go doc -http will exit. Otherwise it can be ^C-ed early, of course.

@rsc rsc moved this from Likely Accept to Accepted in Proposals Sep 4, 2024
@rsc rsc changed the title proposal: cmd/go: doc -http should start a pkgsite instance and open a browser cmd/go: doc -http should start a pkgsite instance and open a browser Sep 4, 2024
@rsc rsc modified the milestones: Proposal, Backlog Sep 4, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/628175 mentions this issue: cmd/doc: add debug support for starting pkgsite instance for docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Accepted
Development

No branches or pull requests

7 participants