-
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
Codeblock color #44397
Codeblock color #44397
Conversation
I'm generally +1 on this, though I'd also like to see what the rest of the docs team thinks. Technically this is gated on #43949, since it makes the same change to the |
src/librustdoc/html/markdown.rs
Outdated
} else if compile_fail { | ||
let mut tmp = HashMap::new(); | ||
tmp.insert("title".to_owned(), | ||
"This code doesn't compile so be extra careful!".to_owned()); |
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'm wondering if there's a nicer way to phrase this than "so be extra careful" (since it doesn't compile anyway), but: I don't have a better suggestion than just leaving that part off so I think it's fine as-is, too.
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 like "Warning: This code will not compile!", maybe?
@GuillaumeGomez could you check how it looks if only the
|
travis failures:
|
@QuietMisdreavus: Oh, forgot to remove the 100 columns limit on the test. |
5e70325
to
30912c4
Compare
I'm +0 on this right now. I think the visual indicators aren't subtle enough and draw too much attention to the code block. I think a symbol like this could probably be sufficient to warn the user instead of incorporating such vibrant colors, but I'm not really sure what the best approach is here. |
That's a good point. Without another kind of indicator on "good" code blocks, it does make the "bad" ones stick out a bit much. I like the idea of using an indicator character like the one you linked; would it be possible to sketch that one out? |
What about a red ⓕ for should fail and a yellow ⓘ for ignored? I think though that snippets you want to ignore shouldn't get be singled out in the rendered documentation as who tells me in the first place that the other snippets test successfully? |
I proposed to add a gren border for the "ok" code blocks and to reduce the outstanding of the other blocks. I don't like the character proposition because it's just another one in the middle of a lot. |
This would fix #20524, those comments should be read as well. Note that the proposed screenshot uses just the left border, like @estebank suggested above. I also like the idea of symbols. Basically, this is a huge 👍 from me generally, but I do think working out the details here would be important. And it'd be nice if we could only gate part of it on |
On IRC, i proposed making the border appear on hover, rather than at all times. That way, the border doesn't distract unless someone has their cursor over the block, like if they're trying to copy the code out. We could even add in the "help" cursor so people are more likely to wait for the tooltip to appear. The linked issue also mentions making sure that we provide sufficient accessibility hints to make sure that users with screen readers or other methods also get the notes. |
e73a380
to
b22043a
Compare
822775b
to
3a256cf
Compare
Updated. |
We talked about it on IRC, and a couple comments came out:
|
Seems good to me!
👍 |
3a256cf
to
797286d
Compare
/// foo(); | ||
/// ``` | ||
/// | ||
/// ```ignore (tidy) |
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.
Would be nice to say something like (checking-rendering-of-ignore-blocks)
instead of (tidy)
here. That way it explicitly says why it's there, rather than just putting something there to make tidy happy. >_>
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.
Haha. I'll think about it. :p
src/librustdoc/html/highlight.rs
Outdated
debug!("highlighting: ================\n{}\n==============", src); | ||
let sess = parse::ParseSess::new(FilePathMapping::empty()); | ||
let fm = sess.codemap().new_filemap("<stdin>".to_string(), src.to_string()); | ||
|
||
let mut out = Vec::new(); | ||
if let Some((tooltip, class)) = tooltip { | ||
write!(out, "<div class='information'><div class='tooltip {}'>ⓕ<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.
This is the glyph i was talking about. Changing that circle-f with the warning symbol is what i was suggesting earlier.
797286d
to
79f888d
Compare
r=me once #43949 lands |
@bors: r=QuietMisdreavus |
📌 Commit 79f888d has been approved by |
@bors: rollup |
…uietMisdreavus Codeblock color <img width="1440" alt="screen shot 2017-09-07 at 21 53 58" src="https://user-images.githubusercontent.com/3050060/30183045-4319108e-9419-11e7-98da-da54952cab37.png"> This screenshot has been generated from: ```rust /// foo /// /// ```compile_fail /// foo(); /// ``` /// /// ```ignore /// goo(); /// ``` /// /// ``` /// let x = 0; /// ``` pub fn bar() -> usize { 2 } ``` r? @QuietMisdreavus cc @rust-lang/docs
…uietMisdreavus Codeblock color <img width="1440" alt="screen shot 2017-09-07 at 21 53 58" src="https://user-images.githubusercontent.com/3050060/30183045-4319108e-9419-11e7-98da-da54952cab37.png"> This screenshot has been generated from: ```rust /// foo /// /// ```compile_fail /// foo(); /// ``` /// /// ```ignore /// goo(); /// ``` /// /// ``` /// let x = 0; /// ``` pub fn bar() -> usize { 2 } ``` r? @QuietMisdreavus cc @rust-lang/docs
…uietMisdreavus Codeblock color <img width="1440" alt="screen shot 2017-09-07 at 21 53 58" src="https://user-images.githubusercontent.com/3050060/30183045-4319108e-9419-11e7-98da-da54952cab37.png"> This screenshot has been generated from: ```rust /// foo /// /// ```compile_fail /// foo(); /// ``` /// /// ```ignore /// goo(); /// ``` /// /// ``` /// let x = 0; /// ``` pub fn bar() -> usize { 2 } ``` r? @QuietMisdreavus cc @rust-lang/docs
…uietMisdreavus Codeblock color <img width="1440" alt="screen shot 2017-09-07 at 21 53 58" src="https://user-images.githubusercontent.com/3050060/30183045-4319108e-9419-11e7-98da-da54952cab37.png"> This screenshot has been generated from: ```rust /// foo /// /// ```compile_fail /// foo(); /// ``` /// /// ```ignore /// goo(); /// ``` /// /// ``` /// let x = 0; /// ``` pub fn bar() -> usize { 2 } ``` r? @QuietMisdreavus cc @rust-lang/docs
…uietMisdreavus Codeblock color <img width="1440" alt="screen shot 2017-09-07 at 21 53 58" src="https://user-images.githubusercontent.com/3050060/30183045-4319108e-9419-11e7-98da-da54952cab37.png"> This screenshot has been generated from: ```rust /// foo /// /// ```compile_fail /// foo(); /// ``` /// /// ```ignore /// goo(); /// ``` /// /// ``` /// let x = 0; /// ``` pub fn bar() -> usize { 2 } ``` r? @QuietMisdreavus cc @rust-lang/docs
…uietMisdreavus Codeblock color <img width="1440" alt="screen shot 2017-09-07 at 21 53 58" src="https://user-images.githubusercontent.com/3050060/30183045-4319108e-9419-11e7-98da-da54952cab37.png"> This screenshot has been generated from: ```rust /// foo /// /// ```compile_fail /// foo(); /// ``` /// /// ```ignore /// goo(); /// ``` /// /// ``` /// let x = 0; /// ``` pub fn bar() -> usize { 2 } ``` r? @QuietMisdreavus cc @rust-lang/docs
This screenshot has been generated from:
r? @QuietMisdreavus
cc @rust-lang/docs