Extract description children from the first paragraph if it's a single block. Pattern: _Libraries for foo._ -> "Libraries for foo."
(nodes: list[SyntaxTreeNode])
| 122 | |
| 123 | |
| 124 | def _extract_description_children(nodes: list[SyntaxTreeNode]) -> list[SyntaxTreeNode]: |
| 125 | """Extract description children from the first paragraph if it's a single <em> block. |
| 126 | |
| 127 | Pattern: _Libraries for foo._ -> "Libraries for foo." |
| 128 | """ |
| 129 | if not nodes: |
| 130 | return [] |
| 131 | first = nodes[0] |
| 132 | if first.type != "paragraph": |
| 133 | return [] |
| 134 | for child in first.children: |
| 135 | if child.type == "inline" and len(child.children) == 1: |
| 136 | em = child.children[0] |
| 137 | if em.type == "em": |
| 138 | return em.children |
| 139 | return [] |
| 140 | |
| 141 | |
| 142 | # --- Entry extraction -------------------------------------------------------- |