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

Add rustdoc settings menu #49954

Merged
merged 2 commits into from
Apr 22, 2018
Merged

Add rustdoc settings menu #49954

merged 2 commits into from
Apr 22, 2018

Conversation

GuillaumeGomez
Copy link
Member

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 13, 2018
@rust-highfive
Copy link
Collaborator

Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
Resolving deltas: 100% (614836/614836), completed with 4886 local objects.
---
[00:00:47] configure: rust.quiet-tests     := True
---
[00:05:20] tidy error: /checkout/src/librustdoc/html/static/settings.js: missing trailing newline
[00:05:21] some tidy checks failed
[00:05:21]
[00:05:21]
[00:05:21] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:05:21] expected success, got: exit code: 1
[00:05:21]
[00:05:21]
[00:05:21] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:05:21] Build completed unsuccessfully in 0:02:02
[00:05:21] make: *** [tidy] Error 1
[00:05:21] Makefile:79: recipe for target 'tidy' failed
---
$ find $HOME/Library/Logs/DiagnosticReports -type f -name '*.crash' -not -name '*.stage2-*.crash' -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; -exec head -750 {} \; -exec echo travis_fold":"end:crashlog \; || true
find: `/home/travis/Library/Logs/DiagnosticReports': No such file or directory
travis_time:end:13ee506e:start=1523653444149841583,finish=1523653444156873560,duration=7031977
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:03961c93
$ dmesg | grep -i kill
[   10.902289] init: failsafe main process (1092) killed by TERM signal

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 @TimNN. (Feature Requests)

@GuillaumeGomez
Copy link
Member Author

Ready it is!

@ollie27
Copy link
Member

ollie27 commented Apr 17, 2018

If settings.html is supposed to be a shared file then its contents should not depend on the crate that generated it so the output is deterministic when documenting multiple crates at the same time. Currently settings.html contains lines like:

<a href='./std_unicode/index.html'><img src='https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png' alt='logo' width='100'></a>

Perhaps it would be better for the settings to be in a drop-down menu like the themes instead of a separate file.

@QuietMisdreavus
Copy link
Member

Alternately, if it's going to be in a separate page, is it possible to put it into librustdoc/html/static/ somehow? Or perhaps using a new template so that the sidebar doesn't link to anything crate-specific?

On the other hand, when i ran it myself, the link gets changed to javascript:void at page load time. The sidebar also gets filled with the crate list, so at least there's a means to get back to regular documentation.

@bors
Copy link
Contributor

bors commented Apr 17, 2018

☔ The latest upstream changes (presumably #50033) made this pull request unmergeable. Please resolve the merge conflicts.

@ollie27
Copy link
Member

ollie27 commented Apr 17, 2018

Another option would be to use a pop-up like the help pop-up.

@GuillaumeGomez
Copy link
Member Author

@ollie27: Check out the changes, I remove the url on the logo. :)

@GuillaumeGomez
Copy link
Member Author

And I'd prefer to avoid adding even more JS than necessary. Settings is in its own page, with its own JS and everything is fine as is.

@ollie27
Copy link
Member

ollie27 commented Apr 17, 2018

The issue with removing the url with JS is that it doesn't help with bit-for-bit deterministic builds (#34902). Also the logo itself is crate specific, as is the favicon. How about not sharing settings.html and generating it once for each crate next to all.html?

@GuillaumeGomez
Copy link
Member Author

Because that's repeated data. I don't really see the issue in here, if the favicon is switched because the user changed it in one crate, then so be it?

@QuietMisdreavus
Copy link
Member

How about this: We can clone the Layout when generating the settings page, to remove the krate, and also tweak the layout to render the logo, but not the link, when there's a logo but no krate to link to. That way, the logo is present, the build is reproducible, and the settings page is still one file for the whole bundle.

@GuillaumeGomez
Copy link
Member Author

@QuietMisdreavus: Sounds like a good solution, I'll go for it then.

@GuillaumeGomez
Copy link
Member Author

@QuietMisdreavus: Done!

let sidebar = "<p class='location'>Settings</p><div class='sidebar-elems'>".to_owned();
themes.push(PathBuf::from("settings.css"));
let mut layout = self.shared.layout.clone();
layout.krate = String::new();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I've already said, the logo and favicon can also be different between crates. If you document two crates at the same time that have different logos, then which logo should the settings.html page use? I suggest setting the logo and favicon to an empty string here as well.

@@ -1590,6 +1642,27 @@ impl Context {
self.shared.css_file_extension.is_some(),
&self.shared.themes),
&final_file);

// If the file already exists, no need to generate it again...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be generated each time to pick up changes to rustdoc options that can affect it.


let mut w = BufWriter::new(try_err!(File::create(&settings_file), &settings_file));
let mut themes = self.shared.themes.clone();
let sidebar = "<p class='location'>Settings</p><div class='sidebar-elems'>".to_owned();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

</div> is missing. Also the .to_owned() isn't needed.

@GuillaumeGomez
Copy link
Member Author

Updated. Anything else you want me to change @ollie27 ?

Copy link
Member

@ollie27 ollie27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than that one unneeded change this looks good to me.

@@ -162,6 +162,8 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
css_class = page.css_class,
logo = if layout.logo.is_empty() {
"".to_string()
} else if layout.krate.is_empty() {
format!("<img src='{}' alt='logo' width='100'>", layout.logo)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is no longer needed now that the logo has been removed.

@GuillaumeGomez
Copy link
Member Author

Done as well!

@GuillaumeGomez
Copy link
Member Author

@bors: r=ollie27,QuietMisdreavus

@bors
Copy link
Contributor

bors commented Apr 22, 2018

📌 Commit 1f7892f has been approved by ollie27,QuietMisdreavus

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 22, 2018
@bors
Copy link
Contributor

bors commented Apr 22, 2018

⌛ Testing commit 1f7892f with merge 28193e8...

bors added a commit that referenced this pull request Apr 22, 2018
@bors
Copy link
Contributor

bors commented Apr 22, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: ollie27,QuietMisdreavus
Pushing 28193e8 to master...

@bors bors merged commit 1f7892f into rust-lang:master Apr 22, 2018
@GuillaumeGomez GuillaumeGomez deleted the doc-settings branch April 22, 2018 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants