-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Add source file sidebar #55707
Add source file sidebar #55707
Conversation
d57ec78
to
6dfde9f
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
6dfde9f
to
400180c
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
0c54b8b
to
3bba941
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much! This looks really great.
Some observations based on poking around with a local build:
-
That the sources sidebar is on the right is a little surprising - the sidebar is on the left on all the other pages we generate. Same for the folding nature of it - this is the first time it's appeared in our docs like that.
-
The sidebar is a little awkward on mobile - it doesn't have its own scrolling container, so the listing and the fold toggle are stuck on the top of the page - but the source pages themselves were awkward on mobile already, so that's not a blocking issue.
-
The fold toggle sometimes "hides" behind the scrollbar for me (Chrome, Windows 7) - it's visible, but not clickable until you refresh the page.
-
The fold/unfold animation of the sidebar feels slow. We don't use animations like that for any of our other folding containers, so this one could afford to be much faster, or not animated in the first place.
-
It seems weird to me that the source files list is loaded dynamically, but i think i'm okay with it, since it can allow all crates that were documented at the same time to have their source all together, regardless of the order they're documented in.
-
The listing of files seems to have an unexpected auto-fold behavior: it looks like if a listing has a subdirectory, it will start unfolded? The following screenshot was taken from
core/lib.rs
, andstd
is already open with this surprising layout: -
Can you write a test? There's a
search-index.rs
test that does substring searches to make sure that certain items are present or missing from the index. -
I feel like we shouldn't touch
source-index.js
if#![doc(html_no_source)]
is set. You can checkcx.shared.include_sources
to see whether we should handle source pages for the current crate.
Updated!
Seemed better to me on the right but I've put it back to the left.
I didn't do much for mobile on sources yet. I intend to once this PR is merged.
Since it's now on the left, no problem anymore.
It's now two times faster. I really like the animation though. :D
Either we load it dynamically or we have to generate a lot of HTML in all source files which are already quite big. And also, it allows to just add other crates. :)
It was a bug. Should be fixed now.
I'm not sure such a test would be useful. If a file is missing, it means we're not supposed to have access to it.
You're absolutely right. I updated the code so it's not generated in such cases. |
I'm a fan of having tests for basic operations like this. We can just have something to make sure that this file is generated in a way that we expect. We're creating new functionality here, and i want to make sure we don't accidentally break something later and not catch it because there wasn't a test. (Something like this has happened in rustdoc already -
Thanks, this looks much nicer! Also, now that the sidebar is on the left, can it start closed? It covers up some source when it's open (which is probably why you had it on the right to begin with), so starting it closed will make it unobtrusive. (This probably means getting rid of the local-storage item and just always being closed on page load.) |
7d4304e
to
1b432a6
Compare
Added test and the source file sidebar is now collapsed by default. |
Pinging from triage @QuietMisdreavus you need to review this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's still a problem with how the "extra scripts" get loaded in with a resource suffix.
44a89ac
to
82a7b6f
Compare
With all these changes, this looks good! r=me when travis is green. |
@bors r+ |
📌 Commit 82a7b6f has been approved by |
/// Files related to the sidebar in rustdoc sources. | ||
pub mod sidebar { | ||
/// File script to handle sidebar. | ||
pub static SOURCE_SCRIPT: &'static str = include_str!("static/source-script.js"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: When this merges, make sure docs.rs also starts caching source-script.js
.
Add source file sidebar This is just a start currently but that gives a good overview of what it'll look like: <img width="1440" alt="screenshot 2018-11-06 at 01 39 15" src="https://user-images.githubusercontent.com/3050060/48035592-05336180-e165-11e8-82e1-5ead0c345eb9.png"> r? @QuietMisdreavus
☀️ Test successful - status-appveyor, status-travis |
This is just a start currently but that gives a good overview of what it'll look like:
r? @QuietMisdreavus