# Can I skip a specific crate on cargo doc?

**URL:** https://internals.rust-lang.org/t/can-i-skip-a-specific-crate-on-cargo-doc/9364
**Category:** cargo
**Created:** [February 5, 2019, 9:50am UTC](https://internals.rust-lang.org/t/can-i-skip-a-specific-crate-on-cargo-doc/9364 "2019-02-05T09:50:00Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![earthengine](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/earthengine/32/2577_2.png) [@earthengine](https://internals.rust-lang.org/u/earthengine)
#### Post date: [February 5, 2019, 9:50am UTC](https://internals.rust-lang.org/t/can-i-skip-a-specific-crate-on-cargo-doc/9364/1 "2019-02-05T09:50:00Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Nemo157](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/nemo157/32/11585_2.png) [@Nemo157](https://internals.rust-lang.org/u/Nemo157)
#### Post date: [February 5, 2019, 10:05am UTC](https://internals.rust-lang.org/t/can-i-skip-a-specific-crate-on-cargo-doc/9364/2 "2019-02-05T10:05:46Z")

</div>

```rust
        --exclude <SPEC>... Exclude packages from the build

```

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

---

<div class="post-metadata">

### Author: ![earthengine](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/earthengine/32/2577_2.png) [@earthengine](https://internals.rust-lang.org/u/earthengine)
#### Post date: [February 8, 2019, 12:44am UTC](https://internals.rust-lang.org/t/can-i-skip-a-specific-crate-on-cargo-doc/9364/3 "2019-02-08T00:44:21Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Eh2406](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/eh2406/32/4839_2.png) [@Eh2406](https://internals.rust-lang.org/u/Eh2406)
#### Post date: [February 8, 2019, 2:12am UTC](https://internals.rust-lang.org/t/can-i-skip-a-specific-crate-on-cargo-doc/9364/4 "2019-02-08T02:12:31Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![earthengine](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/earthengine/32/2577_2.png) [@earthengine](https://internals.rust-lang.org/u/earthengine)
#### Post date: [February 8, 2019, 2:44am UTC](https://internals.rust-lang.org/t/can-i-skip-a-specific-crate-on-cargo-doc/9364/5 "2019-02-08T02:44:37Z")

</div>

> [@Eh2406](#):
>
> Unfortunately the set of items that are re-exported is not available to Cargo

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`.

---

<div class="post-metadata">

### Author: ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)
#### Post date: [May 9, 2019, 2:44am UTC](https://internals.rust-lang.org/t/can-i-skip-a-specific-crate-on-cargo-doc/9364/6 "2019-05-09T02:44:38Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
