doc: generate docs in macro

Remove a bunch of repetition and missing links.
reviewable/pr1316/r3
Tamir Duberstein 2 weeks ago
parent 9996f7a300
commit 0d1193720b
No known key found for this signature in database

@ -162,9 +162,7 @@ impl Link for CgroupDeviceLinkInner {
id_as_key!(CgroupDeviceLinkInner, CgroupDeviceLinkIdInner);
define_link_wrapper!(
/// The link used by [CgroupDevice] programs.
CgroupDeviceLink,
/// The type returned by [CgroupDevice::attach]. Can be passed to [CgroupDevice::detach].
CgroupDeviceLinkId,
CgroupDeviceLinkInner,
CgroupDeviceLinkIdInner,

@ -177,9 +177,7 @@ impl Link for CgroupSkbLinkInner {
id_as_key!(CgroupSkbLinkInner, CgroupSkbLinkIdInner);
define_link_wrapper!(
/// The link used by [CgroupSkb] programs.
CgroupSkbLink,
/// The type returned by [CgroupSkb::attach]. Can be passed to [CgroupSkb::detach].
CgroupSkbLinkId,
CgroupSkbLinkInner,
CgroupSkbLinkIdInner,

@ -153,9 +153,7 @@ impl Link for CgroupSockLinkInner {
id_as_key!(CgroupSockLinkInner, CgroupSockLinkIdInner);
define_link_wrapper!(
/// The link used by [CgroupSock] programs.
CgroupSockLink,
/// The type returned by [CgroupSock::attach]. Can be passed to [CgroupSock::detach].
CgroupSockLinkId,
CgroupSockLinkInner,
CgroupSockLinkIdInner,

@ -154,9 +154,7 @@ impl Link for CgroupSockAddrLinkInner {
id_as_key!(CgroupSockAddrLinkInner, CgroupSockAddrLinkIdInner);
define_link_wrapper!(
/// The link used by [CgroupSockAddr] programs.
CgroupSockAddrLink,
/// The type returned by [CgroupSockAddr::attach]. Can be passed to [CgroupSockAddr::detach].
CgroupSockAddrLinkId,
CgroupSockAddrLinkInner,
CgroupSockAddrLinkIdInner,

@ -153,9 +153,7 @@ impl Link for CgroupSockoptLinkInner {
id_as_key!(CgroupSockoptLinkInner, CgroupSockoptLinkIdInner);
define_link_wrapper!(
/// The link used by [CgroupSockopt] programs.
CgroupSockoptLink,
/// The type returned by [CgroupSockopt::attach]. Can be passed to [CgroupSockopt::detach].
CgroupSockoptLinkId,
CgroupSockoptLinkInner,
CgroupSockoptLinkIdInner,

@ -137,9 +137,7 @@ impl Link for CgroupSysctlLinkInner {
id_as_key!(CgroupSysctlLinkInner, CgroupSysctlLinkIdInner);
define_link_wrapper!(
/// The link used by [CgroupSysctl] programs.
CgroupSysctlLink,
/// The type returned by [CgroupSysctl::attach]. Can be passed to [CgroupSysctl::detach].
CgroupSysctlLinkId,
CgroupSysctlLinkInner,
CgroupSysctlLinkIdInner,

@ -197,12 +197,4 @@ fn get_btf_info(
Ok((btf_fd, btf_id))
}
define_link_wrapper!(
/// The link used by [Extension] programs.
ExtensionLink,
/// The type returned by [Extension::attach]. Can be passed to [Extension::detach].
ExtensionLinkId,
FdLink,
FdLinkId,
Extension,
);
define_link_wrapper!(ExtensionLink, ExtensionLinkId, FdLink, FdLinkId, Extension);

@ -73,12 +73,4 @@ impl FEntry {
}
}
define_link_wrapper!(
/// The link used by [FEntry] programs.
FEntryLink,
/// The type returned by [FEntry::attach]. Can be passed to [FEntry::detach].
FEntryLinkId,
FdLink,
FdLinkId,
FEntry,
);
define_link_wrapper!(FEntryLink, FEntryLinkId, FdLink, FdLinkId, FEntry);

@ -73,12 +73,4 @@ impl FExit {
}
}
define_link_wrapper!(
/// The link used by [FExit] programs.
FExitLink,
/// The type returned by [FExit::attach]. Can be passed to [FExit::detach].
FExitLinkId,
FdLink,
FdLinkId,
FExit,
);
define_link_wrapper!(FExitLink, FExitLinkId, FdLink, FdLinkId, FExit);

@ -149,9 +149,7 @@ impl Link for FlowDissectorLinkInner {
id_as_key!(FlowDissectorLinkInner, FlowDissectorLinkIdInner);
define_link_wrapper!(
/// The link used by [FlowDissector] programs.
FlowDissectorLink,
/// The type returned by [FlowDissector::attach]. Can be passed to [FlowDissector::detach].
FlowDissectorLinkId,
FlowDissectorLinkInner,
FlowDissectorLinkIdInner,

@ -118,15 +118,7 @@ impl TryFrom<FdLink> for IterLink {
impl_try_into_fdlink!(IterLink, PerfLinkInner);
define_link_wrapper!(
/// The link used by [`Iter`] programs.
IterLink,
/// The type returned by [`Iter::attach`]. Can be passed to [`Iter::detach`].
IterLinkId,
PerfLinkInner,
PerfLinkIdInner,
Iter,
);
define_link_wrapper!(IterLink, IterLinkId, PerfLinkInner, PerfLinkIdInner, Iter);
impl IterLink {
/// Converts [`IterLink`] into a [`File`] that can be used to retrieve the

@ -104,9 +104,7 @@ impl KProbe {
}
define_link_wrapper!(
/// The link used by [KProbe] programs.
KProbeLink,
/// The type returned by [KProbe::attach]. Can be passed to [KProbe::detach].
KProbeLinkId,
PerfLinkInner,
PerfLinkIdInner,

@ -473,12 +473,18 @@ macro_rules! id_as_key {
pub(crate) use id_as_key;
macro_rules! define_link_wrapper {
(#[$doc1:meta] $wrapper:ident, #[$doc2:meta] $wrapper_id:ident, $base:ident, $base_id:ident, $program:ident,) => {
#[$doc2]
($wrapper:ident, $wrapper_id:ident, $base:ident, $base_id:ident, $program:ident $(,)?) => {
/// The type returned by
#[doc = concat!("[`", stringify!($program), "::attach`]")]
/// . Can be passed to
#[doc = concat!("[`", stringify!($program), "::detach`]")]
/// .
#[derive(Debug, Hash, Eq, PartialEq)]
pub struct $wrapper_id($base_id);
#[$doc1]
/// The link used by
#[doc = concat!("[`", stringify!($program), "`]")]
/// programs.
#[derive(Debug)]
pub struct $wrapper(Option<$base>);

@ -121,7 +121,7 @@ impl LircMode2 {
}
}
/// The type returned by [LircMode2::attach]. Can be passed to [LircMode2::detach].
/// The type returned by [`LircMode2::attach`]. Can be passed to [`LircMode2::detach`].
#[derive(Debug, Hash, Eq, PartialEq)]
pub struct LircLinkId(RawFd, RawFd);

@ -79,12 +79,4 @@ impl Lsm {
}
}
define_link_wrapper!(
/// The link used by [Lsm] programs.
LsmLink,
/// The type returned by [Lsm::attach]. Can be passed to [Lsm::detach].
LsmLinkId,
FdLink,
FdLinkId,
Lsm,
);
define_link_wrapper!(LsmLink, LsmLinkId, FdLink, FdLinkId, Lsm);

@ -203,9 +203,7 @@ impl TryFrom<FdLink> for PerfEventLink {
}
define_link_wrapper!(
/// The link used by [PerfEvent] programs.
PerfEventLink,
/// The type returned by [PerfEvent::attach]. Can be passed to [PerfEvent::detach].
PerfEventLinkId,
PerfLinkInner,
PerfLinkIdInner,

@ -57,9 +57,7 @@ impl RawTracePoint {
}
define_link_wrapper!(
/// The link used by [RawTracePoint] programs.
RawTracePointLink,
/// The type returned by [RawTracePoint::attach]. Can be passed to [RawTracePoint::detach].
RawTracePointLinkId,
FdLink,
FdLinkId,

@ -82,12 +82,4 @@ impl SkLookup {
}
}
define_link_wrapper!(
/// The link used by [SkLookup] programs.
SkLookupLink,
/// The type returned by [SkLookup::attach]. Can be passed to [SkLookup::detach].
SkLookupLinkId,
FdLink,
FdLinkId,
SkLookup,
);
define_link_wrapper!(SkLookupLink, SkLookupLinkId, FdLink, FdLinkId, SkLookup);

@ -98,9 +98,7 @@ impl SkMsg {
}
define_link_wrapper!(
/// The link used by [SkMsg] programs.
SkMsgLink,
/// The type returned by [SkMsg::attach]. Can be passed to [SkMsg::detach].
SkMsgLinkId,
ProgAttachLink,
ProgAttachLinkId,

@ -113,9 +113,7 @@ impl SkSkb {
}
define_link_wrapper!(
/// The link used by [SkSkb] programs.
SkSkbLink,
/// The type returned by [SkSkb::attach]. Can be passed to [SkSkb::detach].
SkSkbLinkId,
ProgAttachLink,
ProgAttachLinkId,

@ -132,9 +132,7 @@ impl Link for SockOpsLinkInner {
id_as_key!(SockOpsLinkInner, SockOpsLinkIdInner);
define_link_wrapper!(
/// The link used by [SockOps] programs.
SockOpsLink,
/// The type returned by [SockOps::attach]. Can be passed to [SockOps::detach].
SockOpsLinkId,
SockOpsLinkInner,
SockOpsLinkIdInner,

@ -120,7 +120,7 @@ impl SocketFilter {
}
}
/// The type returned by [SocketFilter::attach]. Can be passed to [SocketFilter::detach].
/// The type returned by [`SocketFilter::attach`]. Can be passed to [`SocketFilter::detach`].
#[derive(Debug, Hash, Eq, PartialEq)]
pub struct SocketFilterLinkId(RawFd, RawFd);

@ -463,9 +463,7 @@ impl TryFrom<FdLink> for SchedClassifierLink {
}
define_link_wrapper!(
/// The link used by [SchedClassifier] programs.
SchedClassifierLink,
/// The type returned by [SchedClassifier::attach]. Can be passed to [SchedClassifier::detach].
SchedClassifierLinkId,
TcLinkInner,
TcLinkIdInner,

@ -78,9 +78,7 @@ impl BtfTracePoint {
}
define_link_wrapper!(
/// The link used by [BtfTracePoint] programs.
BtfTracePointLink,
/// The type returned by [BtfTracePoint::attach]. Can be passed to [BtfTracePoint::detach].
BtfTracePointLinkId,
FdLink,
FdLinkId,

@ -90,9 +90,7 @@ impl TracePoint {
}
define_link_wrapper!(
/// The link used by [TracePoint] programs.
TracePointLink,
/// The type returned by [TracePoint::attach]. Can be passed to [TracePoint::detach].
TracePointLinkId,
PerfLinkInner,
PerfLinkIdInner,

@ -211,9 +211,7 @@ fn test_resolve_attach_path() {
}
define_link_wrapper!(
/// The link used by [UProbe] programs.
UProbeLink,
/// The type returned by [UProbe::attach]. Can be passed to [UProbe::detach].
UProbeLinkId,
PerfLinkInner,
PerfLinkIdInner,

@ -319,12 +319,4 @@ impl TryFrom<FdLink> for XdpLink {
}
}
define_link_wrapper!(
/// The link used by [Xdp] programs.
XdpLink,
/// The type returned by [Xdp::attach]. Can be passed to [Xdp::detach].
XdpLinkId,
XdpLinkInner,
XdpLinkIdInner,
Xdp,
);
define_link_wrapper!(XdpLink, XdpLinkId, XdpLinkInner, XdpLinkIdInner, Xdp);

Loading…
Cancel
Save