| 68 | |
| 69 | |
| 70 | def patch_help(s: str, commands: list[str]) -> str: |
| 71 | # Patch some TODOs still not handled correctly below. |
| 72 | pos = 0 |
| 73 | while True: |
| 74 | pos = s.find("global option :option:", pos) |
| 75 | if pos < 0: |
| 76 | break |
| 77 | pos = s.find("<-", pos) |
| 78 | assert pos > 0 |
| 79 | s = s[: pos + 1] + "scenedetect " + s[pos + 1 :] |
| 80 | |
| 81 | for command in [command for command in commands if command not in INFO_COMMANDS]: |
| 82 | |
| 83 | def add_link(_match: re.Match, command: str = command) -> str: |
| 84 | return f":ref:`{command} <command-{command}>`" |
| 85 | |
| 86 | s = re.sub(f"``{command}``(?!\\n)", add_link, s) |
| 87 | return s |
| 88 | |
| 89 | |
| 90 | def generate_title(s: str, level: int = 0, len: int = 72) -> StrGenerator: |