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

[src] view shows lines first and then the code. #264

Closed
AlexEne opened this Issue Nov 20, 2018 · 13 comments

Comments

Projects
None yet
4 participants
@AlexEne
Copy link

AlexEne commented Nov 20, 2018

Clicking on the [src] link for any repo shows you first the line numbers and then the source code.

For example here: https://docs.rs/spirv-reflect/0.1.2/src/spirv_reflect/lib.rs.html#1-601

I get this on Firefox 63.0.3:

image

@QuietMisdreavus

This comment has been minimized.

Copy link
Member

QuietMisdreavus commented Nov 20, 2018

This is an upstream rustdoc bug that should have been fixed by rust-lang/rust#55493, so i'm surprised it showed up on the nightly that rendered these docs (rustc 1.32.0-nightly (6b9b97bd9 2018-11-15)). I'm confident that upstream docs weren't having this problem on that nightly - is there some other interaction that's going on? @GuillaumeGomez, is there a way to find out?

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

GuillaumeGomez commented Nov 20, 2018

It comes from my add of line numbers and it has been fixed already in rust-lang/rust#55858.

@hellow554

This comment has been minimized.

Copy link

hellow554 commented Nov 26, 2018

Is it possible that the documentation will be rebuilt that has been generated in that date region?

@QuietMisdreavus

This comment has been minimized.

Copy link
Member

QuietMisdreavus commented Nov 30, 2018

It's not fixed, though. I just updated the nightly used to build crates to 1.32.0-nightly (3e90a12a8 2018-11-29) and it still exhibits this issue. It's possible for us to rebuild these crates, but i'd wait until we've properly fixed the issue for docs.rs first.

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

GuillaumeGomez commented Dec 1, 2018

It is fixed as far as I can tell. For instance: https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#294-296 (but maybe it requires to update to a more recent rustdoc version?)

@QuietMisdreavus

This comment has been minimized.

Copy link
Member

QuietMisdreavus commented Dec 1, 2018

@GuillaumeGomez It's still broken on docs.rs though. I rebuilt the crate mentioned in the issue description with the rustdoc i just mentioned, and it still shows the problem - click the link and see for yourself.

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

GuillaumeGomez commented Dec 1, 2018

A few things are different in the style apparently:

+ body:not(.source) .example-wrap>pre.rust {
+     width: 100%;
+ }

+ body:not(.source) .example-wrap {
+     display: inline-flex;
+ }
@QuietMisdreavus

This comment has been minimized.

Copy link
Member

QuietMisdreavus commented Dec 1, 2018

I don't see that difference? I just compared with https://docs.rs/spirv-reflect/0.1.2/rustdoc-20181129-1.32.0-nightly-3e90a12a8.css with https://github.com/rust-lang/rust/blob/d09466ceb1374bd0ff1c490bfd50133b8ca67558/src/librustdoc/html/static/rustdoc.css (after trying to un-minimize the former) and i don't see any significant differences between them.

@QuietMisdreavus

This comment has been minimized.

Copy link
Member

QuietMisdreavus commented Dec 1, 2018

Looking further, it seems like the problem is in that CSS selector, body:not(.source), since that affects this behavior. On docs.rs, the <body> tag doesn't get any of the classes that rustdoc sets for it, since it needs to wrap it to insert the navigation bar. Instead, the site content is in a top-level <div class="rustdoc container-rustdoc">. Because the CSS is looking for classes on the <body> tag, that won't work on docs.rs. I'm not sure the best way to approach it, but changing the way those selectors apply will fix the CSS for docs.rs.

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

GuillaumeGomez commented Dec 1, 2018

I looked at 0.1.6 version. And by updating the CSS (by removing the 2 rules that shouldn't be there), it worked as expected.

@QuietMisdreavus

This comment has been minimized.

Copy link
Member

QuietMisdreavus commented Dec 1, 2018

You mean these rules that are also in nightly? Is there a PR on rust-lang/rust that fixes that?

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

GuillaumeGomez commented Dec 1, 2018

This PR added those rules. But it was supposed to fix this very issue. How weird...

@QuietMisdreavus

This comment has been minimized.

Copy link
Member

QuietMisdreavus commented Dec 1, 2018

We talked about it on Discord:

  • The CSS on upstream rustdoc's side was too restrictive, so rust-lang/rust#56416 was opened to allow it to work with the way docs.rs structures its docs pages.
  • However, docs.rs doesn't actually save the CSS classes that rustdoc applies to the <body> tag, so this won't even work until we fix that. If we change the HTML extraction code to also grab the classes off the body tag, then add them to the rustdoc template in the rustdoc-container div, it will start adding the source class to the tree that the new CSS rules will use. (The HTML extraction is called here and inserted into the template, so that's where the body classes would also have to be captured.)

I'm planning to work on the latter later today, but if i don't get to it then that's at least what i think the solution should be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment