cargo-doc-md
🤖 AI-Generated Project: Created entirely by Claude (Anthropic AI). See ATTRIBUTION.md.
A Cargo subcommand that generates markdown documentation for Rust crates and their dependencies.
Installation
Requires Rust nightly (uses unstable rustdoc features):
Usage
# Document current crate + all dependencies (like cargo doc)
# Document only dependencies
# Document specific crates
# Custom output directory
# Convert existing rustdoc JSON
Output Structure
target/doc-md/
index.md # Master index
your_crate/
index.md # Crate overview
module1.md # One file per module
module2.md
sub/
nested_module.md
tokio/
index.md
io.md
net.md
serde/
index.md
...
Use Cases
- Provide API documentation to LLMs as context
- Read documentation in your terminal or editor
- Generate offline documentation for your entire dependency tree
- Navigate large codebases with multi-file output
Features
- Multi-file output with one markdown file per module
- Master index listing all documented crates
- Breadcrumb navigation showing module hierarchy
- Module summaries with item counts
- Complete type signatures for all items
- Automatic dependency discovery and documentation
- Handles multiple versions of the same dependency
- Gracefully skips dependencies that fail to build
Options
cargo doc-md [OPTIONS] [CRATES...]
Arguments:
[CRATES...] Specific crate(s) to document (omit for current crate + all deps)
Options:
-o, --output <DIR> Output directory [default: target/doc-md]
--all-deps Document only dependencies (exclude current crate)
--include-private Include private items
--json <FILE> Convert existing rustdoc JSON file
-h, --help Show help
Run cargo doc-md --help for detailed information.
Upgrading from 0.7.x
Breaking changes in 0.8.0:
- Directory structure flattened:
deps/crate/→crate/ - CLI changed:
--deps tokio,serde→tokio serde - JSON conversion: now requires
--jsonflag
Tool auto-migrates old structure on first run. Update your scripts accordingly.
Development
This project uses snapshot testing to ensure output quality and consistency. Run tests with:
When making changes to the output format, review snapshot changes with:
See tests/README.md for more information about the test suite.
License
MIT or Apache-2.0