add annotations for required features in doc
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 liketor_rtcompat::tokio::PreferredRuntime
where it showsnative-tls
, but the struct exist whennative-tls
is off.
It should be possible to work around some of that, but not all (when re-exporting a runtime under the namePreferredRuntime
, the required feature-set forPreferredRuntime
is the same as the runtime its based on). -
visible::StructFields
does not add feature-flags in a waydoc_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?