(modules: list[ModuleDoc])
| 307 | |
| 308 | |
| 309 | def _sibling_positions(modules: list[ModuleDoc]) -> dict[str, int]: |
| 310 | by_parent: dict[tuple[str, ...], list[ModuleDoc]] = {} |
| 311 | for module in modules: |
| 312 | nav_parts = _nav_parts(module) |
| 313 | parent = tuple(nav_parts[:-1]) if len(_module_parts(module)) > 1 else () |
| 314 | by_parent.setdefault(parent, []).append(module) |
| 315 | |
| 316 | positions: dict[str, int] = {} |
| 317 | for siblings in by_parent.values(): |
| 318 | siblings.sort(key=_sibling_sort_key) |
| 319 | for position, module in enumerate(siblings, start=1): |
| 320 | positions[module.name] = position |
| 321 | return positions |
| 322 | |
| 323 | |
| 324 | def _write_index(output_dir: Path, modules: list[ModuleDoc]) -> None: |
no test coverage detected