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: possible change in how example links work #48707

Open
ianlancetaylor opened this issue Sep 30, 2021 · 2 comments
Open

x/pkgsite: possible change in how example links work #48707

ianlancetaylor opened this issue Sep 30, 2021 · 2 comments

Comments

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Sep 30, 2021

https://golang.org/cl/353391 points out that a link in Effective Go () does not work. The link is https://golang.org/pkg/strings/#example_Map. That link currently just goes to the docs for the strings package. If we change the underscore to a hyphen (https://golang.org/pkg/strings/#example-Map) then it links to the example.

The link has been there since 2013 (added in https://golang.org/cl/7454044) and it seems to me unlkely that nobody ever checked that the link worked. While I can't prove it, it seems much more likely that this broke when golang.org was moved over to pkg.go.dev.

It seems to me that we should make the underscore links work for examples, unless there is some good reason not to. Thanks.

@ianlancetaylor ianlancetaylor added this to the Unreleased milestone Sep 30, 2021
@jba jba changed the title pkg.go.dev: possible change in how example links work x/pkgsite: possible change in how example links work Sep 30, 2021
@jba jba self-assigned this Sep 30, 2021
@dmitshur
Copy link
Contributor

@dmitshur dmitshur commented Sep 30, 2021

The old golang.org/pkg/ documentation server indeed used anchors for examples that don't exactly match those on pkg.go.dev. When pkg.go.dev was in its early development stages in 2019, since it was a new and different website, it was used as an opportunity to adjust the scheme for example anchors be slightly cleaner looking. For example, a package-scoped example named TextMarshalJSON used to be #example__textMarshalJSON, but it became #example-package-TextMarshalJSON on pkg.go.dev.

Unfortunately, when golang.org/pkg/ started to redirect to pkg.go.dev, any old links to golang.org/pkg/ that happen to include example anchors would no longer highlight the target example. Not unless the old anchors are converted or otherwise handled.

@rsc
Copy link
Contributor

@rsc rsc commented Oct 4, 2021

It's certainly possible to put in dummy <span id="foo"></span> tags to keep old links working. I think we should try to do that, if it's not too hard. The code generating the old ids must be easy to grab.

@jamalc jamalc removed this from the Unreleased milestone Oct 4, 2021
@jamalc jamalc added this to the pkgsite/unplanned milestone Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants