Detecting the cargo doc command on build script

I have a build script that panicking when users not specified some required features. Those features must enable manually by users and can not define one feature as default. This script is not generating any rust code and not required for cargo check command. So I need to skip this build script when docs.rs is trying to generate the documentation.
.
I read this ongoing thread. But it is a not active one. If this feature implemented, I could define some default features for only documentation purposes.
.
Is there any temporary workaround to skip the build script by checking env variables. I checked following variables, but didn't helped me.

PROFILE=debug
TARGET=x86_64-unknown-linux-gnu

You can detect docs.rs build by DOCS_RS environment variable. See the documentation here.

1 Like