Skip to content

Highlight crate links like normal links - #75842

Merged
bors merged 1 commit into
rust-lang:masterfrom
camelid:highlight-crate-links
Aug 27, 2020
Merged

Highlight crate links like normal links#75842
bors merged 1 commit into
rust-lang:masterfrom
camelid:highlight-crate-links

Conversation

@camelid

Copy link
Copy Markdown
Member

Fixes#75823.

Cc @jyn514

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @ollie27

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

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

Copy link
Copy Markdown
MemberAuthor

@rustbot modify labels: T-rustdoc

@rustbotrustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Aug 23, 2020
Comment threadsrc/librustdoc/html/render/mod.rs Outdated
@camelid

Copy link
Copy Markdown
MemberAuthor

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

@camelid
camelidforce-pushed the highlight-crate-links branch from 85482a6 to 4419e04CompareAugust 23, 2020 17:24
@camelid

Copy link
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
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
Copy Markdown
MemberAuthor

r? @jyn514

@rust-highfiverust-highfive assigned jyn514 and unassigned ollie27Aug 23, 2020
@jyn514

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

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

since he has so much free time ;)

😝

@camelid

Copy link
Copy Markdown
MemberAuthor

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

@camelid

Copy link
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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

camelid commented Aug 23, 2020

Copy link
Copy Markdown
MemberAuthor

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.

.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
Copy Markdown
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
Copy Markdown
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.

@pickfirepickfireAug 24, 2020

Copy link
Copy Markdown
Contributor

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.

@GuillaumeGomezGuillaumeGomezAug 24, 2020

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
MemberAuthor

@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
Copy Markdown
Member

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
Copy Markdown
Member

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

@camelid

Copy link
Copy Markdown
MemberAuthor

Still waiting on my build :)

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

image

@camelid

Copy link
Copy Markdown
MemberAuthor

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
Copy Markdown
Member

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
Copy Markdown
MemberAuthor

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

@jyn514

Copy link
Copy Markdown
Member

Looks good to me!
image

@bors r+

@bors

bors commented Aug 27, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit 4419e04 has been approved by jyn514

@borsbors 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
Copy Markdown
MemberAuthor

Never could get my build to finish :(

@bors

bors commented Aug 27, 2020

Copy link
Copy Markdown
Collaborator

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

@bors

bors commented Aug 27, 2020

Copy link
Copy Markdown
Collaborator

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

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

Copy link
Copy Markdown
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
Copy Markdown
MemberAuthor

@GuillaumeGomez Thanks, I'll try that!

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

Copy link
Copy Markdown
MemberAuthor

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
Copy Markdown
Member

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

@camelid

Copy link
Copy Markdown
MemberAuthor

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

@jyn514

Copy link
Copy Markdown
Member

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
@cuvipercuviper added this to the 1.48.0 milestone Nov 17, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-borsThis PR was explicitly merged by bors.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-rustdocRelevant 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

@camelid@rust-highfive@jyn514@GuillaumeGomez@bors@pickfire@cuviper@ollie27@rustbot