Skip to content

Playpen links from code snippets on doc.rust-lang.org contain wrong code #20732

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

Closed
Valloric opened this issue Jan 8, 2015 · 2 comments
Closed
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Valloric
Copy link
Contributor

Valloric commented Jan 8, 2015

For example, the code snippet for std::str::StrExt::split shows an arrow in the top-right when hovered over with the mouse. The arrow is a link to the following page with suspicious muffin-related content. This seems to be the snippet for the std::str::StrExt::replace function (which is also the first function on the page with example code). All other code snippets on the page lead to the same muffin code.

This is on Chrome 39.0.2171.95 (64-bit) on Mac OS X 10.10.1.

muffins

@estsauver
Copy link
Contributor

It looks like this is caused by rustdoc rendering all of the examples with the same id.

If you look at the playpen js code in rustdoc: https://github.com/rust-lang/rust/blob/5b3cd3900ceda838f5798c30ab96ceb41f962534/src/librustdoc/html/static/playpen.js

you see that it depends on all the same ids being different. However, if you look at the source of the StrExt example you linked, you see they all have "rust-example-rendered-0" as the id.

I think the error comes from somewhere in here,

https://github.com/rust-lang/rust/blob/master/src/librustdoc/html/markdown.rs#L196

but it's not obvious to me how to fix it. I'll look into the issue, but this is my first little bit of work on rust so it may take a second/I'd appreciate insight as to what the problem might be.

@kmcallister kmcallister added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jan 8, 2015
@Gankra
Copy link
Contributor

Gankra commented Jan 12, 2015

nominating for I-muffins

bors added a commit that referenced this issue Jan 15, 2015
In #20732, that all links in some modules point to the same code
examples was reported. The ID's generated for documents in
librustdoc are not all unique, which means the code rendered as
text is not being properly selected.

This change makes the link to the code section that is next to
the current link.
@bors bors closed this as completed in 2a320f2 Jan 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants