Creates a comment block

        Args:
            text (str): content of comment without #
            comment_prefix (str): character indicating start of comment

        Returns:
            self for chaining
347437
def comment(self, text, comment_prefix='#'):
        
        comment = Comment(self._container)
        if not text.startswith(comment_prefix):
            text = "{} {}".format(comment_prefix, text)
        if not text.endswith('\n'):
            text = "{}{}".format(text, '\n')
        comment.add_line(text)
        self._container.structure.insert(self._idx, comment)
        self._idx += 1
        return self
980331
def highlight_block(self, text):
        """"""
        text = to_text_string(text)
        previous_state = tbh.get_state(self.currentBlock().previous())
        
        if previous_state == self.COMMENT:
            self.setFormat(0, len(text), self.formats["comment"])
        else:
            previous_state = self.NORMAL
            self.setFormat(0, len(text), self.formats["normal"])
        
        tbh.set_state(self.currentBlock(), previous_state)
        match = self.PROG.search(text)        

        match_count = 0
        n_characters = len(text)
        # There should never be more matches than characters in the text.
        while match and match_count < n_characters:
            match_dict = match.groupdict()
            for key, value in list(match_dict.items()):
                if value:
                    start, end = match.span(key)
                    if previous_state == self.COMMENT:
                        if key == "multiline_comment_end":
                            tbh.set_state(self.currentBlock(), self.NORMAL)
                            self.setFormat(end, len(text),
                                           self.formats["normal"])
                        else:
                            tbh.set_state(self.currentBlock(), self.COMMENT)
                            self.setFormat(0, len(text),
                                           self.formats["comment"])
                    else:
                        if key == "multiline_comment_start":
                            tbh.set_state(self.currentBlock(), self.COMMENT)
                            self.setFormat(start, len(text),
                                           self.formats["comment"])
                        else:
                            tbh.set_state(self.currentBlock(), self.NORMAL)
                            try:
                                self.setFormat(start, end-start,
                                               self.formats[key])
                            except KeyError:
                                # happens with unmatched end-of-comment;
                                # see issue 1462
                                pass
            
            match = self.PROG.search(text, match.end())
            match_count += 1
        
        self.highlight_spaces(text)
73952
def commentdoc(text):
    """"""
    if not text:
        raise ValueError(
            'Expected non-empty comment str, got {}'.format(repr(text))
        )

    commentlines = []
    for line in text.splitlines():
        alternating_words_ws = list(filter(None, WHITESPACE_PATTERN_TEXT.split(line)))
        starts_with_whitespace = bool(
            WHITESPACE_PATTERN_TEXT.match(alternating_words_ws[0])
        )

        if starts_with_whitespace:
            prefix = alternating_words_ws[0]
            alternating_words_ws = alternating_words_ws[1:]
        else:
            prefix = NIL

        if len(alternating_words_ws) % 2 == 0:
            # The last part must be whitespace.
            alternating_words_ws = alternating_words_ws[:-1]

        for idx, tup in enumerate(zip(alternating_words_ws, cycle([False, True]))):
            part, is_ws = tup
            if is_ws:
                alternating_words_ws[idx] = flat_choice(
                    when_flat=part,
                    when_broken=always_break(
                        concat([
                            HARDLINE,
                            '# ',
                        ])
                    )
                )

        commentlines.append(
            concat([
                '# ',
                prefix,
                fill(alternating_words_ws)
            ])
        )

    outer = identity

    if len(commentlines) > 1:
        outer = always_break

    return annotate(
        Token.COMMENT_SINGLE,
        outer(concat(intersperse(HARDLINE, commentlines)))
    )
960257
def create_comment(self, body):
        
        assert isinstance(body, (str, unicode)), body
        post_parameters = {
            "body": body,
        }
        headers, data = self._requester.requestJsonAndCheck(
            "POST",
            self.url + "/comments",
            input=post_parameters
        )
        return github.IssueComment.IssueComment(self._requester, headers, data, completed=True)
856936
def _pythonized_comments(tokens):
    
    is_after_colon = True
    for token_type, token_text in tokens:
        if is_after_colon and (token_type in pygments.token.String):
            token_type = pygments.token.Comment
        elif token_text == ':':
            is_after_colon = True
        elif token_type not in pygments.token.Comment:
            is_whitespace = len(token_text.rstrip(' \f\n\r\t')) == 0
            if not is_whitespace:
                is_after_colon = False
        yield token_type, token_text
