How to exclude libc from rustdoc?


#1

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:

#[doc(hidden)]
extern crate libc;

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


#2

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.


#3

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


#4

Thank you