From 46c08c738da9b72aa63254490dd1ef5559fee139 Mon Sep 17 00:00:00 2001 From: ninevra Date: Sat, 8 Oct 2022 19:55:41 -0700 Subject: [PATCH 1/2] Document all features (on docs.rs) Use the unstable feature doc_auto_cfg to document items' feature flags, and configure docs.rs runs to compile all features. For now, using this locally requires running `cargo +nightly rustdoc --all-features -- --cfg docsrs`. --- Cargo.toml | 4 ++++ src/lib.rs | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index e529ab6..1cd90b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,3 +31,7 @@ itertools = "0.10" [[example]] name = "evtest_tokio" required-features = ["tokio"] + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] diff --git a/src/lib.rs b/src/lib.rs index bec58de..2ddd237 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -86,6 +86,14 @@ // should really be cfg(target_os = "linux") and maybe also android? #![cfg(unix)] +// Flag items' docs' with their required feature flags, but only on docsrs so +// that local docs can still be built on stable toolchains. +// As of the time of writing, the stabilization plan is such that: +// - Once stabilized, this attribute should be replaced with #![doc(auto_cfg)] +// - Then in edition 2024, doc(auto_cfg) will become the default and the +// attribute can be removed entirely +// (see https://github.com/rust-lang/rust/pull/100883#issuecomment-1264470491) +#![cfg_attr(docsrs, feature(doc_auto_cfg))] // has to be first for its macro #[macro_use] From f2587e5b547a6816e6a59a52044111617f923ee5 Mon Sep 17 00:00:00 2001 From: ninevra Date: Sat, 8 Oct 2022 19:58:24 -0700 Subject: [PATCH 2/2] Fix some broken doc links --- src/raw_stream.rs | 2 +- src/sync_stream.rs | 2 +- src/uinput.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/raw_stream.rs b/src/raw_stream.rs index 3f8732d..a7794d6 100644 --- a/src/raw_stream.rs +++ b/src/raw_stream.rs @@ -814,7 +814,7 @@ mod tokio_stream { /// /// This can be used by calling [`stream.next_event().await?`](Self::next_event), or if you /// need to pass it as a stream somewhere, the [`futures::Stream`](Stream) implementation. - /// There's also a lower-level [`poll_event`] function if you need to fetch an event from + /// There's also a lower-level [`Self::poll_event`] function if you need to fetch an event from /// inside a `Future::poll` impl. pub struct EventStream { device: AsyncFd, diff --git a/src/sync_stream.rs b/src/sync_stream.rs index 6a94feb..ad219b5 100644 --- a/src/sync_stream.rs +++ b/src/sync_stream.rs @@ -739,7 +739,7 @@ mod tokio_stream { /// /// This can be used by calling [`stream.next_event().await?`](Self::next_event), or if you /// need to pass it as a stream somewhere, the [`futures::Stream`](Stream) implementation. - /// There's also a lower-level [`poll_event`] function if you need to fetch an event from + /// There's also a lower-level [`Self::poll_event`] function if you need to fetch an event from /// inside a `Future::poll` impl. pub struct EventStream { device: AsyncFd, diff --git a/src/uinput.rs b/src/uinput.rs index 653a70e..b981201 100644 --- a/src/uinput.rs +++ b/src/uinput.rs @@ -537,7 +537,7 @@ mod tokio_stream { /// /// This can be used by calling [`stream.next_event().await?`](Self::next_event), or if you /// need to pass it as a stream somewhere, the [`futures::Stream`](Stream) implementation. - /// There's also a lower-level [`poll_event`] function if you need to fetch an event from + /// There's also a lower-level [`Self::poll_event`] function if you need to fetch an event from /// inside a `Future::poll` impl. pub struct VirtualEventStream { device: AsyncFd,