add annotations for required features in doc
- Aug 24, 2022
-
-
trinity-1686a authored
-
trinity-1686a authored
-
trinity-1686a authored
-
trinity-1686a authored
-
trinity-1686a authored
-
trinity-1686a authored
-
trinity-1686a authored
-
fix #541 (closed)
rendered: https://trinity.fr.eu.org/tmp/arti-doc/arti/
As eta stated, this require a nightly feature, it will only work when compiling in nightly. tpo/core/doc will need to be updated to build with nightly, and use RUSTDOCFLAGS="--cfg docsrs"
.
Limitations:
doc_auto_cfg
does overall a good job of adding annotations wherever needed. However it does not seems to detect re-exports well. There seems to be 20 or so such cases. I've worked on a script that should warn when cfg flag and annotation diverge, as both might not be in the same file, leading to easy miss for both dev and reviewer.// this does not get annotated automagically
#[cfg(feature = "myFeature")]
pub use mod::StructUnreachableWithoutMyFeature;
Features like tor_llcrypto with-openssl
which are not strictly additive, makes for misleading annotations. This also goes for some things like tor_rtcompat::tokio::PreferredRuntime
where it shows native-tls
, but the struct exist when native-tls
is off.
It should be possible to work around some of that, but not all (when re-exporting a runtime under the name PreferredRuntime
, the required feature-set for PreferredRuntime
is the same as the runtime its based on).
visible::StructFields
does not add feature-flags in a way doc_auto_cfg
can detect. However as the struct-attribute and fields are close, I think keeping both in sync can be achieved with manual review alone.
maint/check_doc_features
contains an unhealthy dose of gawk
, but I'm not sure how to make it better. Maybe this ought to be rewritten in Python?