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 CLI option to setup favicon #60002

Closed
wants to merge 1 commit into from

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 15, 2019
@jonas-schievink jonas-schievink added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Apr 15, 2019
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of 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.
travis_time:end:0d6903a4:start=1555367122540220872,finish=1555367213255050419,duration=90714829547
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
travis_time:start:test_assembly
Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:14:44] 
[01:14:44] running 9 tests
[01:14:44] iiiiiiiii
[01:14:44] 
[01:14:44]  finished in 0.161
[01:14:44] travis_fold:end:test_assembly

---
travis_time:start:test_debuginfo
Check compiletest suite=debuginfo mode=debuginfo-both (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:15:01] 
[01:15:01] running 121 tests
[01:15:30] .iiiii...i.....i..i...i..i.i.i..i.ii...i.....i..i....i..........iiii..........i...ii...i.......ii.i. 100/121
[01:15:35] i.i......iii.i.....ii
[01:15:35] 
[01:15:35]  finished in 34.288
[01:15:35] travis_fold:end:test_debuginfo

---
travis_time:start:test_rustdoc
Check compiletest suite=rustdoc mode=rustdoc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:19:25] 
[01:19:25] running 305 tests
[01:20:40] ............................i......................F................................................ 100/305
[01:22:50] .................................................................................................... 300/305
[01:22:54] .....
[01:22:54] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:517:22
[01:22:54] failures:
[01:22:54] failures:
[01:22:54] 
[01:22:54] ---- [rustdoc] rustdoc/favicon-path.rs stdout ----
[01:22:54] 
[01:22:54] error: rustdoc failed!
[01:22:54] status: exit code: 1
[01:22:54] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc/favicon-path/auxiliary" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc/favicon-path" "/checkout/src/test/rustdoc/favicon-path.rs" "-Z" "unstable-options" "--favicon-path" "./src/librustdoc/html/static/favicon.ico"
[01:22:54] ------------------------------------------
[01:22:54] 
[01:22:54] ------------------------------------------
[01:22:54] stderr:
[01:22:54] stderr:
[01:22:54] ------------------------------------------
[01:22:54] error: option `--favicon-path` argument must be a file
[01:22:54] 
[01:22:54] ------------------------------------------
[01:22:54] 
[01:22:54] thread '[rustdoc] rustdoc/favicon-path.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3469:9
---
[01:22:54] test result: FAILED. 302 passed; 1 failed; 2 ignored; 0 measured; 0 filtered out
[01:22:54] 
[01:22:54] 
[01:22:54] 
[01:22:54] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--rustdoc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc" "--src-base" "/checkout/src/test/rustdoc" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "rustdoc" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:22:54] 
[01:22:54] 
[01:22:54] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:22:54] Build completed unsuccessfully in 0:20:43
[01:22:54] Build completed unsuccessfully in 0:20:43
[01:22:54] Makefile:48: recipe for target 'check' failed
[01:22:54] make: *** [check] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:25b83298
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Mon Apr 15 23:49:58 UTC 2019

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

@QuietMisdreavus: BTW, I wanted to ask: should I add the resource suffix in here as well? Also: should I keep the original filename?

Copy link
Member

@QuietMisdreavus QuietMisdreavus left a comment

Choose a reason for hiding this comment

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

This only kind of solves the problem that docs.rs is having. I have one suggestion for a better solution in the review comments, but here's one more: Instead of taking the plain string or a file path, why not have an option to disable the default favicon altogether? That way, we don't have to worry about paths at all.

(The question remains of what to do with #![doc(html_favicon_url)] in this situation, though. My instinct is to let the crate override the CLI, but then i feel like we'd have to provide an option to really really disable the favicon in that case. Something like --favicon default,no-default,disable? That way we could keep the custom favicon that crates like Rocket and Iron use.)

favicon = if layout.favicon_path.is_some() {
format!(r#"<link rel="shortcut icon" href="{static_root_path}{path}">"#,
static_root_path=static_root_path,
path=layout.favicon)
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem like a useful addition to the layout code. If we're going to use the favicon string and the static_root_path anyway, why not just update that path with the right path?

(If we make the favicon path a plain string instead of an actual file path, we can keep this distinction, though, as long as we make sure to not use static_root_path in that situation.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Because one generates a full path whereas the other generates a relative one.

let favicon = matches.opt_str("favicon-path").map(|s| PathBuf::from(&s));
if let Some(ref favicon) = favicon {
if !favicon.is_file() {
diag.struct_err("option `--favicon-path` argument must be a file").emit();
Copy link
Member

Choose a reason for hiding this comment

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

Since this change was suggested for docs.rs, i should note that this won't work over there. The favicon file isn't available to the docs.rs builder when it runs rustdoc (in fact it's not even in the repository), so it can't point to a filename for it to try to load.

What would be ideal is if we could take an arbitrary string here, which would then be pasted in for the favicon path, much like the #![doc(html_favicon_url)] attribute we're mimicking. That way docs.rs can pass "/favicon.ico" which would link to the correct favicon without having to make sure it can be loaded by the builder.

Copy link
Member Author

Choose a reason for hiding this comment

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

Huuuum... We have to differentiate two kind of paths: URL and locals. What do you want to do in both cases?

@@ -545,7 +546,10 @@ pub fn run(mut krate: clean::Crate,
issue_tracker_base_url: None,
layout: layout::Layout {
logo: String::new(),
favicon: String::new(),
favicon: favicon.as_ref()
.map(|_| format!("favicon-{}.ico", krate.name))
Copy link
Member

Choose a reason for hiding this comment

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

Modifying the favicon filename/URL in the doc output will not work for docs.rs, since it will break the caching that is already done for the /favicon.ico URL.

let s = s.to_string();
if scx.layout.favicon_path.is_some() {
if !s.is_empty() {
diag.struct_warn("`favicon-path` option has been passed, ignoring \
Copy link
Member

Choose a reason for hiding this comment

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

Since we're already iterating through libsyntax's attributes here, why not use its span in this warning?

@@ -0,0 +1,6 @@
// compile-flags:-Z unstable-options --favicon-path ./src/librustdoc/html/static/favicon.ico
Copy link
Member

Choose a reason for hiding this comment

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

Loading the file like this won't work on travis, since x.py is called from a different directory there - this path isn't valid.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, I'll just create or use another file. :)

@bors
Copy link
Contributor

bors commented May 13, 2019

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

@Dylan-DPC-zz Dylan-DPC-zz added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 27, 2019
@Dylan-DPC-zz
Copy link

ping from triage @GuillaumeGomez you need to address the changes requested in the review

@GuillaumeGomez
Copy link
Member Author

Indeed! I'll come back to it soon.

@Dylan-DPC-zz
Copy link

ping from triage @GuillaumeGomez any updates on this?

@GuillaumeGomez
Copy link
Member Author

Still need to come back to it. :)

@joelpalmer
Copy link

@rustbot modify labels to -S-waiting-on-author and +S-inactive-closed

Hi @GuillaumeGomez - ping from Triage, closing this due to inactivity. Please re-open before pushing changes. Thanks for the PR.

@rustbot rustbot added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add CLI argument to set favicon URL
8 participants