深度优先扁平化所有 sections。
(sections: list[Section])
| 330 | |
| 331 | |
| 332 | def flatten_sections(sections: list[Section]) -> list[Section]: |
| 333 | """深度优先扁平化所有 sections。""" |
| 334 | out: list[Section] = [] |
| 335 | def walk(s: Section): |
| 336 | out.append(s) |
| 337 | for c in s.children: |
| 338 | walk(c) |
| 339 | for s in sections: |
| 340 | walk(s) |
| 341 | return out |
| 342 | |
| 343 | |
| 344 | def find_section_by_anchor(sections: list[Section], anchor: str) -> Optional[Section]: |
no test coverage detected