From 1f3cd0446d22845aa54198357769adcc365763c8 Mon Sep 17 00:00:00 2001 From: miniduikboot Date: Sun, 7 Sep 2025 00:52:51 +0200 Subject: [PATCH] Add docs for bin source, not lib source code If a crate has both a lib and a bin target, cargo will prefer to generate for the library target[1]. By renaming the library target, we force cargo to document the binary instead. [1]: https://github.com/rust-lang/cargo/blob/3b379fcc541b39321a7758552d37e5e0cc4277b9/src/doc/src/reference/cargo-targets.md#the-doc-field --- {{project-name}}-ebpf/Cargo.toml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/{{project-name}}-ebpf/Cargo.toml b/{{project-name}}-ebpf/Cargo.toml index aec62c5..a3639a8 100644 --- a/{{project-name}}-ebpf/Cargo.toml +++ b/{{project-name}}-ebpf/Cargo.toml @@ -15,3 +15,10 @@ which = { workspace = true } [[bin]] name = "{{ project-name }}_ebpf" path = "src/main.rs" + +# Tip: if you want to get aya-ebpf documentation in your crate docs, try +# running `cargo doc --all`. This block makes cargo doc skip the dummy library +# (see {{ project-name }}/Cargo.toml for more details) +[lib] +name = "{{ project-name | snake_case }}_ebpf_dummy" +doc = false