Find the first help command (foo?) in the cell.
(cls, tokens_by_line)
| 428 | |
| 429 | @classmethod |
| 430 | def find(cls, tokens_by_line): |
| 431 | """Find the first help command (foo?) in the cell. |
| 432 | """ |
| 433 | for line in tokens_by_line: |
| 434 | # Last token is NEWLINE; look at last but one |
| 435 | if len(line) > 2 and line[-2].string == '?': |
| 436 | # Find the first token that's not INDENT/DEDENT |
| 437 | ix = 0 |
| 438 | while line[ix].type in {tokenize.INDENT, tokenize.DEDENT}: |
| 439 | ix += 1 |
| 440 | return cls(line[ix].start, line[-2].start) |
| 441 | |
| 442 | def transform(self, lines): |
| 443 | """Transform a help command found by the ``find()`` classmethod. |
no outgoing calls