| name | rust-crate-docs |
| description | Read and understand Rust crate documentation from crates.io or local crates. Use when needing to understand how to use a crate, find API documentation, check version compatibility, or understand crate features. Handles cargo doc, docs.rs, local documentation, and dependency information. |
Reading Rust Crate Documentation
Guidelines for accessing and understanding Rust crate documentation from various sources.
When to Use This Skill
- Understanding how to use a crate's API
- Finding documentation for a dependency
- Checking version compatibility
- Understanding crate features
- Looking up function signatures and examples
- Checking for breaking changes between versions
Methods for Accessing Documentation
1. Generate Local Documentation
Build documentation for all dependencies:
cargo doc --open
cargo doc --package <crate-name> --open
cargo doc --no-deps
cargo doc --workspace
The documentation will be available at target/doc/<crate-name>/index.html.
2. Online Documentation (docs.rs)
For published crates, documentation is available at:
https://docs.rs/<crate-name>/<version>/
https://docs.rs/<crate-name>/ (latest version)
Example:
https://docs.rs/serde/1.0/
https://docs.rs/polars/
3. Crate Information
Get information about dependencies:
cargo tree
cargo tree --package <crate-name>
cargo metadata --format-version 1
cargo tree --package <crate-name> --depth 0
4. Read Local Crate Documentation
For workspace crates or local dependencies:
cargo doc --package <workspace-crate> --open
Reading Documentation Effectively
Understanding API Structure
- Start with the crate root - Check
index.html or main module docs
- Look for examples - Many crates have examples in their docs
- Check feature flags - Understand what features enable what functionality
- Read trait documentation - Traits often define the main API patterns
Finding Specific Information
- Functions: Look in module documentation or search the docs
- Types: Check struct/enum documentation
- Traits: Look for trait definitions and implementations
- Examples: Often in
examples/ section or inline in docs
Common Documentation Patterns
Checking Version Compatibility
From Cargo.toml
[dependencies]
crate-name = "1.0"
crate-name = "^1.0"
crate-name = "~1.0"
crate-name = "1.0.0"
Check Available Versions
cargo search <crate-name>
Understanding Feature Flags
Many crates use feature flags to enable optional functionality:
[dependencies]
crate-name = { version = "1.0", features = ["feature1", "feature2"] }
Check the crate's Cargo.toml or documentation for available features:
- Often documented in crate-level docs
- May be in a
FEATURES.md file
- Check
Cargo.toml in the crate source
Reading Documentation in Code
When reading code that uses a crate:
- Check imports - See what's being imported
- Follow the types - Understand the type signatures
- Look for examples - In the crate's examples directory
- Check tests - Tests often show usage patterns
Important Rules
- Use local docs first -
cargo doc --open is fastest for dependencies
- Check version - Make sure you're reading docs for the correct version
- Read examples - Examples show real usage patterns
- Check features - Some APIs require specific features to be enabled
- Understand traits - Many Rust APIs are trait-based
Examples from Project
For this workspace, documentation is available for:
flow-fcs: cargo doc --package fcs --open
peacoqc-rs: cargo doc --package peacoqc-rs --open
plots: cargo doc --package plots --open
Troubleshooting
Docs Not Generating
cargo clean
cargo doc
cargo tree --package <crate-name>
Wrong Version in Docs
cargo doc --package <crate-name> --open
cargo tree --package <crate-name> --depth 0
Missing Features
If documentation shows features you don't have access to:
- Check
Cargo.toml for feature flags
- Enable features:
cargo doc --features <feature> --open
- Check crate's feature documentation