Conditional compilation hint in rustdoc?

Hi there,

I'm using conditional compilation to factor in target architecture specific behavior.
While generating the documentation using cargo doc I'm currently using some strange cfg flag to show them all in the documentation like so:

#[cfg(any(target_arch = "aarch64", test, doc, doctest))]
pub mod aarch64;
#[cfg(any(target_arch = "aarch64", test, doc, doctest))]
pub use aarch64::*;

#[cfg(any(target_arch = "arm", test, doc, doctest))]
pub mod aarch32;
#[cfg(any(target_arch = "arm", test, doc, doctest))]
pub use aarch32::*;

Thats lot of noise in the code, but I'd be fine if this is the way to. What I'm missing is to see in the generated doc that the modules are only available for a specific condition. Is there any option to generate this into the doc's ? So a banner is created like for deprectaed or unstable items?

Would this maybe a feature request to rustdoc ?

Thx in advance for any hint...

I know that tokio does this: tokio. I think it uses this.

See also this line from std

#![doc(cfg(unix))]
1 Like

Hi,
Thanks. This was exactly what I was looking for ....
I'm using the #[doc(cfg(target_arch = "aarch64"))] flag to control this now... And it works like a charm :slight_smile:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.