(node: Tag)
| 333 | |
| 334 | |
| 335 | def _code_header_label(node: Tag) -> str: |
| 336 | if node.name in {"h2", "h3"}: |
| 337 | text = re.sub(r"\s+", " ", _plain_code(node)).strip() |
| 338 | return _inline_code(text) if text else "" |
| 339 | |
| 340 | for class_name in ( |
| 341 | "fn", |
| 342 | "associatedtype", |
| 343 | "constant", |
| 344 | "struct", |
| 345 | "enum", |
| 346 | "trait", |
| 347 | "type", |
| 348 | "macro", |
| 349 | "derive", |
| 350 | "attribute", |
| 351 | ): |
| 352 | link = node.find("a", class_=class_name) |
| 353 | if link is None: |
| 354 | continue |
| 355 | text = _clean_text(link.get_text("", strip=True)) |
| 356 | if text: |
| 357 | return _inline_code(text) |
| 358 | |
| 359 | text = re.sub(r"\s+", " ", _plain_code(node)).strip() |
| 360 | return _inline_code(text) if text else "" |
| 361 | |
| 362 | |
| 363 | def _code_header_markdown(node: Tag, page: Page, pages_by_html: dict[Path, Page]) -> str: |
no test coverage detected