tools/json_schema_compiler/idl_schema.py
def ProcessComment(comment):
  '''
  Convert a comment into a parent comment and a list of parameter comments.

  Function comments are of the form:
    Function documentation. May contain HTML and multiple lines.

    |arg1_name|: Description of arg1. Use <var>argument</var> to refer
    to other arguments.
    |arg2_name|: Description of arg2...

  Newlines are removed, and leading and trailing whitespace is stripped.

  Args:
    comment: The string from a Comment node.

  Returns: A tuple that looks like:
    (
      "The processed comment, minus all |parameter| mentions and jsexterns.",
      "Any block wrapped in <jsexterns></jsexterns>.",
      {
        'parameter_name_1': "The comment that followed |parameter_name_1|:",
        ...
      }
    )
  '''
  jsexterns = None
  match = re.search('<jsexterns>(.*)</jsexterns>', comment, re.DOTALL)
  if match:
    jsexterns = match.group(1).strip()
    comment = comment[:match.start()] + comment[match.end():]

  def add_paragraphs(content):
    paragraphs = content.split('\n\n')
    if len(paragraphs) < 2:
      return content
    return '<p>' + '</p><p>'.join(p.strip() for p in paragraphs) + '</p>'

  # Find all the parameter comments of the form '|name|: comment'.
  parameter_starts = list(re.finditer(r' *\|([^|]*)\| *: *', comment))

  # Get the parent comment (everything before the first parameter comment.
  first_parameter_location = (parameter_starts[0].start()
                              if parameter_starts else len(comment))
  parent_comment = (add_paragraphs(comment[:first_parameter_location].strip())
                    .replace('\n', ''))

  params = OrderedDict()
  for (cur_param, next_param) in zip_longest(parameter_starts,
                                             parameter_starts[1:]):
    param_name = cur_param.group(1)

    # A parameter's comment goes from the end of its introduction to the
    # beginning of the next parameter's introduction.
    param_comment_start = cur_param.end()
    param_comment_end = next_param.start() if next_param else len(comment)
    params[param_name] = (
        add_paragraphs(comment[param_comment_start:param_comment_end].strip())
        .replace('\n', ''))

  return (parent_comment, jsexterns, params)

  Convert a comment into a parent comment and a list of parameter comments.

  Function comments are of the form:
    Function documentation. May contain HTML and multiple lines.

    |arg1_name|: Description of arg1. Use <var>argument</var> to refer
    to other arguments.
    |arg2_name|: Description of arg2...

  Newlines are removed, and leading and trailing whitespace is stripped.

  Args:
    comment: The string from a Comment node.

  Returns: A tuple that looks like:
    (
      "The processed comment, minus all |parameter| mentions and jsexterns.",
      "Any block wrapped in <jsexterns></jsexterns>.",
      {
        'parameter_name_1': "The comment that followed |parameter_name_1|:",
        ...
      }
    )
  
Convert a comment into a parent comment and a list of parameter comments.
Function comments are of the form:
Function documentation. May contain HTML and multiple lines.

|arg1_name|: Description of arg1. Use argument to refer
to other arguments.
|arg2_name|: Description of arg2

Newlines are removed, and leading and trailing whitespace is stripped.
Convert a comment into a parent comment and a list of parameter comments . Function comments are of the form : Function documentation . May contain HTML and multiple lines . |arg1_name| : Description of arg1 . Use argument to refer to other arguments . |arg2_name| : Description of arg2 Newlines are removed and leading and trailing whitespace is stripped .
def ProcessComment(comment):
  jsexterns = None
  match = re.search('<jsexterns>(.*)</jsexterns>', comment, re.DOTALL)
  if match:
    jsexterns = match.group(1).strip()
    comment = comment[:match.start()] + comment[match.end():]
  def add_paragraphs(content):
    paragraphs = content.split('\n\n')
    if len(paragraphs) < 2:
      return content
    return '<p>' + '</p><p>'.join(p.strip() for p in paragraphs) + '</p>'
  parameter_starts = list(re.finditer(r' *\|([^|]*)\| *: *', comment))
  first_parameter_location = (parameter_starts[0].start()
                              if parameter_starts else len(comment))
  parent_comment = (add_paragraphs(comment[:first_parameter_location].strip())
                    .replace('\n', ''))
  params = OrderedDict()
  for (cur_param, next_param) in zip_longest(parameter_starts,
                                             parameter_starts[1:]):
    param_name = cur_param.group(1)
    param_comment_start = cur_param.end()
    param_comment_end = next_param.start() if next_param else len(comment)
    params[param_name] = (
        add_paragraphs(comment[param_comment_start:param_comment_end].strip())
        .replace('\n', ''))
  return (parent_comment, jsexterns, params)
def ProcessComment ( comment ) : jsexterns = None match = re . search ( '<jsexterns>(.*)</jsexterns>' , comment , re . DOTALL ) if match : jsexterns = match . group ( 1 ) . strip ( ) comment = comment [ : match . start ( ) ] + comment [ match . end ( ) : ] def add_paragraphs ( content ) : paragraphs = content . split ( '\n\n' ) if len ( paragraphs ) < 2 : return content return '<p>' + '</p><p>' . join ( p . strip ( ) for p in paragraphs ) + '</p>' parameter_starts = list ( re . finditer ( r' *\|([^|]*)\| *: *' , comment ) ) first_parameter_location = ( parameter_starts [ 0 ] . start ( ) if parameter_starts else len ( comment ) ) parent_comment = ( add_paragraphs ( comment [ : first_parameter_location ] . strip ( ) ) . replace ( '\n' , '' ) ) params = OrderedDict ( ) for ( cur_param , next_param ) in zip_longest ( parameter_starts , parameter_starts [ 1 : ] ) : param_name = cur_param . group ( 1 ) param_comment_start = cur_param . end ( ) param_comment_end = next_param . start ( ) if next_param else len ( comment ) params [ param_name ] = ( add_paragraphs ( comment [ param_comment_start : param_comment_end ] . strip ( ) ) . replace ( '\n' , '' ) ) return ( parent_comment , jsexterns , params )
Convert a comment into a parent comment and a list of parameter comments.
Convert a comment into a parent comment and a list of parameter comments .
'''
  Convert a comment into a parent comment and a list of parameter comments.

  Function comments are of the form:
    Function documentation. May contain HTML and multiple lines.

    |arg1_name|: Description of arg1. Use <var>argument</var> to refer
    to other arguments.
    |arg2_name|: Description of arg2...

  Newlines are removed, and leading and trailing whitespace is stripped.

  Args:
    comment: The string from a Comment node.

  Returns: A tuple that looks like:
    (
      "The processed comment, minus all |parameter| mentions and jsexterns.",
      "Any block wrapped in <jsexterns></jsexterns>.",
      {
        'parameter_name_1': "The comment that followed |parameter_name_1|:",
        ...
      }
    )
  ''' # Find all the parameter comments of the form '|name|: comment'. # Get the parent comment (everything before the first parameter comment. # A parameter's comment goes from the end of its introduction to the # beginning of the next parameter's introduction.
comment
The string from a Comment node.
The string from a Comment node .