How to disable documentation testing for specific platforms?


How could one disable documentation testing for specific platforms?
I tried doing this:

/// ```
/// # #[cfg(all(unix, not(any(target_os="macos", target_os="ios", target_os="android"))))]
/// # fn main() {
/// # }
/// ```

And on the excluded platforms it throws this error: error: main function not found.
Should I just put another cfg with the excluded platforms that does just?:

fn main() {}

Aka adding:

/// # #[cfg(not(all(unix, not(any(target_os="macos", target_os="ios", target_os="android")))))]
/// # fn main() {}

That will show that the test passed even though nothing has been run…
I would like cargo doc to skip the test on those platforms if this is possible.

Note that I want to skip only 1 test. I am aware that I could disable all doctests on those platforms…
From what I searched, seems like this is not supported.

Update 2: It is supported. Solution in the response.


Ok, I solved my issue like that:

#[cfg_attr(all(unix, not(any(target_os="macos", target_os="ios", target_os="android"))),
           doc = " ```")]
#[cfg_attr(not(all(unix, not(any(target_os="macos", target_os="ios", target_os="android")))),
           doc = " ```no_run")]

That’s instead of:

/// ```

Thanks to this blog post.