-
Notifications
You must be signed in to change notification settings - Fork 201
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
Detecting docs.rs from build.rs? #147
Comments
Thanks for the neat idea, currently there is no way to check this. We can setup an environment variable and you can check presence of this env var to detect if build machine is docs.rs. What do you think? |
Yes, that would work. |
Is there any update on this or something that I can do to help out? |
As a terrible workaround, what about creating a |
There could be docs.rs-specific solution (e.g. the site could set a feature or env var), but ideally this could be built-in into Rust. Tests get If there was an officially blessed solution, then it would be easier to make crates like |
See @nickbabcock's comment in #191 for a clever-but-hacky workaround: [package.metadata.docs.rs]
rustc-args = ["--cfg", "<name>_docs_rs"]
rustdoc-args = ["--cfg", "<name>_docs_rs"] Then in if cfg!(<name>_docs_rs) { ... } |
I wasn't aware of the metadata table! [package.metadata.docs.rs]
features = [ "docs-only" ] That would work for me. |
The A more complicated problem is that it seems that this
This succeed, while it should have failed (because of the missing Any idea how to solve this? |
|
Can that be detected by build scripts? |
Hmm, I don't think so. I'll see if we can add an environment variable. |
Mentoring instructions:
See also the contributing guidelines. Feel free to reach out here or on the Discord |
docs.rs now sets |
How can we detect it also when invoking |
@thewh1teagle I don't know of any environment variable that is set, more idiomatically you can use |
if you need to detect docs.rs specifically you can use |
The docs.rs documentation has a page on this topic: https://docs.rs/about/builds#detecting-docsrs |
the last question here was about detecting |
The issue for detecting |
I have a crate that requires complicated system dependencies to build. However, the real functionality is not actually needed for docs, so I think I could fake it just for doc generation.
Can I somehow detect docs.rs and build my crate differently for docs?
The text was updated successfully, but these errors were encountered: