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: docs not shown for functions with language version build tags #68932

Closed
destel opened this issue Aug 18, 2024 · 11 comments
Closed

x/pkgsite: docs not shown for functions with language version build tags #68932

destel opened this issue Aug 18, 2024 · 11 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. pkgsite
Milestone

Comments

@destel
Copy link

destel commented Aug 18, 2024

What is the URL of the page with the issue?

https://pkg.go.dev/github.com/destel/rill@v0.4.0#pkg-functions

What is your user agent?

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36

Screenshot

No response

What did you do?

I updated my Go library to include new functions that use Go 1.23 features (iterators), while maintaining compatibility with Go 1.20. So, I put several functions into a separate file and added a build constraint to that file.

So, my setup is:

  • go.mod is 1.20
  • file iter.go has //go:build go1.23
  • other files do not have build constraints

What did you see happen?

  • There is no documentation for the functions from iter.go file on https://pkg.go.dev
  • At the same time, when I run pkgsite locally it correctly shows documentation for all functions

What did you expect to see?

Expected to see documentation for all functions from all files

@destel destel added the pkgsite label Aug 18, 2024
@gopherbot gopherbot added this to the Unreleased milestone Aug 18, 2024
@seankhliao seankhliao changed the title x/pkgsite: Go 1.23 conditional compilation: New functions not showing on pkg.go.dev x/pkgsite: docs not shown for functions with language version build tags Aug 19, 2024
@codyoss
Copy link
Member

codyoss commented Aug 20, 2024

Just to inline some comments I had filed in a separate, now closed issue:

I expect users of the library to be able to see docs for all Go versions or have the ability to select a Go version to see the docs of.

As a library maintainer it is important to me to maintain broad support for versions of Go. But it is also important for me to be able to implement and share new language features like iterator support gated by build tags.

For standard library packages it seems you can see all supported symbols, and it even lets you know when things were added. Example: https://pkg.go.dev/net/http#Request.PathValue

@ansaba
Copy link

ansaba commented Aug 22, 2024

cc: @jba

@ansaba ansaba added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 22, 2024
@jba
Copy link
Contributor

jba commented Aug 22, 2024

Unfortunately it's too expensive for pkgsite to generate docs for files with build tags. We do handle a few GOOS/GOARCH configs, but that's it. In general the number of possibilities is exponential so it's infeasible.
Maybe we should handle language version tags.
On the other hand, since pkgsite stores the source in the background and generates docs on the fly, we probably could support this if we stored all the source.

@codyoss
Copy link
Member

codyoss commented Aug 22, 2024

Yeah, I could see how general build tags could be problematic. My personal ask here would just be for language versions. And/Or docs assume the latest go version to show all possible methods?!

@destel
Copy link
Author

destel commented Aug 22, 2024

@jba, thank you for the response.

Is there an official way to have some functions of a library to be Go 1.23+ only, while being properly documented. Maybe not build tags, but something else?

Another thing that's not clear to me: when I run pkgsite on my machine, it properly shows docs for all functions regardless of build tags.

@destel
Copy link
Author

destel commented Aug 22, 2024

Also, It seems I've noticed a potentially relevant change:
golang/pkgsite@a03e71d

This 2-days-old commit seems to upgrade the Go version from 1.22 to 1.23. I'm not sure if it's related to the issue we're discussing, but I thought it might be worth mentioning. For context, I encountered a documentation issue 4 days ago.

I'm not familiar with pkgsite's source code yet, so I'm just speculating.

@jba
Copy link
Contributor

jba commented Aug 22, 2024

You're right, the upgrade to 1.23 would result in the new functions being shown. I just had to reprocess your existing module and now you can see them: https://pkg.go.dev/github.com/destel/rill@v0.4.0. Anything you publish in the future will have 1.23 symbols too.

That is also why it shows them on your machine: you are running go 1.23.

Obviously this is not the complete solution that @codyoss and others would like, where you can, say, select a Go version from a dropdown and see the symbols defined for that version. That could be filed as a feature request, but to be honest, I don't see it happening any time soon because it's a relatively rare request and would require a fair amount of work on both the frontend and backend.

I'm going to close this, since it's a bug report and the "bug" is fixed.

@jba jba closed this as completed Aug 22, 2024
@destel
Copy link
Author

destel commented Aug 22, 2024

@jba Thank you very much.
Is it also possible to delete two versions of my lib from pkg.go.dev?
v0.4.1-debug1 - I created it in an attempt to fix the issue with go.mod changes
v0.1.1-debug1 - older debug version from the times when I didn't know there was no simple way to delete versions

@jba
Copy link
Contributor

jba commented Aug 23, 2024

We can't remove individual versions, only entire module paths.
The best you can do is retract them. We then display that on the doc page:
image

and on the versions list:

image

@destel
Copy link
Author

destel commented Aug 23, 2024

Thank you. I'll try that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. pkgsite
Projects
None yet
Development

No branches or pull requests

6 participants