Only compile doc tests that require non-default features if those features are enabled.#546
Only compile doc tests that require non-default features if those features are enabled.#546
Conversation
|
I'm not sure this is the best way to do it, because this will remove examples from the documentation entirely, increasing confusion. This wouldn't be an issue for docs.rs, but the use case of building documentation locally (with limited feature flags) is important to me. Perhaps these examples should just be moved to the |
| //! println!("verify result: {res:?}"); | ||
| //! ``` | ||
| #![cfg_attr(any(feature = "ring", feature = "openssl"), doc = r#" | ||
| ```no_run |
There was a problem hiding this comment.
We could do a cfg_attr that only changes this line into:
```ignore
which will still include the code in the docs for all selected feature sets.
There was a problem hiding this comment.
I guess ignore has the disadvantage that there will be no warning if the example gets out of sync with the code in domain.
There was a problem hiding this comment.
It will run if the features are enabled and we do have CI runs that do that, so I think it is fine?
Thanks to https://users.rust-lang.org/t/doctests-that-require-a-non-default-feature-is-it-possible/29529/4