rustdown 0.0.1

Breakdown code structure & usages by module in a crate, a workspace, or an arbitrary ecosystem of crate(s)/workspace(s)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
<!-- Generated by rustdown at 2025-09-26 14:42:14 UTC -->
<!-- Generated from rustdoc JSON output -->
<!-- Git commit: f6ca5cbc (dirty) -->
<!-- Commit timestamp: 2025-09-26T07:26:07-07:00 -->

# Crate `rustdown` Module Structure

```
rustdown
├── manifest_dir (3 struct: CrateManifest, GitInfo, ManifestDir)
├── markdown (4 fn: format_generation_header, format_usages, get_relative_source_path, rustdoc_to_markdown, 1 struct: MarkdownOptions)
├── parser (20 struct: ConstantRef, FunctionRef, MacroRef, ModuleRef, ParsedAssociatedConstant, ParsedAssociatedType, ParsedCrate, ParsedField, ParsedFunction, ParsedGenerics, ParsedMethod, ParsedModule, ParsedParameter, ParsedSignature, ParsedTrait, ParsedType, ParsedVariant, SourceLocation, TraitRef, TypeRef, 5 enum: GenericParam, MacroKind, ParsedVisibility, TypeKind, VariantKind)
├── printer (1 fn: print_module_tree)
├── rust_analyzer (4 fn: find_identifier_position, find_item_usages, initialize_ra_session, shutdown_ra_session, 2 struct: ReferenceInfo, RustAnalyzerSession, 2 const: RA_SESSION, USAGE_CACHE)
└── rustdoc (1 fn: generate_rustdoc_json)
```

# Root `rustdown` Module
Rustdown - Convert Rust documentation JSON to Markdown

This crate provides functionality to convert rustdoc's JSON output into
readable Markdown documentation optimized for LLM consumption.
# Module `crate::manifest_dir`
## [`struct ManifestDir`]src/manifest_dir.rs#L9

```
struct ManifestDir {
    manifest_dir: std::path::PathBuf,
    members: Vec<CrateManifest>,
    is_workspace: bool,
}
```

### [`ManifestDir::detect`]src/manifest_dir.rs#L38

`fn detect(start_path: &Path) -> Result<Self>`

### [`ManifestDir::get_git_info`]src/manifest_dir.rs#L132

`fn get_git_info(self: &Self) -> Result<Option<GitInfo>>`

## [`struct CrateManifest`]src/manifest_dir.rs#L16

```
struct CrateManifest {
    name: String,
    manifest_path: std::path::PathBuf,
    relative_path: std::path::PathBuf,
}
```

## [`struct GitInfo`]src/manifest_dir.rs#L210

```
struct GitInfo {
    commit_hash: String,
    commit_timestamp: String,
    is_dirty: bool,
}
```

# Module `crate::markdown`
## [`struct MarkdownOptions`]src/markdown.rs#L12

Options for markdown generation

```
struct MarkdownOptions {
    compact: bool,
    manifest_path: Option<std::path::PathBuf>,
    max_tree_items: Option<usize>,
    output_path: Option<std::path::PathBuf>,
    show_signatures: bool,
    show_tree: bool,
    show_usages: bool,
    workspace_relative_path: Option<std::path::PathBuf>,
}
```

## [`fn get_relative_source_path`]src/markdown.rs#L50

Get the source file path relative to the crate root

When rustdoc generates JSON for workspace members, paths are relative to the workspace root.
This function makes paths relative to where the rustdown.md file will be placed.

In compact mode, returns only the filename instead of the full path.

# Examples
- File in same crate `crates/utils`: `crates/utils/src/file.rs``src/file.rs`
- File in other crate from `crates/utils`: `crates/cli/src/main.rs``../cli/src/main.rs`
- Standalone crate: `src/main.rs``src/main.rs` (unchanged)
- Compact mode: `src/file/operations.rs``operations.rs`

`fn get_relative_source_path(source_path: &std::path::Path, options: &MarkdownOptions) -> std::path::PathBuf`

## [`fn rustdoc_to_markdown`]src/markdown.rs#L101

Convert rustdoc JSON data to Markdown format

`fn rustdoc_to_markdown(rustdoc: rustdoc_types::Crate, options: MarkdownOptions) -> String`

## [`fn format_generation_header`]src/markdown.rs#L170

`fn format_generation_header(git_info: Option<&manifest_dir::GitInfo>) -> String`

## [`fn format_usages`]src/markdown.rs#L808

Format usage references for markdown output

`fn format_usages(references: &[rust_analyzer::ReferenceInfo], options: &MarkdownOptions) -> String`

# Module `crate::parser`
## [`struct ParsedCrate`]src/parser.rs#L11

Represents a parsed crate with all its modules and items organized hierarchically

```
struct ParsedCrate {
    /// The name of the crate
    name: String,
    /// The version of the crate if specified
    version: Option<String>,
    /// The root module containing all items
    root_module: ParsedModule,
    /// All modules indexed by their ID for quick lookup
    modules_by_id: std::collections::HashMap<rustdoc_types::Id, ParsedModule>,
    /// All types (structs, enums, unions) indexed by ID
    types_by_id: std::collections::HashMap<rustdoc_types::Id, ParsedType>,
    /// All functions indexed by ID
    functions_by_id: std::collections::HashMap<rustdoc_types::Id, ParsedFunction>,
    /// All traits indexed by ID
    traits_by_id: std::collections::HashMap<rustdoc_types::Id, ParsedTrait>,
}
```

### [`ParsedCrate::is_inline_module`]src/parser.rs#L295

Check if a module is defined inline within another file

`fn is_inline_module(span: &Option<rustdoc_types::Span>, module_name: &str) -> bool`

### [`ParsedCrate::from_rustdoc`]src/parser.rs#L324

Parse a rustdoc JSON crate into our rich data structure

`fn from_rustdoc(rustdoc: &Crate) -> Self`

### [`ParsedCrate::parse_module_items`]src/parser.rs#L369

Parse items within a module

`fn parse_module_items(self: &mut Self, rustdoc: &Crate, item_ids: &[Id], parent_module: &mut ParsedModule, parent_path: &str)`

### [`ParsedCrate::parse_struct`]src/parser.rs#L536

`fn parse_struct(self: &Self, item: &Item, struct_: &rustdoc_types::Struct, rustdoc: &Crate, path: &str) -> ParsedType`

### [`ParsedCrate::parse_enum`]src/parser.rs#L631

`fn parse_enum(self: &Self, item: &Item, enum_: &rustdoc_types::Enum, rustdoc: &Crate, path: &str) -> ParsedType`

### [`ParsedCrate::parse_union`]src/parser.rs#L742

`fn parse_union(self: &Self, item: &Item, union_: &rustdoc_types::Union, rustdoc: &Crate, path: &str) -> ParsedType`

### [`ParsedCrate::parse_function`]src/parser.rs#L782

`fn parse_function(self: &Self, item: &Item, func: &rustdoc_types::Function, rustdoc: &Crate, path: &str) -> ParsedFunction`

### [`ParsedCrate::parse_trait`]src/parser.rs#L801

`fn parse_trait(self: &Self, item: &Item, trait_: &rustdoc_types::Trait, rustdoc: &Crate, path: &str) -> ParsedTrait`

## [`struct ParsedModule`]src/parser.rs#L30

Represents a module with its items

```
struct ParsedModule {
    /// Module ID
    id: rustdoc_types::Id,
    /// Module name (None for root module)
    name: Option<String>,
    /// Full path to this module (e.g., "crate::foo::bar")
    path: String,
    /// Documentation
    docs: Option<String>,
    /// Source location
    source: Option<SourceLocation>,
    /// Whether this module is defined inline within another file
    is_inline: bool,
    /// Child modules
    submodules: Vec<ModuleRef>,
    /// Types defined in this module (structs, enums, unions, type aliases)
    types: Vec<TypeRef>,
    /// Functions defined in this module
    functions: Vec<FunctionRef>,
    /// Traits defined in this module
    traits: Vec<TraitRef>,
    /// Constants and statics
    constants: Vec<ConstantRef>,
    /// Macros
    macros: Vec<MacroRef>,
}
```

## [`struct ModuleRef`]src/parser.rs#L59

Reference to a module

```
struct ModuleRef {
    id: rustdoc_types::Id,
    name: String,
    path: String,
    is_inline: bool,
}
```

## [`struct TypeRef`]src/parser.rs#L68

Reference to a type

```
struct TypeRef {
    id: rustdoc_types::Id,
    name: String,
    kind: TypeKind,
}
```

## [`struct FunctionRef`]src/parser.rs#L76

Reference to a function

```
struct FunctionRef {
    id: rustdoc_types::Id,
    name: String,
    is_async: bool,
    is_unsafe: bool,
    is_const: bool,
}
```

## [`struct TraitRef`]src/parser.rs#L86

Reference to a trait

```
struct TraitRef {
    id: rustdoc_types::Id,
    name: String,
    is_unsafe: bool,
    is_auto: bool,
}
```

## [`struct ConstantRef`]src/parser.rs#L95

Reference to a constant or static

```
struct ConstantRef {
    id: rustdoc_types::Id,
    name: String,
    is_static: bool,
}
```

## [`struct MacroRef`]src/parser.rs#L103

Reference to a macro

```
struct MacroRef {
    id: rustdoc_types::Id,
    name: String,
    kind: MacroKind,
}
```

## [`struct ParsedType`]src/parser.rs#L111

