(value)
return ret + ('\n%s\n' % comment_prefix).join(wrapped_blocks)
Template filter to line wrap a typical block comment.

  Take a block of text where each line has a common comment prefix, divide it
  into multiple sections, line wrap each section and string them back together.
  Sections are defined as blank lines or lines containing only the comment
  prefix.

  Example template usage:
    /**{% filter block_comment %}
     * wwelrj wlejrwerl jrl (very long line ...) rwrwr.
     *
     * more text
     * and more
     * {% endfilter %}
     */

  Args:
    value: (str) a block of text to line wrap.
  Returns:
    (str) the wrapped text.
Template filter to line wrap a typical block comment.
Template filter to line wrap a typical block comment .
def block_comment(value):  # pylint: disable=g-bad-name
  """Template filter to line wrap a typical block comment.

  Take a block of text where each line has a common comment prefix, divide it
  into multiple sections, line wrap each section and string them back together.
  Sections are defined as blank lines or lines containing only the comment
  prefix.

  Example template usage:
    /**{% filter block_comment %}
     * wwelrj wlejrwerl jrl (very long line ...) rwrwr.
     *
     * more text
     * and more
     * {% endfilter %}
     */

  Args:
    value: (str) a block of text to line wrap.
  Returns:
    (str) the wrapped text.
  """
  if not value:
    return ''
  lines = value.split('\n')
  # Ignore a leading blank line while figuring out the comment tag. This allows
  # us to put the filter tag above the content, rather than flush left before
  # it. It makes the template easier to read.
  leading_blank = False
  if not lines[0]:
    leading_blank = True
    comment_prefix = _ExtractCommentPrefix(lines[1])
  else:
    comment_prefix = _ExtractCommentPrefix(lines[0])
  # TODO(user): Default is for backwards-compatibility; remove when safe to
  # do so.
  language = _GetCurrentLanguage(default='java')
  line_width = _language_defaults[language][_LINE_WIDTH]
  wrapper = textwrap.TextWrapper(width=line_width,
                                 replace_whitespace=False,
                                 initial_indent=('%s ' % comment_prefix),
                                 subsequent_indent=('%s ' % comment_prefix))
  wrapped_blocks = []
  for block in _DivideIntoBlocks(lines, comment_prefix):
    wrapped_blocks.append(wrapper.fill(' '.join(block)))
  ret = ''
  if leading_blank:
    ret = '\n'
  return ret + ('\n%s\n' % comment_prefix).join(wrapped_blocks)
def block_comment ( value ) : # pylint: disable=g-bad-name if not value : return '' lines = value . split ( '\n' ) # Ignore a leading blank line while figuring out the comment tag. This allows # us to put the filter tag above the content, rather than flush left before # it. It makes the template easier to read. leading_blank = False if not lines [ 0 ] : leading_blank = True comment_prefix = _ExtractCommentPrefix ( lines [ 1 ] ) else : comment_prefix = _ExtractCommentPrefix ( lines [ 0 ] ) # TODO(user): Default is for backwards-compatibility; remove when safe to # do so. language = _GetCurrentLanguage ( default = 'java' ) line_width = _language_defaults [ language ] [ _LINE_WIDTH ] wrapper = textwrap . TextWrapper ( width = line_width , replace_whitespace = False , initial_indent = ( '%s ' % comment_prefix ) , subsequent_indent = ( '%s ' % comment_prefix ) ) wrapped_blocks = [ ] for block in _DivideIntoBlocks ( lines , comment_prefix ) : wrapped_blocks . append ( wrapper . fill ( ' ' . join ( block ) ) ) ret = '' if leading_blank : ret = '\n' return ret + ( '\n%s\n' % comment_prefix ) . join ( wrapped_blocks )