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

Highlight crate links like normal links #75842

Merged
merged 1 commit into from
Aug 27, 2020

Conversation

camelid
Copy link
Member

@camelid camelid commented Aug 23, 2020

Fixes #75823.

Cc @jyn514

@rust-highfive
Copy link
Collaborator

r? @ollie27

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 23, 2020
@camelid
Copy link
Member Author

camelid commented Aug 23, 2020

@rustbot modify labels: T-rustdoc

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Aug 23, 2020
@camelid
Copy link
Member Author

camelid commented Aug 23, 2020

I'm waiting on a rustc build to see if this works - for some reason it's rebuilding LLVM... :(

@camelid
Copy link
Member Author

camelid commented Aug 23, 2020

Fixed formatting

Comment on lines -1069 to +1073
format!("<li><a href=\"{}index.html\">{}</li>", ensure_trailing_slash(s), s)
format!(
"<li><a class=\"mod\" href=\"{}index.html\">{}</a></li>",
ensure_trailing_slash(s),
s
)
Copy link
Member Author

Choose a reason for hiding this comment

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

Using class mod should probably be temporary (I should probably be a separate class crate). However, the ul that this is in (starting on line 1065) already has class mod!

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a missing closing </a> tag also.

Copy link
Contributor

Choose a reason for hiding this comment

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

In the other link class="mod" was also added.

@camelid
Copy link
Member Author

camelid commented Aug 23, 2020

r? @jyn514

@rust-highfive rust-highfive assigned jyn514 and unassigned ollie27 Aug 23, 2020
@jyn514
Copy link
Member

jyn514 commented Aug 23, 2020

I think ollie might actually have been a better reviewer, I don't know this part of the code very well ... let's

r? @GuillaumeGomez

since he has so much free time ;)

@GuillaumeGomez
Copy link
Member

Looks good to me. Is there anything else to be done here?

since he has so much free time ;)

😝

@camelid
Copy link
Member Author

camelid commented Aug 23, 2020

I think I should add a new CSS class crate instead of using mod.

@camelid
Copy link
Member Author

camelid commented Aug 23, 2020

Actually, since we want the styles to be the same, it might be better to not add a separate class since it might get out of date if the module styles are updated.

@camelid camelid marked this pull request as ready for review August 23, 2020 20:29
@camelid
Copy link
Member Author

camelid commented Aug 23, 2020

I wasn't able to verify that the styling looks correct since I've been having some issues building the compiler (https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/ICE.20when.20compiling).

@camelid
Copy link
Member Author

camelid commented Aug 23, 2020

One final thing which is somewhat unrelated is that the title, description, and heading for the index page are all different:

let page = layout::Page {
title: "Index of crates",
css_class: "mod",
root_path: "./",
static_root_path: cx.shared.static_root_path.as_deref(),
description: "List of crates",
keywords: BASIC_KEYWORDS,
resource_suffix: &cx.shared.resource_suffix,
extra_scripts: &[],
static_extra_scripts: &[],
};

It might be good to consolidate them, but that could be done in a separate PR.

