-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Md warnings #46247
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
Md warnings #46247
Conversation
src/librustdoc/markdown.rs
Outdated
let orig_used_id_map = USED_ID_MAP.with(|map| map.borrow().clone()); | ||
let hoedown_output = format!("{}", MarkdownWithToc(text, RenderType::Hoedown)); | ||
USED_ID_MAP.with(|map| *map.borrow_mut() = orig_used_id_map); | ||
let pulldown_output = format!("{}", MarkdownWithToc(text, RenderType::Pulldown)); |
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.
Is there a way we can somehow combine this chunk of code with the one below and with https://github.com/GuillaumeGomez/rust/blob/92c38d31e4f3797517d1a33619eb2628758cf464/src/librustdoc/html/render.rs#L1838-L1843 so we don't have three copies of the "render this markdown twice" code? (I'm thinking some kind of function that takes a RenderType
and returns a string so it can also be used right here?)
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.
I was thinking about it as well but every solution seems more like a boilerplate than a real solution. I'll give it a deeper look.
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.
So my thinking is something like this, in html/render.rs
so it can be used alongside USED_ID_MAP
:
fn render_text<F: FnMut(RenderType) -> String>(render: F) -> (String, String) {
// (original comment about saving USED_ID_MAP)
let orig_used_id_map = USED_ID_MAP.with(|map| map.borrow().clone());
let hoedown_output = render(text, RenderType::Hoedown);
USED_ID_MAP.with(|map| *map.borrow_mut() = orig_used_id_map);
let pulldown_output = render(text, RenderType::Pulldown);
(hoedown_output, pulldown_output)
}
...and then it could be called like this:
render_text(|type| format!("{}", Markdown(text, type)));
render_text(|type| format!("{}", MarkdownWithToc(text, type)));
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.
Totally seems like a boilerplate haha. I'll give it a try. ;)
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.
I don't see how refactoring this to combine the code would be called "boilerplate", but if you think it would be too much effort i can just drop it.
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.
Can you export render_text
and use it here? (That's why i brought it up in the first place. >_>
)
Checking in from triage — it looks like it's up to @GuillaumeGomez to make some suggested changes, yes? |
That or some kind of field report for having tried them out and rejecting them. The rest of the PR is good. |
I need to apply @QuietMisdreavus' suggestions. I didn't have time yet. |
92c38d3
to
fca51fb
Compare
@QuietMisdreavus: Updated. The new code looks way better. Great suggestion! |
fca51fb
to
eb84f42
Compare
r=me pending travis |
@bors: r=QuietMisdreqvus |
📌 Commit eb84f42 has been approved by |
Md warnings Fixes #45365. r? @QuietMisdreavus
☀️ Test successful - status-appveyor, status-travis |
Fixes #45365.
r? @QuietMisdreavus