Represents a parsed type (struct, enum, union, or type alias)

```
struct ParsedType {
    id: rustdoc_types::Id,
    name: String,
    path: String,
    kind: TypeKind,
    docs: Option<String>,
    source: Option<SourceLocation>,
    visibility: ParsedVisibility,
    generics: Option<ParsedGenerics>,
    /// Methods and associated functions
    methods: Vec<ParsedMethod>,
    /// Implemented traits
    implemented_traits: Vec<String>,
    /// For enums: variants
    variants: Vec<ParsedVariant>,
    /// For structs: fields
    fields: Vec<ParsedField>,
}
```

## [`enum TypeKind`]src/parser.rs#L132

Kind of type

```
enum TypeKind {
    Struct,
    Enum,
    Union,
    TypeAlias,
}
```

## [`struct ParsedFunction`]src/parser.rs#L141

Represents a parsed function

```
struct ParsedFunction {
    id: rustdoc_types::Id,
    name: String,
    path: String,
    docs: Option<String>,
    source: Option<SourceLocation>,
    visibility: ParsedVisibility,
    signature: ParsedSignature,
    generics: Option<ParsedGenerics>,
}
```

## [`struct ParsedSignature`]src/parser.rs#L154

Function signature details

```
struct ParsedSignature {
    is_async: bool,
    is_unsafe: bool,
    is_const: bool,
    is_extern: bool,
    abi: Option<String>,
    parameters: Vec<ParsedParameter>,
    return_type: Option<String>,
}
```

### [`ParsedSignature::from_function`]src/parser.rs#L958

`fn from_function(func: &rustdoc_types::Function, rustdoc: &Crate) -> Self`

## [`struct ParsedParameter`]src/parser.rs#L166

Function parameter

```
struct ParsedParameter {
    name: String,
    type_str: String,
}
```

## [`struct ParsedTrait`]src/parser.rs#L173

Represents a parsed trait

```
struct ParsedTrait {
    id: rustdoc_types::Id,
    name: String,
    path: String,
    docs: Option<String>,
    source: Option<SourceLocation>,
    visibility: ParsedVisibility,
    is_unsafe: bool,
    is_auto: bool,
    generics: Option<ParsedGenerics>,
    /// Required methods
    required_methods: Vec<ParsedMethod>,
    /// Provided methods (with default implementation)
    provided_methods: Vec<ParsedMethod>,
    /// Associated types
    associated_types: Vec<ParsedAssociatedType>,
    /// Associated constants
    associated_constants: Vec<ParsedAssociatedConstant>,
    /// Types that implement this trait
    implementors: Vec<String>,
}
```

## [`struct ParsedMethod`]src/parser.rs#L197

Method or associated function

```
struct ParsedMethod {
    id: rustdoc_types::Id,
    name: String,
    docs: Option<String>,
    signature: ParsedSignature,
    is_default: bool,
}
```

## [`struct ParsedAssociatedType`]src/parser.rs#L207

Associated type in a trait

```
struct ParsedAssociatedType {
    id: rustdoc_types::Id,
    name: String,
    docs: Option<String>,
    bounds: Vec<String>,
    default: Option<String>,
}
```

## [`struct ParsedAssociatedConstant`]src/parser.rs#L217

Associated constant in a trait

```
struct ParsedAssociatedConstant {
    id: rustdoc_types::Id,
    name: String,
    docs: Option<String>,
    type_str: String,
    default: Option<String>,
}
```

## [`struct ParsedVariant`]src/parser.rs#L227

Enum variant

```
struct ParsedVariant {
    id: rustdoc_types::Id,
    name: String,
    docs: Option<String>,
    kind: VariantKind,
    discriminant: Option<String>,
}
```

## [`enum VariantKind`]src/parser.rs#L237

Variant kind

```
enum VariantKind {
    Plain,
    Tuple(Vec<String>),
    Struct(Vec<ParsedField>),
}
```

## [`struct ParsedField`]src/parser.rs#L245

Struct or variant field

```
struct ParsedField {
    id: Option<rustdoc_types::Id>,
    name: Option<String>,
    type_str: String,
    docs: Option<String>,
    visibility: ParsedVisibility,
}
```

## [`enum ParsedVisibility`]src/parser.rs#L255

Parsed visibility

```
enum ParsedVisibility {
    Public,
    Private,
    Crate,
    Restricted(String),
}
```

### [`ParsedVisibility::from_visibility`]src/parser.rs#L907

`fn from_visibility(vis: &Visibility) -> Self`

## [`struct ParsedGenerics`]src/parser.rs#L264

Generic parameters

```
struct ParsedGenerics {
    params: Vec<GenericParam>,
    where_predicates: Vec<String>,
}
```

### [`ParsedGenerics::from_generics`]src/parser.rs#L918

