arrayvec icon indicating copy to clipboard operation
arrayvec copied to clipboard

Automatically document feature flag requirements on docs.rs by using the feature `doc_auto_cfg`

Open JSorngard opened this issue 1 year ago • 2 comments

Thanks for the nice crate!

Since this is an unsolicited PR, I completely understand if it is not interesting.

This PR automatically documents all feature flag requirements on docs.rs. This way any future feature flag gated code does not have to worry about documenting what features it needs. It uses the idea discussed in this stackoverflow post.

The feature requires a nightly compiler, but by conditionally enabling it only on docs.rs the MSRV of the crate is unchanged (docs.rs always uses the nightly compiler).

The result should look like this: bild
and this:
bild

To test it locally you can do

RUSTDOCFLAGS="--cfg docsrs"; cargo +nightly doc --all-features

on Linux, and

$env:RUSTDOCFLAGS="--cfg docsrs"
cargo +nightly doc --all-features

on Windows.

JSorngard avatar Jun 09 '24 09:06 JSorngard

That looks very good but right now, with the slow speed of development, I don't want to use any unstable features.

bluss avatar Jul 31 '24 13:07 bluss

Ah, I hadn't seen that! Very nice.

Makes sense to not merge. Should I delete the PR, or is it something for the future?

JSorngard avatar Jul 31 '24 15:07 JSorngard