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

rustdoc: do not use plain summary for trait impls #73819

Merged
merged 2 commits into from
Sep 3, 2020

Conversation

euclio
Copy link
Contributor

@euclio euclio commented Jun 27, 2020

Fixes #38386.
Fixes #48332.
Fixes #49430.
Fixes #62741.
Fixes #73474.

Unfortunately this is not quite ready to go because the newly-working links trigger a bunch of linkcheck failures. The failures are tough to fix because the links are resolved relative to the implementor, which could be anywhere in the module hierarchy.

(In the current docs, these links end up rendering as uninterpreted markdown syntax, so I don't think these failures are any worse than the status quo. It might be acceptable to just add them to the linkchecker whitelist.)

Ideally this could be fixed with intra-doc links but it isn't working for me: I am currently investigating if it's possible to solve it this way. Opened #73829.

EDIT: This is now ready!

@rust-highfive
Copy link
Collaborator

r? @steveklabnik

(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 Jun 27, 2020
@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

Some(String::new())
let mut s = String::with_capacity(md.len() * 3 / 2);

// FIXME: This doesn't handle intra-doc links: "[`std::io::Error`]" will go through unchanged.
Copy link
Member

Choose a reason for hiding this comment

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

You shouldn't need to handle them here, they're handled in a separate pass. See for example the links on https://docs.rs/rand/0.7.3/rand/#traits

@GuillaumeGomez
Copy link
Member

As far as I remember, the intra-links are currently not resolved in all shorten doc comments. As long as you don't change the current behavior, I think it's fine to fix it in another PR?

@euclio
Copy link
Contributor Author

euclio commented Jul 9, 2020

The problem is that linkcheck will break for basically anything that implements a trait with a link in the description, because there's no way to write a link that will work for all locations without intra-doc links.

@GuillaumeGomez
Copy link
Member

Absolutely, that needs to be added and there is an issue open for this missing part. I started to take a look at it but some parts in intra-doc links were missing. Once @jyn514's big PR is merged, we'll be able to go back into it.

@jyn514
Copy link
Member

jyn514 commented Jul 9, 2020

Once @jyn514's big PR is merged, we'll be able to go back into it.

See #43466 (comment) for status on that, it's currently waiting on #74195.

@crlf0710 crlf0710 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 Jul 24, 2020
@crlf0710
Copy link
Member

Ping from triage. What's the current status? Is this blocked on #74430?

@euclio
Copy link
Contributor Author

euclio commented Jul 24, 2020

Blocked on #74489. Planning to add linkcheck exceptions for links that can't be resolved due to #73829.

@jyn514
Copy link
Member

jyn514 commented Jul 24, 2020

I'm not sure I follow. Why do intra-doc links need to be stabilized for this to work? The relevant bugs in intra-doc links have been fixed, except for #73829.

@jyn514
Copy link
Member

jyn514 commented Jul 24, 2020

Oh oops I didn't realized you linked to two different PRs. I'll try and work on #74489 sometime this weekend.

@jyn514 jyn514 added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 24, 2020
@bors

This comment has been minimized.

@euclio euclio changed the title [WIP] rustdoc: do not use plain summary for trait impls rustdoc: do not use plain summary for trait impls Aug 25, 2020
@euclio euclio force-pushed the rustdoc-summaries branch 2 times, most recently from cf63b25 to 6498e63 Compare August 25, 2020 22:42
@euclio
Copy link
Contributor Author

euclio commented Aug 25, 2020

This is ready for another look. I put in a FIXME in linkcheck for the links that need #73829 to work.

@jyn514
Copy link
Member

jyn514 commented Aug 25, 2020

A lot of the links you changed were also changed in #75832, #75852, and #75853. So you may want to wait until some of those land.

@ollie27
Copy link
Member

ollie27 commented Aug 26, 2020

How about we filter out all links in short summaries when used for trait impls?

render_markdown(w, cx, &markdown, item.links(), prefix, is_hidden);
let mut summary_html = MarkdownSummaryLine(s, &item.links()).into_string();

if s.contains('\n') {
Copy link
Member

Choose a reason for hiding this comment

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

Does it take into account when you only have an indented code block like:

///    hello

?


/// Escaped formatting a\*b\*c\* works
fn d();
}
Copy link
Member

Choose a reason for hiding this comment

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

Please add a test with indented codeblock like this:

///    hello

@GuillaumeGomez
Copy link
Member

Just one doubt about the indented codeblock but otherwise sounds good. Once the indented codeblock test has been added, it'll be good to go for me!

@euclio
Copy link
Contributor Author

euclio commented Sep 2, 2020

@GuillaumeGomez What's the expected behavior? unindent-comments trims the leading spaces so that

///    hello

is rendered as a paragraph, not a code block. There's nothing special about trait methods here.

@GuillaumeGomez
Copy link
Member

@euclio It should be a codeblock. :o

@euclio
Copy link
Contributor Author

euclio commented Sep 2, 2020

My point is that

///    hello
pub struct Foo;

isn't rendered as a code block either.

@GuillaumeGomez
Copy link
Member

Ah, I might have forgotten a whitespace. Codeblocks are 4 whitespaces, but with rustdoc we have to add a fifth one. Try again with 5. :)

Normally, it should render as a codeblock (it does with the commonmark spec), if not, we have a bug to report.

@euclio
Copy link
Contributor Author

euclio commented Sep 2, 2020

It's the same output with 4 and 5 spaces. I disagree that it's a bug, seems like expected behavior from the unindent-comments pass.

@GuillaumeGomez
Copy link
Member

No, it's a bug for me: we can't transform a codeblock into text just like that.

@jyn514
Copy link
Member

jyn514 commented Sep 3, 2020

@GuillaumeGomez you haven't answered the question. This is done for all items - what's special about trait methods that they shouldn't be counted? Why is unindenting relevant to this PR? If you think rustdoc shouldn't be doing it in general, that seems like it should be a separate fix.

@GuillaumeGomez
Copy link
Member

Unless I misunderstood, it's part of plain_text_summary, no?

@jyn514
Copy link
Member

jyn514 commented Sep 3, 2020

No, it's a separate pass.

ConditionalPass::always(UNINDENT_COMMENTS),

@GuillaumeGomez
Copy link
Member

Then I'm just confused. Apart from this, no issue for me.

Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

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

LGTM

@GuillaumeGomez
Copy link
Member

Thanks @euclio !

@bors: r=jyn514,GuillaumeGomez

@bors
Copy link
Contributor

bors commented Sep 3, 2020

📌 Commit 98232ec has been approved by jyn514,GuillaumeGomez

@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 Sep 3, 2020
@bors
Copy link
Contributor

bors commented Sep 3, 2020

⌛ Testing commit 98232ec with merge 62dad45...

@bors
Copy link
Contributor

bors commented Sep 3, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: jyn514,GuillaumeGomez
Pushing 62dad45 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 3, 2020
@bors bors merged commit 62dad45 into rust-lang:master Sep 3, 2020
@euclio euclio deleted the rustdoc-summaries branch September 4, 2020 00:13
@cuviper cuviper added this to the 1.48.0 milestone May 2, 2024
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
9 participants