How to exclude libc from rustdoc?

I have a crate that depends on libc. I don't like that rustdoc output includes full documentation for all of libc. The HTML for libc constants alone is many times larger than documentation for my own crate.

I've added:

extern crate libc;

But cargo doc still documents libc. Should #[doc(hidden)] work for excluding crates?

1 Like

The attribute should probably not have any effect -- it's a direction to rustdoc about the docs of the main crate, but cargo is telling rustdoc to document the dependency crate explicitly, and in that execution, the attribute in the main crate is never visited.

That line is in fact hidden from docs by default -- because it is a private extern crate. Make it pub and it is visible by default.

1 Like

cargo doc --no-deps will only build documentation for your crate.

1 Like

Thank you