Find the first help command (foo?) in the cell.
(cls, tokens_by_line)
| 562 | |
| 563 | @classmethod |
| 564 | def find(cls, tokens_by_line): |
| 565 | """Find the first help command (foo?) in the cell. |
| 566 | """ |
| 567 | for line in tokens_by_line: |
| 568 | # Last token is NEWLINE; look at last but one |
| 569 | if len(line) > 2 and line[-2].string == '?': |
| 570 | # Find the first token that's not INDENT/DEDENT |
| 571 | ix = 0 |
| 572 | while line[ix].type in {tokenize.INDENT, tokenize.DEDENT}: |
| 573 | ix += 1 |
| 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. |
no outgoing calls