tokio-rs / valuable

MIT License
187 stars 20 forks source link

add `doc(cfg(...))` to feature-flagged impls #74

Closed hawkw closed 2 years ago

hawkw commented 2 years ago

Currently, feature-flagged public APIs will not be documented as requiring feature flags. This branch adds #[doc(cfg(...))] to all feature-flagged APIs.

For the most part, this is done using the feature! macro lifted from Tokio: https://github.com/tokio-rs/tokio/blob/8943e8aeef0b33f371d6dc69f62b38da390b5d5f/tokio/src/macros/cfg.rs#L3-L14

In a couple of places, though, the feature-flagged thing is in a position other than item position, so in that case, it was necessary to just paste the attribute...

Signed-off-by: Eliza Weisman eliza@buoyant.io

davidbarsky commented 2 years ago

@hawkw I don't think that this is necessary anymore as per this tweet. @taiki-e's PR (https://github.com/tokio-rs/tokio/pull/4268) removed these feature flags.

hawkw commented 2 years ago

@hawkw I don't think that this is necessary anymore as per this tweet. @taiki-e's PR (tokio-rs/tokio#4268) removed these feature flags.

huh, i just built the docs on nightly yesterday and I thought I didn't see the feature flag docs, so I had thought that wasn't ready yet. let me double-check!

hawkw commented 2 years ago

@davidbarsky hmm, i'm still not seeing them without the attribute, on today's nightly: image

image

it looks like it worked for tokio, though. i wonder if the issue is that in valuable currently, the only things that are feature flagged are trait impls for foreign types; maybe RustDoc doesn't generate the cfg docs for those implicitly?

hawkw commented 2 years ago

@davidbarsky OH i'm a dumbass, it turns out --- we do still need to enable the doc_cfg feature, we just don't need to add the attributes everywhere. lmao.

hawkw commented 2 years ago

huh. I still can't get it to work without the attributes, even with #![feature(doc_cfg)] added unconditionally. I'm on last night's nightly build:

:; cargo +nightly rustdoc --  --version --verbose
 Documenting valuable v0.1.0 (/home/eliza/Code/valuable/valuable)
rustdoc 1.58.0-nightly (936f2600b 2021-11-22)
binary: rustdoc
commit-hash: 936f2600b6c903b04387f74ed5cbce88bb06d243
commit-date: 2021-11-22
host: x86_64-unknown-linux-gnu
release: 1.58.0-nightly
LLVM version: 13.0.0
    Finished dev [unoptimized + debuginfo] target(s) in 0.08s
davidbarsky commented 2 years ago

huh. I still can't get it to work without the attributes, even with #![feature(doc_cfg)] added unconditionally. I'm on last night's nightly build:

that's effin' weird. anyways, ignore me! please don't let me nerdsnipe you on this shit

carllerche commented 2 years ago

Where we taking this? Moving forward or holding back?