319664
def add_comment(self, line: str) -> None:
        ''' '''
        # the rule is like
        #
        # # comment line  --> add to last comment
        # blank line --> clears last comment
        # [ ] --> use last comment
        # parameter: --> use last comment
        # All others: clear last comment
        self._last_comment += (' ' if self._last_comment else '') + \
            line.lstrip('#').strip()
626730
def nextValidComment(self, text, start=0):
        

        m = min([self.lineComment(text, start),
                 self.blockComment(text, start)],
                key=lambda m: m.start(0) if m else len(text))
        return m
1232123
def appendText(self, text):
        '''
            
        '''
        # self.text is just raw string of the text
        self.text += text
        self.isSelfClosing = False # inner text means it can't self close anymo
        # self.blocks is either text or tags, in order of appearance
        self.blocks.append(text)
115159
def comment(self, comment, show=False, endline=True, newpar=False):
        """"""
        if not endline:
            comment += "<NOBR>"
        if newpar:
            comment += "<BR>"
        self._write("comment:%d:%s\n" % (int(show), comment))
        return self
250721
def set_comment(self,c):
        
        c = ' '+c.replace('-','').strip()+' '
        self.node.insert(0,etree.Comment(c))
1198711
def _add_comments(self, comments, original_string=""):
        
        return comments and "{0}  # {1}".format(self._strip_comments(original_string)[0],
                                                "; ".join(comments)) or original_string
1343996
def _prevNonCommentBlock(self, block):
        
        block = self._prevNonEmptyBlock(block)
        while block.isValid() and self._isCommentBlock(block):
            block = self._prevNonEmptyBlock(block)
        return block
486760
def comment(self, text):
        
        url = self._imgur._base_url + "/3/comment"
        payload = {'image_id': self.id, 'comment': text}
        resp = self._imgur._send_request(url, params=payload, needs_auth=True,
                                         method='POST')
        return Comment(resp, imgur=self._imgur, has_fetched=False)
554193
def indent(text, prefix):
    
    # Based on Python 3's textwrap.indent
    def prefixed_lines():
        for line in text.splitlines(True):
            yield (prefix + line if line.strip() else line)
    return u"".join(prefixed_lines())
891530
def handle_block(self, match, block_start=None):
        
        # we have to handle comments inside blocks because you could do this:
        # {% blk foo %}asdf {# {% endblk %} #} {%endblk%}
        # they still end up in the data/raw_data of the block itself, but we
        # have to know to ignore stuff until the end comment marker!
        found = BlockTag(**match.groupdict())
        # the full block started at the given match start, which may include
        # prefixed whitespace! we'll strip it later
        if block_start is None:
            block_start = match.start()

        self._block_contents = ''

        # you can have as many comments in your block as you'd like!
        while True:
            match = self._expect_match(
                '"{}"'.format(found.end_block_type_name),
                found.end_pat(), COMMENT_START_PATTERN, RAW_START_PATTERN,
                regex('''(?P<quote>(['"]))''')
            )
            groups = match.groupdict()
            if groups.get('endblock') is not None:
                break

            self.advance(match.end())

            if groups.get('comment_start') is not None:
                self.expect_comment_end()
            elif groups.get('raw_start') is not None:
                self.expect_raw_end()
            elif groups.get('quote') is not None:
                self.rewind()
                match = self._expect_match('any string', STRING_PATTERN)
                self.advance(match.end())
            else:
                raise dbt.exceptions.InternalException(
                    'unhandled regex in handle_block, no match: {}'
                    .format(groups)
                )

        # we want to advance to just the end tag at first, to extract the
        # contents
        self.advance(match.start())
        found.contents = self._block_contents
        self._block_contents = None
        # now advance to the end
        self.advance(match.end())
        found.full_block = self.data[block_start:self.pos]
        return found
870041
def getargspecfromtext(text):
    
    blocks = text.split("\n\n")
    first_block = blocks[0].strip()
    return getsignaturefromtext(first_block, '')
1355916
def comment_filter(comment_text):
    
    filter_func = settings.COMMENT_FILTER
    if not filter_func:
        def filter_func(s):
            return linebreaksbr(urlize(s, autoescape=True), autoescape=True)
    elif not callable(filter_func):
        filter_func = import_dotted_path(filter_func)
    return filter_func(comment_text)