Transform a help command found by the ``find()`` classmethod.
(self, lines)
| 574 | return cls(line[ix].start, line[-2].start) |
| 575 | |
| 576 | def transform(self, lines): |
| 577 | """Transform a help command found by the ``find()`` classmethod. |
| 578 | """ |
| 579 | |
| 580 | piece = "".join(lines[self.start_line : self.q_line + 1]) |
| 581 | indent, content = piece[: self.start_col], piece[self.start_col :] |
| 582 | lines_before = lines[: self.start_line] |
| 583 | lines_after = lines[self.q_line + 1 :] |
| 584 | |
| 585 | m = _help_end_re.search(content) |
| 586 | if not m: |
| 587 | raise SyntaxError(content) |
| 588 | assert m is not None, content |
| 589 | target = m.group(1) |
| 590 | esc = m.group(3) |
| 591 | |
| 592 | |
| 593 | call = _make_help_call(target, esc) |
| 594 | new_line = indent + call + '\n' |
| 595 | |
| 596 | return lines_before + [new_line] + lines_after |
| 597 | |
| 598 | def make_tokens_by_line(lines:List[str]): |
| 599 | """Tokenize a series of lines and group tokens by line. |