-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Allow # to appear in rustdoc code output. #41785
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
c62b4ea
to
5ab531d
Compare
src/test/rustdoc/issue-41783.rs
Outdated
|
||
// @has issue_41783/struct.Foo.html | ||
// @has - '# <span class="ident">single' | ||
// @has - '#<span class="attribute"># <span class="ident">double</span>' |
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.
If there's a better way to do this, I'd be happy to hear about it.
Ok, so it seems to be a good idea but I don't agree with how you implemented it or the idea of the feature. From my point of view, if a line starts with |
74b29b6
to
ba840c5
Compare
src/librustdoc/html/markdown.rs
Outdated
} else if trimmed.starts_with("# ") { | ||
Some(&trimmed[2..]) | ||
Line::Hidden("") | ||
} else if trimmed.starts_with("#") { |
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.
This code won't work, switch the two conditions.
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.
Err, that was a mistake either way, it should be "# "
.
ba840c5
to
45a22b1
Compare
src/librustdoc/html/markdown.rs
Outdated
let trimmed = s.trim(); | ||
if trimmed == "#" { | ||
Some("") | ||
Line::Hidden("") | ||
} else if trimmed.starts_with("# ") { |
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.
Something more intelligent in here could be to put this if condition after the next one, and replace starts_with("# ")
with starts_with("#")
. So you can write:
#extern crate foo;
As well as:
# extern crate foo;
45a22b1
to
2e072ac
Compare
"##" at the start of a trimmed rustdoc line is now cut to "#" and then shown. If the user wanted to show "##", they can type "###".
2e072ac
to
ffe12b1
Compare
I wasn't able to make |
Well, it could be a future improvement. We'll see. For now it's good, thanks! @bors: r+ |
📌 Commit ffe12b1 has been approved by |
Allow # to appear in rustdoc code output. "##" at the start of a trimmed rustdoc line is now cut to "#" and then shown. If the user wanted to show "##", they can type "###". I'm somewhat concerned about the potential implications for users, since this does make a potentially backwards-incompatible change. Previously, `##` had no special handling, and now we do change it. However, I'm not really sure what we can do here to improve this, and I can't think of any cases where `##` would likely be correct in a code block, though of course I could be wrong. Fixes #41783.
☀️ Test successful - status-appveyor, status-travis |
"##" at the start of a trimmed rustdoc line is now cut to "#" and then
shown. If the user wanted to show "##", they can type "###".
I'm somewhat concerned about the potential implications for users, since this does make a potentially backwards-incompatible change. Previously,
##
had no special handling, and now we do change it. However, I'm not really sure what we can do here to improve this, and I can't think of any cases where##
would likely be correct in a code block, though of course I could be wrong.Fixes #41783.