(page: Page, pages_by_html: dict[Path, Page], position: int)
| 563 | |
| 564 | |
| 565 | def _render_page(page: Page, pages_by_html: dict[Path, Page], position: int) -> str: |
| 566 | soup = BeautifulSoup(page.html_path.read_text(encoding="utf-8"), "html.parser") |
| 567 | content = soup.select_one("#main-content") |
| 568 | if content is None: |
| 569 | raise SystemExit(f"rustdoc main content not found: {page.html_path}") |
| 570 | _remove_noisy_sections(content) |
| 571 | |
| 572 | body = _remove_duplicate_top_level_sections(_block_markdown(content, page, pages_by_html).strip()) |
| 573 | description = _description(soup) |
| 574 | lines = [ |
| 575 | frontmatter( |
| 576 | _page_title(soup, page), |
| 577 | description, |
| 578 | position, |
| 579 | sidebar_title=_sidebar_title(soup, page), |
| 580 | slug=page.url if _needs_explicit_slug(page) else None, |
| 581 | normalize=_ascii, |
| 582 | ), |
| 583 | ] |
| 584 | lines.append(f"{GENERATED_BY}\n\n") |
| 585 | if body: |
| 586 | lines.append(body + "\n") |
| 587 | return "".join(lines) |
| 588 | |
| 589 | |
| 590 | def _item_order(index_html: Path, pages_by_html: dict[Path, Page]) -> dict[Path, int]: |
no test coverage detected