Closed AaronErhardt closed 1 year ago
How do you pass that via cargo so that it can be enabled as part of cargo doc
? Via rustc
I'm aware, I'm using that mechanism in some non-cargo project of mine.
It's as simple as using the RUSTFLAGS
or RUSTDOCFLAGS
env variables, for example RUSTDOCFLAGS='--cfg docsrs' cargo doc
Not nice but I guess OK because we only do that via generator.py
anyway.
This should probably be moved to gir itself, then whatever change happens there will propagate to all the bindings once that gets fixed.
@AaronErhardt Do you want to work on adding this?
Yes, I think I should have some time to come up with a PR in the next few days.
Cargo features are supposed to be additive, but the "dox" feature isn't. Compiling with "dox" skips compile time checks for the underlying C libraries and therefore should not be enabled during normal development.
A better solution would be to use a "docsrs" or "dox" config argument for rustc directly. This seems to be what most crates do and it's also what docs.rs recommends. This would make possible to use
--all-features
again and removes the need to pass the "dox" feature to the dependencies.The code for conditional compilation would only change from
#[cfg(feature = "dox")]
to#[cfg(dox)]
.This doesn't only affect the gtk4 crate, so feel free to move the issue if there's a better repo for this topic.