`fn from_generics(generics: &rustdoc_types::Generics, _context: T) -> Option<Self>`

## [`enum GenericParam`]src/parser.rs#L271

Generic parameter

```
enum GenericParam {
    Type {
        name: String,
        bounds: Vec<String>,
    },
    Lifetime {
        name: String,
        bounds: Vec<String>,
    },
    Const {
        name: String,
        type_: String,
    },
}
```

## [`struct SourceLocation`]src/parser.rs#L279

Source location

```
struct SourceLocation {
    file: String,
    line: usize,
    column: usize,
}
```

### [`SourceLocation::from_span`]src/parser.rs#L897

`fn from_span(span: &Option<rustdoc_types::Span>) -> Option<Self>`

## [`enum MacroKind`]src/parser.rs#L287

Macro kind

```
enum MacroKind {
    Declarative,
    ProcMacro,
    Derive,
    Attribute,
}
```

# Module `crate::printer`
## [`fn print_module_tree`]src/printer.rs#L63

`fn print_module_tree(module: &crate::parser::ParsedModule, crate_data: &crate::ParsedCrate, rustdoc: &rustdoc_types::Crate, indent: usize, crate_root: Option<&std::path::Path>)`

# Module `crate::rust_analyzer`
## [`struct ReferenceInfo`]src/rust_analyzer.rs#L11

```
struct ReferenceInfo {
    file_path: String,
    line: u32,
    column: u32,
}
```

## [`struct RustAnalyzerSession`]src/rust_analyzer.rs#L17

```
struct RustAnalyzerSession {
    root_path: std::path::PathBuf,
}
```

### [`RustAnalyzerSession::new`]src/rust_analyzer.rs#L25

`fn new(crate_path: &Path) -> Result<Self, Box<dyn std::error::Error>>`

### [`RustAnalyzerSession::open_document`]src/rust_analyzer.rs#L192

`fn open_document(self: &mut Self, file_path: &Path) -> Result<(), Box<dyn std::error::Error>>`

### [`RustAnalyzerSession::wait_for_indexing`]src/rust_analyzer.rs#L214

`fn wait_for_indexing(self: &mut Self) -> Result<(), Box<dyn std::error::Error>>`

### [`RustAnalyzerSession::wait_for_indexing_with_verification`]src/rust_analyzer.rs#L218

`fn wait_for_indexing_with_verification(self: &mut Self, crate_path: &Path, test_items: &[(Id, String, PathBuf, u32, ItemEnum)]) -> Result<(), Box<dyn std::error::Error>>`

### [`RustAnalyzerSession::wait_for_indexing_with_modules`]src/rust_analyzer.rs#L373

`fn wait_for_indexing_with_modules(self: &mut Self, _module_names: &[String]) -> Result<(), Box<dyn std::error::Error>>`

### [`RustAnalyzerSession::find_references`]src/rust_analyzer.rs#L587

`fn find_references(self: &mut Self, file_path: &Path, line: u32, column: u32) -> Result<Vec<ReferenceInfo>, Box<dyn std::error::Error>>`

### [`RustAnalyzerSession::shutdown`]src/rust_analyzer.rs#L653

`fn shutdown(self: Self) -> Result<(), Box<dyn std::error::Error>>`

## [`fn find_identifier_position`]src/rust_analyzer.rs#L673

`fn find_identifier_position(crate_path: &std::path::Path, file_path: &std::path::Path, line: u32, item_name: &str, item_kind: &rustdoc_types::ItemEnum) -> (u32, u32)`

## [`fn initialize_ra_session`]src/rust_analyzer.rs#L745

Initialize rust-analyzer session for finding usages with ParsedCrate

`fn initialize_ra_session(crate_path: &std::path::Path, rustdoc: &rustdoc_types::Crate, workspace_relative_path: Option<&std::path::PathBuf>) -> Result<(), Box<dyn std::error::Error>>`

## [`fn shutdown_ra_session`]src/rust_analyzer.rs#L851

Shutdown the rust-analyzer session

`fn shutdown_ra_session() -> Result<(), Box<dyn std::error::Error>>`

## [`fn find_item_usages`]src/rust_analyzer.rs#L861

Find all usages of an item

`fn find_item_usages(item: &rustdoc_types::Item, crate_path: &std::path::Path, _rustdoc: &rustdoc_types::Crate) -> Vec<ReferenceInfo>`

## [`const RA_SESSION`]src/rust_analyzer.rs#L738

## [`const USAGE_CACHE`]src/rust_analyzer.rs#L738

# Module `crate::rustdoc`
## [`fn generate_rustdoc_json`]src/rustdoc.rs#L5

`fn generate_rustdoc_json(manifest_path: Option<&std::path::Path>, target_dir: Option<&std::path::Path>, document_private_items: bool, features: &[String], all_features: bool) -> Result<String>`