def commentdoc(text):
if not text:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>'.format(repr(text))<EOL>)<EOL><DEDENT>commentlines = []<EOL>for line in text.splitlines():<EOL><INDENT>alternating_words_ws = list(filter(None, WHITESPACE_PATTERN_TEXT.split(line)))<EOL>starts_with_whitespace = bool(<EOL>WHITESPACE_PATTERN_TEXT.match(alternating_words_ws[<NUM_LIT:0>])<EOL>)<EOL>if starts_with_whitespace:<EOL><INDENT>prefix = alternating_words_ws[<NUM_LIT:0>]<EOL>alternating_words_ws = alternating_words_ws[<NUM_LIT:1>:]<EOL><DEDENT>else:<EOL><INDENT>prefix = NIL<EOL><DEDENT>if len(alternating_words_ws) % <NUM_LIT:2> == <NUM_LIT:0>:<EOL><INDENT>alternating_words_ws = alternating_words_ws[:-<NUM_LIT:1>]<EOL><DEDENT>for idx, tup in enumerate(zip(alternating_words_ws, cycle([False, True]))):<EOL><INDENT>part, is_ws = tup<EOL>if is_ws:<EOL><INDENT>alternating_words_ws[idx] = flat_choice(<EOL>when_flat=part,<EOL>when_broken=always_break(<EOL>concat([<EOL>HARDLINE,<EOL>'<STR_LIT>',<EOL>])<EOL>)<EOL>)<EOL><DEDENT><DEDENT>commentlines.append(<EOL>concat([<EOL>'<STR_LIT>',<EOL>prefix,<EOL>fill(alternating_words_ws)<EOL>])<EOL>)<EOL><DEDENT>outer = identity<EOL>if len(commentlines) > <NUM_LIT:1>:<EOL><INDENT>outer = always_break<EOL><DEDENT>return annotate(<EOL>Token.COMMENT_SINGLE,<EOL>outer(concat(intersperse(HARDLINE, commentlines)))<EOL>)<EOL>
Returns a Doc representing a comment `text`. `text` is
    treated as words, and any whitespace may be used to break
    the comment to multiple lines.