-
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
Warn more gently on ignored example code #44927
Comments
We'll need to discuss it in the next team meeting. |
cc #44397 . I was totally okay with the previous behaviour and don't really like the new one either. |
So, this is one of the longest-standing requests for rustdoc, and we get issues about it all the time. People expect to be able to run examples, and so if the example doesn't run, we should tell them in some fashion. Is there some way we can address both concerns here? |
I guess it's just an issue of how to formulate it. Something more matter of fact would be good like "This example is not tested automatically." Warning triangle can stay? |
My main problem is the inaccuracy. Whether a test is ignored or not is not the same as whether a test actually compiles and runs. Just look at the example @bluss linked. The test obviously will compile, but its ignored. The reverse can be true as well: if you have changed an API but forgot to run Its the same issue I have with this crates.io batches thing: I want the info to be accurate, and not just be some indicator. This is Rust, not C! I'd agree with the feature if rustdoc would actually test each single example for whether it compiles and runs, and display that info instead. |
Well, every non-ignored code block is tested and run, so I'm not sure to understand what you're talking about. |
I think as a workaround you could comment the code out, e.g. //! ```rust,ignore
//! # #[cfg(never)] mod foo {
//! use itertools::Itertools;
//! # }
//! ```
|
I sometimes write Rust-like pseudocode to explain concepts where normal Rust code would be too verbose or detract from the main topic. The presence of syntax highlighting improves readability. I find this warning rather discouraging, especially the exclamation mark that is normally used for unsafe code. Besides, there's ways to work around this kind of stuff, so all it does is to force doc writers to find more unsightly hacks like @arielb1's example, or give up syntax highlighting for no good reason. I think rather than to disparage code blocks that are untested with scary signs, consider adding some positive decoration to the code blocks that are tested, like "this code is tested" with a glowy green border or something, perhaps with some buttons for copy-pasting the original code and/or exposing the |
First, on all operating systems I've tried on you can just select code and copy it by pressing some keys, so its not really needed, second usually example code is not properly licensed. Most times its under the same license as the code around it, so you'd have to copy the entire attribution/license headers as well. So I don't think one should go down that path. |
I'm looking at touching this, at least to tweak the phrasing. How do the phrases "This sample is not tested" and "This sample deliberately fails to compile" sound? I'm also looking for a better icon, but sadly INFORMATION SOURCE is a box on my work computer, so i'd need to find one that is provided by the fonts we bundle with rustdoc. |
@QuietMisdreavus what about ⓘ ? |
The former sounds good. Should it say "example" instead of sample? |
I put these string tweaks in #45815 - feel free to bikeshed over there. |
…s, r=GuillaumeGomez rustdoc: tweak notes on ignore/compile_fail examples Part of rust-lang#44927 This is a softening of these notices to mention *why* a given example has a given callout, rather then telling viewers to be careful with an example. It also changes the character used for these samples from a warning logo to a circle-i/information logo. ![image](https://user-images.githubusercontent.com/5217170/32464361-5fbb5d9e-c305-11e7-8482-ce71b97a54df.png)
…s, r=GuillaumeGomez rustdoc: tweak notes on ignore/compile_fail examples Part of rust-lang#44927 This is a softening of these notices to mention *why* a given example has a given callout, rather then telling viewers to be careful with an example. It also changes the character used for these samples from a warning logo to a circle-i/information logo. ![image](https://user-images.githubusercontent.com/5217170/32464361-5fbb5d9e-c305-11e7-8482-ce71b97a54df.png)
Now #45815 is merged, where does that leave this issue? |
Icon and text are improved, I think this is fine to close. Thanks @QuietMisdreavus |
Source code (rendered):
This renders with a warning triangle in the crate's docs. "Be careful when using this code, it's not being tested!"
Can we be more gentle with the warnings? This warning reflects badly on the crate, and we cast doubt on it that is unfounded. Any author that uses
ignore
probably knew why they did so.In this case the warning is especially visible and unlucky, and the user can easily be confused, is "the code" referring to the whole crate?
The text was updated successfully, but these errors were encountered: