-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
1c05711
to
8677281
Compare
This comment has been minimized.
This comment has been minimized.
src/librustdoc/html/markdown.rs
Outdated
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. |
There was a problem hiding this comment.
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
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? |
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. |
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. |
See #43466 (comment) for status on that, it's currently waiting on #74195. |
Ping from triage. What's the current status? Is this blocked on #74430? |
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. |
Oh oops I didn't realized you linked to two different PRs. I'll try and work on #74489 sometime this weekend. |
This comment has been minimized.
This comment has been minimized.
8677281
to
184772e
Compare
cf63b25
to
6498e63
Compare
This is ready for another look. I put in a FIXME in linkcheck for the links that need #73829 to work. |
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') { |
There was a problem hiding this comment.
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(); | ||
} |
There was a problem hiding this comment.
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
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! |
@GuillaumeGomez What's the expected behavior?
is rendered as a paragraph, not a code block. There's nothing special about trait methods here. |
@euclio It should be a codeblock. :o |
My point is that
isn't rendered as a code block either. |
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. |
It's the same output with 4 and 5 spaces. I disagree that it's a bug, seems like expected behavior from the |
No, it's a bug for me: we can't transform a codeblock into text just like that. |
@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. |
Unless I misunderstood, it's part of |
No, it's a separate pass. rust/src/librustdoc/passes/mod.rs Line 98 in b543afc
|
Then I'm just confused. Apart from this, no issue for me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
📌 Commit 98232ec has been approved by |
☀️ Test successful - checks-actions, checks-azure |
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!