| 123 | |
| 124 | |
| 125 | def _mandoc_markdown(mandoc_path: str, manpage: Path) -> str: |
| 126 | result = subprocess.run( |
| 127 | [mandoc_path, "-T", "markdown", str(manpage)], |
| 128 | cwd=REPO_ROOT, |
| 129 | capture_output=True, |
| 130 | text=True, |
| 131 | check=False, |
| 132 | timeout=60, |
| 133 | ) |
| 134 | if result.returncode != 0: |
| 135 | raise RuntimeError( |
| 136 | result.stderr.strip() or f"mandoc exited {result.returncode}" |
| 137 | ) |
| 138 | if not result.stdout.strip(): |
| 139 | raise RuntimeError("mandoc produced empty markdown") |
| 140 | return result.stdout.rstrip() + "\n" |
| 141 | |
| 142 | |
| 143 | def _line_metrics(markdown: str) -> dict[str, Any]: |