Skip to content

Commit

Permalink
libbpf-rs: Generate docs for impls on type alias
Browse files Browse the repository at this point in the history
rustdoc apparently cannot generate docs for methods implemented on a
type alias target unless said type alias is exported from the crate. I
think it's b/c under the hood rustdoc is using some clever javascript
tricks to inline documentation. They do this to avoid HTML bloat for
crates with lots of type alises [0].

The upshot of this is now trait impls like `AsFd` are visible in web
docs. This is really important, as otherwise it's quite difficult for
users to discover these APIs.

The downside of this approach is we publically expose implementation
structs in docs. It's not a huge deal, as with skeleton it should be
fairly obvious what types they should actually interact with. I kinda
doubt anyone reads the docs front to back.

[0]: rust-lang/rust#116471
  • Loading branch information
danobi authored and d-e-s-o committed Sep 17, 2024
1 parent f8b8a5a commit af2ee0b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libbpf-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,13 @@ pub use crate::map::Map;
pub use crate::map::MapCore;
pub use crate::map::MapFlags;
pub use crate::map::MapHandle;
pub use crate::map::MapImpl;
pub use crate::map::MapInfo;
pub use crate::map::MapKeyIter;
pub use crate::map::MapMut;
pub use crate::map::MapType;
pub use crate::map::OpenMap;
pub use crate::map::OpenMapImpl;
pub use crate::map::OpenMapMut;
pub use crate::object::AsRawLibbpf;
pub use crate::object::MapIter;
Expand All @@ -132,10 +134,12 @@ pub use crate::print::PrintCallback;
pub use crate::print::PrintLevel;
pub use crate::program::Input as ProgramInput;
pub use crate::program::OpenProgram;
pub use crate::program::OpenProgramImpl;
pub use crate::program::OpenProgramMut;
pub use crate::program::Output as ProgramOutput;
pub use crate::program::Program;
pub use crate::program::ProgramAttachType;
pub use crate::program::ProgramImpl;
pub use crate::program::ProgramMut;
pub use crate::program::ProgramType;
pub use crate::program::TracepointOpts;
Expand Down

0 comments on commit af2ee0b

Please sign in to comment.