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

x/pkgsite: add flag to set an alternative for /files URLs #63403

Closed
adonovan opened this issue Oct 5, 2023 · 2 comments
Closed

x/pkgsite: add flag to set an alternative for /files URLs #63403

adonovan opened this issue Oct 5, 2023 · 2 comments
Assignees
Labels

Comments

@adonovan
Copy link
Member

adonovan commented Oct 5, 2023

This issue is a feature request to add a command-line flag to change the prefix of the URLs generated for source declarations.
For example, when I run pkgsite in a local clone of the kubernetes repo, by clicking around on the API documentation for a package, I can reach this URL:

http://localhost:8080/files/Users/adonovan/w/kubernetes/k8s.io/kubernetes/pkg/api/endpoints/testing/make.go#L53

I would like to be able to run pkgsite in a mode in which this link instead goes to:

http://localhost:12345/something/Users/adonovan/w/kubernetes/k8s.io/kubernetes/pkg/api/endpoints/testing/make.go#L53

In particular, the prefix http://localhost:12345/something/ would be an endpoint served by a local gopls instance, and visiting that URL would cause gopls to send a showDocument request to the user's editor to open the named file and line. In this way, the pkgsite browser pane and the user's editor can link to each other, enabling a lightweight interactive process for reviewing API documentation even as the files are being edited.

(A related feature request would be the ability to specify "overlays" of unsaved editor buffers that pkgsite would use instead of the file system, but I suspect that's rather harder. It would allow even unsaved doc edits to be previewed.)

@gopherbot gopherbot added this to the Unreleased milestone Oct 5, 2023
@adonovan
Copy link
Member Author

adonovan commented Oct 6, 2023

Having inspected the pkgsite code a little, I think the cleanest seam would be for the Server.InstallFS operation to install an alternative handler when the -files_redirect=http://localhost:12345/something flag is set, and this handler would issue an HTTP redirect to "http://localhost:12345/something" + req.URL.Path. That way all the places that construct /files URLs can be left unchanged, and just the endpoint that handles them will differ.

@hyangah hyangah modified the milestones: Unreleased, pkgsite/backlog Oct 26, 2023
@adonovan
Copy link
Member Author

I think it will be simpler overall for gopls to implement its own rendering. Code sharing would be complex for both parties, and the total amount of code gopls requires is really not very much. Having its own implementation will make it easier to evolve, for example to include type-derived information, which is of course not available to pkgsite.

Retracting this feature request.

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

No branches or pull requests

4 participants