@@ -129,18 +129,48 @@ edition = "2021"
129
129
let mut target_docs_path: Option < PathBuf > = None ;
130
130
let mut found_count = 0 ;
131
131
132
+ // Convert crate name with hyphens to underscores for directory matching
133
+ let expected_dir_name = crate_name. replace ( "-" , "_" ) ;
134
+
132
135
if base_doc_path. is_dir ( ) {
136
+ eprintln ! ( "Looking for documentation in: {}" , base_doc_path. display( ) ) ;
137
+ eprintln ! ( "Target crate directory name: {}" , expected_dir_name) ;
138
+
133
139
for entry_result in fs:: read_dir ( & base_doc_path) ? {
134
140
let entry = entry_result?;
135
141
if entry. file_type ( ) ?. is_dir ( ) {
136
142
let dir_path = entry. path ( ) ;
143
+ let dir_name = dir_path. file_name ( )
144
+ . and_then ( |n| n. to_str ( ) )
145
+ . unwrap_or ( "" ) ;
146
+
147
+ eprintln ! ( " Found directory: {}" , dir_name) ;
148
+
149
+ // Skip the temp crate's own documentation
150
+ if dir_name == "temp_doc_crate" {
151
+ eprintln ! ( " -> Skipping temp_doc_crate" ) ;
152
+ continue ;
153
+ }
154
+
137
155
let index_html_path = dir_path. join ( "index.html" ) ;
138
156
if index_html_path. is_file ( ) {
139
- if target_docs_path. is_none ( ) {
157
+ eprintln ! ( " -> Has index.html" ) ;
158
+
159
+ // Prefer the directory that matches our target crate name
160
+ if dir_name == expected_dir_name {
161
+ eprintln ! ( " -> MATCHES target crate name!" ) ;
140
162
target_docs_path = Some ( dir_path) ;
163
+ found_count = 1 ; // Reset count since we found our target
164
+ break ; // Stop searching, we found what we want
165
+ } else if target_docs_path. is_none ( ) {
166
+ // Keep as fallback if we don't find exact match
167
+ target_docs_path = Some ( dir_path) ;
168
+ found_count += 1 ;
169
+ } else {
170
+ found_count += 1 ;
141
171
}
142
- found_count += 1 ;
143
172
} else {
173
+ eprintln ! ( " -> No index.html" ) ;
144
174
}
145
175
}
146
176
}
@@ -201,7 +231,7 @@ edition = "2021"
201
231
}
202
232
}
203
233
204
- // --- Initialize paths_to_process and explicitly add the root index.html if it exists ---
234
+ // --- Initialize paths_to_process and explicitly add the root index.html if it exists ---
205
235
let mut paths_to_process: Vec < PathBuf > = Vec :: new ( ) ;
206
236
let root_index_path = docs_path. join ( "index.html" ) ;
207
237
if root_index_path. is_file ( ) {
@@ -311,4 +341,4 @@ edition = "2021"
311
341
312
342
eprintln ! ( "Finished document loading. Found {} final documents." , documents. len( ) ) ;
313
343
Ok ( documents)
314
- }
344
+ }
0 commit comments