| 386 | .map_err(|err| io::Error::new(io::ErrorKind::InvalidData, err))?; |
| 387 | let slug = slug_from_rel(rel); |
| 388 | push_doc(collection, &path, slug, out)?; |
| 389 | } |
| 390 | Ok(()) |
| 391 | } |
| 392 | |
| 393 | fn collect_demo_docs(slug_prefix: &str, dir: &Path, out: &mut Vec<DocOut>) -> io::Result<()> { |
| 394 | let Ok(entries) = fs::read_dir(dir) else { |
| 395 | return Ok(()); |
| 396 | }; |
| 397 | for entry in entries.flatten() { |
| 398 | let path = entry.path(); |
| 399 | if path.extension().and_then(|ext| ext.to_str()) != Some("md") { |
| 400 | continue; |
| 401 | } |
| 402 | let stem = path |
| 403 | .file_stem() |
| 404 | .and_then(|stem| stem.to_str()) |
| 405 | .unwrap_or(""); |
| 406 | if stem.eq_ignore_ascii_case("README") { |
| 407 | push_doc_with_link_slug( |
| 408 | "docs", |
| 409 | &path, |
| 410 | slug_prefix.to_string(), |
| 411 | format!("{slug_prefix}/index"), |
| 412 | out, |
| 413 | )?; |
| 414 | } else if !stem.is_empty() { |
| 415 | let slug = format!("{slug_prefix}/{stem}"); |
| 416 | push_doc("docs", &path, slug, out)?; |
| 417 | } |