docs: Add labels for optional features

Following the lead of crates like tokio and nix, we now annotate APIs
that require optional features. This helps in cases where a user wants
to have an `AsyncPerfEventArray` which is documented on crates.io, but
it's not obvious that you have to enable the `async` feature.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
pull/404/head
Dave Tucker 2 years ago
parent 3f2f3a8be0
commit 95e8c78db8

@ -32,3 +32,7 @@ default = []
async = ["futures"] async = ["futures"]
async_tokio = ["tokio", "async"] async_tokio = ["tokio", "async"]
async_std = ["async-std", "async-io", "async"] async_std = ["async-std", "async-io", "async"]
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

@ -36,6 +36,7 @@
html_logo_url = "https://aya-rs.dev/assets/images/crabby.svg", html_logo_url = "https://aya-rs.dev/assets/images/crabby.svg",
html_favicon_url = "https://aya-rs.dev/assets/images/crabby.svg" html_favicon_url = "https://aya-rs.dev/assets/images/crabby.svg"
)] )]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![deny(clippy::all, missing_docs)] #![deny(clippy::all, missing_docs)]
#![allow(clippy::missing_safety_doc, clippy::len_without_is_empty)] #![allow(clippy::missing_safety_doc, clippy::len_without_is_empty)]

@ -137,7 +137,7 @@ pub struct AsyncPerfEventArrayBuffer<T: DerefMut<Target = Map>> {
async_fd: Async<RawFd>, async_fd: Async<RawFd>,
} }
#[cfg(any(feature = "async_tokio", doc))] #[cfg(any(feature = "async_tokio"))]
impl<T: DerefMut<Target = Map>> AsyncPerfEventArrayBuffer<T> { impl<T: DerefMut<Target = Map>> AsyncPerfEventArrayBuffer<T> {
/// Reads events from the buffer. /// Reads events from the buffer.
/// ///

@ -1,12 +1,14 @@
//! Ring buffer types used to receive events from eBPF programs using the linux `perf` API. //! Ring buffer types used to receive events from eBPF programs using the linux `perf` API.
//! //!
//! See the [`PerfEventArray`] and [`AsyncPerfEventArray`]. //! See the [`PerfEventArray`] and [`AsyncPerfEventArray`].
#[cfg(any(feature = "async", doc))] #[cfg(any(feature = "async"))]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
mod async_perf_event_array; mod async_perf_event_array;
mod perf_buffer; mod perf_buffer;
mod perf_event_array; mod perf_event_array;
#[cfg(any(feature = "async", doc))] #[cfg(any(feature = "async"))]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub use async_perf_event_array::*; pub use async_perf_event_array::*;
pub use perf_buffer::*; pub use perf_buffer::*;
pub use perf_event_array::*; pub use perf_event_array::*;

@ -95,7 +95,7 @@ impl FdLink {
/// Pins the link to a BPF file system. /// Pins the link to a BPF file system.
/// ///
/// When a link is pinned it will remain attached even after the link instance is dropped, /// When a link is pinned it will remain attached even after the link instance is dropped,
/// and will only be detached once the pinned file is removed. To unpin, see [PinnedFd::unpin]. /// and will only be detached once the pinned file is removed. To unpin, see [`PinnedLink::unpin()`].
/// ///
/// The parent directories in the provided path must already exist before calling this method, /// The parent directories in the provided path must already exist before calling this method,
/// and must be on a BPF file system (bpffs). /// and must be on a BPF file system (bpffs).

@ -67,7 +67,10 @@ fn build_docs(working_dir: &PathBuf, abs_header_path: &Path) -> Result<(), anyho
.current_dir(working_dir) .current_dir(working_dir)
.env( .env(
"RUSTDOCFLAGS", "RUSTDOCFLAGS",
format!("--html-in-header {}", abs_header_path.to_str().unwrap()), format!(
"--cfg docsrs --html-in-header {}",
abs_header_path.to_str().unwrap()
),
) )
.args(&args) .args(&args)
.status() .status()

Loading…
Cancel
Save