rustdoc-json-to-markdown
🤖 AI-Generated Project: This tool was created entirely by Claude (Anthropic AI). See ATTRIBUTION.md for details.
Convert rustdoc's JSON output to markdown format for LLM consumption and convenient documentation viewing.
Motivation
Rustdoc generates excellent HTML documentation, but for LLM context or text-based viewing, markdown is more convenient. This tool converts rustdoc's JSON output (available via --output-format=json
) into clean, structured markdown files.
Installation
From crates.io (recommended)
From source
Usage
Quick Start
# 1. Generate rustdoc JSON (requires nightly Rust)
# 2. Convert to markdown
# 3. View the generated markdown
Detailed Usage
Step 1: Generate rustdoc JSON
# For a Cargo project (most common)
# For a single file
# For a specific dependency
This creates a JSON file at target/doc/<crate_name>.json
Step 2: Convert to Markdown
# With options
Features
- ✅ Converts all major rustdoc item types
- Structs (with field tables and type information)
- Enums (with variant tables showing kinds: Unit, Tuple, Struct)
- Functions (with complete type signatures)
- Traits (with method listings)
- Type aliases and constants
- Modules
- ✅ Preserves documentation comments (already markdown)
- ✅ Full type formatting for signatures and fields
- ✅ Generates table of contents with links
- ✅ Markdown tables for struct fields and enum variants
- ✅ Generic parameter support
- 🚧 Multi-file output (one file per module)
- 🚧 Cross-reference links between items
- 🚧 External crate links
- 🚧 Trait implementation listings
Legend: ✅ Implemented | 🚧 Planned
Example Output
The tool generates clean, structured markdown with:
Table of Contents:
- --
Struct with Field Table:
**Type:** Struct
Represents a 2D point in space.
**Fields:**
Enum with Variant Table:
**Type:** Enum
**Variants:**
Function with Type Signatures:
**Type:** Function
Adds two numbers together.
\`\`\`rust
fn add(a: i32, b: i32) -> i32
\`\`\`
CLI Options
<INPUT> Path
Project Status
Phase 1 Complete (MVP) - The core functionality is implemented and tested with real-world crates:
- Successfully tested with anyhow, serde_json, and custom crates
- Generates well-formatted markdown with complete type information
- Produces structured documentation suitable for LLM consumption and viewing
Note: The rustdoc JSON format itself is unstable and requires nightly Rust.
See PLAN.md for implementation details and Phase 2 roadmap.
Requirements
- Rust nightly (to generate JSON output from rustdoc)
- Cargo (to build this tool)
Dependencies
rustdoc-types
v0.56 - Type definitions for rustdoc JSON (from crates.io)serde_json
- JSON parsinganyhow
- Error handlingclap
- CLI interface with derive macros
Contributing
This is a personal project exploring rustdoc JSON output. Contributions welcome once the MVP is complete.
License
MIT or Apache-2.0 (same as Rust)