(doc_root: Path, output_dir: Path)
| 199 | |
| 200 | |
| 201 | def _discover_pages(doc_root: Path, output_dir: Path) -> dict[Path, Page]: |
| 202 | pages: dict[Path, Page] = {} |
| 203 | for crate_name, crate_dir_name, _description in CRATES: |
| 204 | crate_dir = doc_root / crate_dir_name |
| 205 | if not crate_dir.is_dir(): |
| 206 | raise SystemExit(f"rustdoc crate output not found: {crate_dir}") |
| 207 | for html_path in sorted(crate_dir.rglob("*.html")): |
| 208 | if html_path.name == "all.html": |
| 209 | continue |
| 210 | if 'id="main-content"' not in html_path.read_text(encoding="utf-8", errors="ignore"): |
| 211 | continue |
| 212 | output_rel = _output_relative(crate_name, crate_dir, html_path) |
| 213 | url_rel = _url_relative(crate_name, crate_dir, html_path) |
| 214 | pages[html_path.resolve()] = Page( |
| 215 | html_path=html_path.resolve(), |
| 216 | output_path=output_dir / output_rel, |
| 217 | url=_page_url(url_rel), |
| 218 | crate_name=crate_name, |
| 219 | crate_dir_name=crate_dir_name, |
| 220 | ) |
| 221 | return pages |
| 222 | |
| 223 | |
| 224 | def _resolve_href(page: Page, href: str, pages_by_html: dict[Path, Page]) -> str | None: |
no test coverage detected