| 29 | |
| 30 | |
| 31 | def expand(text: str) -> str: |
| 32 | out_lines: list[str] = [] |
| 33 | changed = False |
| 34 | for line in text.splitlines(keepends=True): |
| 35 | eol = "" |
| 36 | body = line |
| 37 | if body.endswith("\r\n"): |
| 38 | eol = "\r\n" |
| 39 | body = body[:-2] |
| 40 | elif body.endswith("\n"): |
| 41 | eol = "\n" |
| 42 | body = body[:-1] |
| 43 | elif body.endswith("\r"): |
| 44 | eol = "\r" |
| 45 | body = body[:-1] |
| 46 | |
| 47 | m = PATTERN.match(body) |
| 48 | if not m: |
| 49 | out_lines.append(line) |
| 50 | continue |
| 51 | |
| 52 | indent, inner = m.group(1), m.group(2) |
| 53 | if not inner.strip() or inner.strip() == "*": |
| 54 | out_lines.append(line) |
| 55 | continue |
| 56 | |
| 57 | out_lines.append(f"{indent}/**{eol}") |
| 58 | out_lines.append(f"{indent} * {inner}{eol}") |
| 59 | out_lines.append(f"{indent} */{eol}") |
| 60 | changed = True |
| 61 | |
| 62 | return "".join(out_lines) if changed else text |
| 63 | |
| 64 | |
| 65 | def iter_files() -> list[Path]: |