506 Private method to extract a docstring given a module source. |
506 Private method to extract a docstring given a module source. |
507 |
507 |
508 @param source source to parse (list of string) |
508 @param source source to parse (list of string) |
509 @return context of extracted docstring (DocStyleContext) |
509 @return context of extracted docstring (DocStyleContext) |
510 """ |
510 """ |
511 for kind, value, (line, char), _, _ in tokenize.generate_tokens( |
511 for kind, value, (line, _char), _, _ in tokenize.generate_tokens( |
512 StringIO("".join(source)).readline): |
512 StringIO("".join(source)).readline): |
513 if kind in [tokenize.COMMENT, tokenize.NEWLINE, tokenize.NL]: |
513 if kind in [tokenize.COMMENT, tokenize.NEWLINE, tokenize.NL]: |
514 continue |
514 continue |
515 elif kind == tokenize.STRING: # first STRING should be docstring |
515 elif kind == tokenize.STRING: # first STRING should be docstring |
516 return DocStyleContext(value, line - 1, "docstring") |
516 return DocStyleContext(value, line - 1, "docstring") |