@@ -1066,7 +1066,11 @@ themePicker.onblur = handleThemeButtonsBlur;
krates
.iter()
.map(|s| {
format!("<li><a href=\"{}index.html\">{}</li>", ensure_trailing_slash(s), s)
format!(
"<li><a class=\"mod\" href=\"{}index.html\">{}</a></li>",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"<li><a class=\"mod\" href=\"{}index.html\">{}</a></li>",
"<li><a class='mod' href='{}index.html'>{}</a></li>",

Copy link
Member

Choose a reason for hiding this comment

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

We're using double quotes everywhere else, so for consistency, I think we should keep them.

Copy link
Contributor

@pickfire pickfire Aug 24, 2020

Choose a reason for hiding this comment

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

I saw that we also use single quotes for quite a lot of place too. From what I see, maybe more than double quotes.

Copy link
Member

@GuillaumeGomez GuillaumeGomez Aug 24, 2020

Choose a reason for hiding this comment

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

179 single quotes and 230 double quotes (looking for =' and =\"). I wonder how we ended up in this mess... We should clean that up.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just make all single quotes? We don't need to escape that way..

Copy link
Member

Choose a reason for hiding this comment

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

Had some cases where I saw:

<div onclick='func('clicked');'>...</div>

So mostly irrelevant here but still afraid me. Even more considering that for now, the generated UI isn't tested.

Copy link
Contributor

Choose a reason for hiding this comment

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

We could change that to

<div onclick="func('clicked');">...</div>

Copy link
Member

Choose a reason for hiding this comment

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

Or to:

<div onclick='func("clicked");'>...</div>

😛

@camelid
Copy link
Member Author

camelid commented Aug 26, 2020

@GuillaumeGomez I think this PR is ready. Do you want to merge? @pickfire or someone else could do a follow-up PR to make the quote character consistent in this file if that's what's decided upon.

@jyn514
Copy link
Member

jyn514 commented Aug 26, 2020

I think this PR is ready.
I'm waiting on a rustc build to see if this works - for some reason it's rebuilding LLVM... :(

Can you post a screenshot of what this now looks like?

@GuillaumeGomez
Copy link
Member

Yes, just a screenshot before/after and then I think we're good to go!

@camelid
Copy link
Member Author

camelid commented Aug 26, 2020

Still waiting on my build :)

The before is at https://doc.rust-lang.org/nightly/nightly-rustc:

image

@camelid
Copy link
Member Author

camelid commented Aug 26, 2020

Wow, my build is taking forever. I just stopped and started it in case that’s the issue. ./x.py doc --stage 1 is the command to use, right?

@jyn514
Copy link
Member

jyn514 commented Aug 26, 2020

Wow, my build is taking forever. I just stopped and started it in case that’s the issue. ./x.py doc --stage 1 is the command to use, right?

Yes, that sounds right. Try running with -j1 if you aren't already, you might be thrashing memory to disk and back. It takes me about an hour on my laptop with -j1.

@camelid
Copy link
Member Author

camelid commented Aug 26, 2020

I have several gigabytes of free memory though, so would that still help?

@jyn514
Copy link
Member

jyn514 commented Aug 27, 2020

Looks good to me!
image

@bors r+

@bors
Copy link
Contributor

bors commented Aug 27, 2020

📌 Commit 4419e04 has been approved by jyn514

@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 Aug 27, 2020
@camelid
Copy link
Member Author

camelid commented Aug 27, 2020

Never could get my build to finish :(

@bors
Copy link
Contributor

bors commented Aug 27, 2020

⌛ Testing commit 4419e04 with merge 18b0585...

@bors
Copy link
Contributor

bors commented Aug 27, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: jyn514
Pushing 18b0585 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 27, 2020
@bors bors merged commit 18b0585 into rust-lang:master Aug 27, 2020
@GuillaumeGomez
Copy link
Member

@camelid In case you want to retry to build doc locally: x.py doc library/std --stage 1 --jobs 2 (--jobs 2 is just to prevent your computer to burn too much haha). Then it's generated in build/[your arch]/doc/std/index.html.

@camelid
Copy link
Member Author

camelid commented Aug 30, 2020

@GuillaumeGomez Thanks, I'll try that!

@camelid camelid deleted the highlight-crate-links branch August 30, 2020 00:54
@camelid
Copy link
Member Author

camelid commented Aug 30, 2020

The build completed successfully, but that index page is not the crate index, so it is not affected by this PR. I think I have to document the compiler to get the right page.

@jyn514
Copy link
Member

jyn514 commented Aug 30, 2020

@camelid try compiler-docs = true in config.toml

@camelid
Copy link
Member Author

camelid commented Aug 30, 2020

@jyn514 I'm curious: is there a reason that is not the default?

@jyn514
Copy link
Member

jyn514 commented Aug 30, 2020

Not sure, sorry. You could ask on zulip.

My guess though is that most of the compiler docs are maintained out of tree at rustc-dev-guide.rust-lang.org so people don't look at the API docs as much? I use the online ones a lot though.

bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 17, 2020
Use double quote for rustdoc html

r? `@GuillaumeGomez`

Feels scary without escaping stuff when I looked at the code, probably susceptible to XSS.
Follow up of rust-lang#75842
@cuviper cuviper added this to the 1.48.0 milestone Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

Highlight crate links as normal links with --enable-index-page
9 participants