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

Codeblock color #44397

Merged
merged 3 commits into from
Sep 17, 2017
Merged

Codeblock color #44397

merged 3 commits into from
Sep 17, 2017

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Sep 7, 2017

screen shot 2017-09-07 at 21 53 58

This screenshot has been generated from:

/// foo
///
/// ```compile_fail
/// foo();
/// ```
///
/// ```ignore
/// goo();
/// ```
///
/// ```
/// let x = 0;
/// ```
pub fn bar() -> usize { 2 }

r? @QuietMisdreavus
cc @rust-lang/docs

@QuietMisdreavus
Copy link
Member

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 compile_fail flag. If you put back the nightly check for compile_fail then that should be fine.

} 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());
Copy link
Contributor

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.

Copy link
Member

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?

@estebank
Copy link
Contributor

estebank commented Sep 7, 2017

@GuillaumeGomez could you check how it looks if only the border-left is given the proposed colors? I feel that the current design drives too much attention to the emptiness on the right hand side of the code block.

</bikeshedding>

@QuietMisdreavus
Copy link
Member

travis failures:

[00:03:47] tidy error: /checkout/src/test/rustdoc/codeblock-title.rs:13: line longer than 100 chars
[00:03:47] tidy error: /checkout/src/test/rustdoc/codeblock-title.rs:14: line longer than 100 chars
[00:03:47] tidy error: /checkout/src/test/rustdoc/codeblock-title.rs:22: unexplained "```ignore" doctest; try one:
[00:03:47] 
[00:03:47] * make the test actually pass, by adding necessary imports and declarations, or
[00:03:47] * use "```text", if the code is not Rust code, or
[00:03:47] * use "```compile_fail,Ennnn", if the code is expected to fail at compile time, or
[00:03:47] * use "```should_panic", if the code is expected to fail at run time, or
[00:03:47] * use "```no_run", if the code should type-check but not necessary linkable/runnable, or
[00:03:47] * explain it like "```ignore (cannot-test-this-because-xxxx)", if the annotation cannot be avoided.

@alexcrichton alexcrichton added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 7, 2017
@GuillaumeGomez
Copy link
Member Author

@QuietMisdreavus: Oh, forgot to remove the 100 columns limit on the test.
@estebank: I think you're right, it attracts attention too much. Let's see with just left. ;)

@GuillaumeGomez
Copy link
Member Author

screenshot from 2017-09-08 16-17-51

@frewsxcv
Copy link
Member

frewsxcv commented Sep 8, 2017

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.

@QuietMisdreavus
Copy link
Member

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?

@est31
Copy link
Member

est31 commented Sep 8, 2017

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?

@GuillaumeGomez
Copy link
Member Author

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.

@steveklabnik
Copy link
Member

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 compile_fail, ignore alone would be a big improvement.

@estebank
Copy link
Contributor

estebank commented Sep 8, 2017

What about expanding the current proposal with that has been mentioned already?

screen shot 2017-09-08 at 10 36 37

screen shot 2017-09-08 at 10 38 19

If using the unicode char ⓕ or any other icon, I'd make sure to add a tooltip for it.

@QuietMisdreavus
Copy link
Member

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.

@GuillaumeGomez
Copy link
Member Author

Ok so new output:

screen shot 2017-09-09 at 15 33 38

@GuillaumeGomez GuillaumeGomez force-pushed the codeblock-color branch 2 times, most recently from 822775b to 3a256cf Compare September 9, 2017 21:06
@GuillaumeGomez
Copy link
Member Author

Updated.

@QuietMisdreavus
Copy link
Member

We talked about it on IRC, and a couple comments came out:

  • The little glyph isn't exactly what was asked for. The original request was to use a circle-f for compile_fail examples, and a circle-i for ignore examples, but the PR as-is puts a circle-f on all of them. I'd personally just stick with the same ⚠ warning glyph we use when listing unsafe functions, but i don't know what everyone else in this thread thinks about that.
  • Right now, the PR stabilizes the compile_fail flag, even though Compile fail stable #43949 is meant to do that. After talking about it on IRC, we decided to take those changes out of this PR, and explicitly gate it on Compile fail stable #43949. @GuillaumeGomez didn't want to land this change until compile_fail was fully stable.

@steveklabnik
Copy link
Member

but i don't know what everyone else in this thread thinks about that.

Seems good to me!

@GuillaumeGomez didn't want to land this change until compile_fail was fully stable.

👍

@GuillaumeGomez
Copy link
Member Author

screen shot 2017-09-11 at 22 11 12

/// foo();
/// ```
///
/// ```ignore (tidy)
Copy link
Member

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. >_>

Copy link
Member Author

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

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 \
Copy link
Member

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.

@QuietMisdreavus
Copy link
Member

r=me once #43949 lands

@GuillaumeGomez
Copy link
Member Author

@bors: r=QuietMisdreavus

@bors
Copy link
Contributor

bors commented Sep 15, 2017

📌 Commit 79f888d has been approved by QuietMisdreavus

@GuillaumeGomez
Copy link
Member Author

@bors: rollup

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 15, 2017
…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
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Sep 16, 2017
…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
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Sep 16, 2017
…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
TimNN added a commit to TimNN/rust that referenced this pull request Sep 17, 2017
…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
TimNN added a commit to TimNN/rust that referenced this pull request Sep 17, 2017
…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
TimNN added a commit to TimNN/rust that referenced this pull request Sep 17, 2017
…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
bors added a commit that referenced this pull request Sep 17, 2017
Rollup of 17 pull requests

- Successful merges: #44073, #44088, #44381, #44397, #44509, #44533, #44549, #44553, #44562, #44567, #44595, #44604, #44617, #44622, #44630, #44639, #44647
- Failed merges:
@bors bors merged commit 79f888d into rust-lang:master Sep 17, 2017
@GuillaumeGomez GuillaumeGomez deleted the codeblock-color branch September 17, 2017 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants