# Build Rust API docs with the intended package and feature set

Canonical: https://githtml.com/guides/cargo-doc-feature-scope-review
Published: 2026-11-23
Publisher: WaveTech LLC / gitHtml

Choose the package, features, and dependency scope deliberately when running cargo doc, then verify that the resulting reference matches the API users can actually build. A successful documentation build for one feature set does not establish every configuration. Review generated pages and examples separately, and do not assume no-deps means the build performs no dependency-related work.

## Define the API configuration readers use

Identify the crate or workspace package, target assumptions, and enabled features that correspond to the documented release. Feature-gated items can appear or disappear based on the build configuration, so a reference generated with every feature is not automatically the most accurate public guide. Inspect the project's maintained documentation instructions and Cargo configuration. Record whether the guide describes defaults, a named feature combination, or a specific platform. Avoid presenting an experimental item as universally available. Before building an unfamiliar workspace, review build scripts and dependencies as code that may run during the process, using an appropriate local environment.

## Run a focused documentation build

The sample documents the selected package without generating separate dependency documentation. Replace the placeholder package with an actual workspace package and add only the verified feature flags needed for the intended contract. Inspect the installed toolchain and project lockfile policy. Keep the output associated with the source revision and configuration. Read compiler and rustdoc diagnostics rather than assuming a page opening in the browser means all references resolved. If an item is missing, compare its visibility and conditional compilation with the chosen feature set before changing source comments. A scope mismatch should be diagnosed as such, not hidden by enabling unrelated features.

````sh
cargo --version
cargo doc --package sample_package --no-deps
````

## Verify the public surface and examples

Inspect a representative type, function, trait implementation, and feature-gated item in the generated reference. Confirm availability notes and links are clear to a user who arrives directly at that page. Test documentation examples through the project's appropriate safe test command when required; generating docs is not equivalent to running every example. Check for private implementation details if additional visibility flags were used for an internal review. Preserve the generated directory when sharing a site artifact, or create a separately verified excerpt for a smaller reading task. Record the exact package and feature set in the handoff so readers know which contract the reference represents. If several feature combinations are supported, keep separate labeled review results for them. Combining observations into one undifferentiated reference can conceal which APIs are actually available to each reader.

1. Record package, toolchain, target assumptions, and intended feature set.
2. Review build scripts before running documentation for unfamiliar code.
3. Use a focused command and inspect diagnostics and missing-item causes.
4. Verify public and feature-gated items, and test examples separately where appropriate.

## Sources and further reading

- [Cargo doc command](https://doc.rust-lang.org/cargo/commands/cargo-doc.html)

## Related guides

- [Fix Docusaurus MDX errors caused by literal braces and angle brackets](https://githtml.com/guides/docusaurus-mdx-angle-bracket-errors)
- [Fix Docusaurus sidebar links that use the wrong document ID](https://githtml.com/guides/docusaurus-sidebar-document-id)
- [Edit the right Docusaurus documentation version](https://githtml.com/guides/docusaurus-versioned-docs-edit-target)
- [Generate Doxygen HTML from a deliberate source scope](https://githtml.com/guides/doxygen-html-input-scope-review)

Editorial approach: https://githtml.com/guides/about
