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

False doc_markdown warnings #1469

Closed
compressed opened this issue Jan 23, 2017 · 6 comments · Fixed by #1799
Closed

False doc_markdown warnings #1469

compressed opened this issue Jan 23, 2017 · 6 comments · Fixed by #1799
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@compressed
Copy link

compressed commented Jan 23, 2017

When I use cfg_attr for conditional examples in doc comments like this:

#![cfg_attr(feature = "a", doc = " ```")]
#![cfg_attr(not(feature = "a"), doc = " ```ignore")]
//! fn main() {
//!     let s = "localhost:10000".to_string();
//!     println!("{}", s);
//! }
//! ```

I receive false warnings:

cargo clippy --features a
...
warning: you should put `to_string` between ticks in the documentation, #[warn(doc_markdown)] on by default
  --> src/lib.rs:66:35
   |
66 | //!     let s = "localhost:10000".to_string();
   |                                   ^^^^^^^^^
@oli-obk
Copy link
Contributor

oli-obk commented Jan 24, 2017

I wasn't even aware that's possible. That's amazing...

@oli-obk oli-obk added the C-bug Category: Clippy is not doing the correct thing label Jan 24, 2017
@compressed
Copy link
Author

Yeah, I had to learn about how to do it correctly in the first place 😄. Definitely an edge case.

@mcarton
Copy link
Member

mcarton commented Jan 24, 2017

This is such a hack, I hesitate between 😄 and 😱.

@Manishearth
Copy link
Member

I think this is a niche enough use case that clippy shouldn't attempt to handle it. idk. Ultimately, the way clippy is supposed to be used is with a liberal sprinkling of allows.

@compressed
Copy link
Author

compressed commented Jan 25, 2017

I'd be fine putting an allow, but since it's at the crate/module level, I'm not sure how to just have it apply there.

If I put #![cfg_attr(feature = "cargo-clippy", allow(doc_markdown))], I'd turn off the validation for the entire crate, not just this section. Maybe there is a better workaround?

Edit: Actually for my use case it's at the crate level so I that's where I'm stuck. If it was just a module I could apply a #[cfg_attr(feature = "cargo-clippy", allow(doc_markdown))] to that mod specifically.

@iliekturtles
Copy link

I ran into the same issue at the crate level and I'm hesitant to add #![allow(doc_markdown)]. I briefly attempted to do a github-wide search for other repositories to see how many others use this same functionality, but didn't get very far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants