Can I skip a specific crate on cargo doc?


#1

When I run cargo doc on a new build it takes hours to document the winapi crate. I don’t think I would ever need to check its documentation as I never use it directally in my own code.

Can I skip it to save hours of build time?


#2
        --exclude <SPEC>...         Exclude packages from the build

I believe you must also manually pass the implied --all if you use --exclude.


#3

I have tried that but it seems does not do anything – It still try to build winapi and spend hours on it.

When building documents, the dependency requirements are a bit different - only crates that have items re-exported should be considered a dependency. If we adapt to this strategy, I believe the dependency tree will be much simpler and the build will be much faster.


#4

Unfortunately the set of items that are re-exported is not available to Cargo. When PubPriv Dependency implemented and is widely used, then it is definitely worth trying. In the meantime, I don’t know if RustDoc can make this happen, but I suspect it is looking at the tree in the wrong order.

Another approach that has been discussed is making the docs.rs build setup into a widely useable cargo subcommand. docs.rs needs to build the docs for the new library but for all dependencies link to the already built and hosted version.


#5

IMHO, this is not the job of Cargo. It is the job of Rustdoc to determine whether a referenced crate is worth to build with Rustdoc or just usual build would be enough. Then this information will feed back to Cargo, to launch the correct comment for the referenced crate.

Image that we have rustdoc --generate-dependency > cargodoc.toml.